Go Down

Topic: unstable accelerometer (Read 3313 times) previous topic - next topic



I have a school project in which I need to control a robotic arm. I have to control it using sensors mounted on the user's hand. I have a 1-axis gyro for the up-down movement of the gripper and a 3-axis accelerometer (mma7361) for the rest of the arm (up-down, left-right and forward-backward).

I want to use the 3 axes separately: z for up-down movement (not sure if it's better to tilt the sensor or to move it up and down), y for left-right turning (again, I'm thinking of tilting the accelerometer instead of moving it from left to right) and x for forward-backwards movement.

My problem is that the data from the accelerometer is very unstable, very noisy. When I move the sensor up and down I don't have a stable output. The motor switches chaotically between directions although it is a steady linear movement.

The project is due in 1 week and I really need some help.


P.S. tomorrow I'll buy another accelerometer, this time the adxl335 one, hoping it's less noisy. I have to stay with analog sensor because I don't think I have time (or the money) to switch to digital and implement them.


Yes, they are noisy.
They do not only measure the motion, but also every vibration of the motor.

First of all, is there any noise from outside to the analog lines ?
For example the current through the motor could influence the analog line.
A good ground is essential.

Next, can you filter the output of the accelerometer ?
For example in software, but you could place an RC-filter in the analog lines.

Perhaps you can adjust the software feedback to the motor, reduce gain or something like that.


For measuring orientation a typical setup is to use an accelerometer with heavy low-pass filtering (timescale of seconds) to provide the drift-free reference orientation.  A gyro is used for faster rotations as gyros are insensitive to vibrations and short-time scale movements - but MEMS gyros drift over time (timescale of tens of seconds).  The combination of gyro and accelerometer gives the best of both worlds.

For measuring actual movement and accelerations you have to deal with the noise - filter it out with a low-pass filter as much as you can get away with, or integrate the output to give a velocity signal (which will drift with time).  Furthermore there is always the acceleration due to gravity to subtract-out from the result (which you can only do accurately if you know the orientation - which suggests a gyro is a good idea).

Its a bit more complex than it might seem at first - but you will learn a lot from trying.  One technique that springs to mind is to stop the motors before taking a reading (if using accelerometer as tilt-sensor), and then use this as a correction term to fire the motors up again - constantly estimate the amount of motor motion, do the motion, measure the result, update the error estimate and repeat till close enough.  By taking measurements when at rest you are removing lots of unknowns from the equation (literally!).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Do you need to use accelerometers?

I did something similar: http://www.youtube.com/watch?v=6upw98gZR5Q

you can find information on my blog: http://fkeel.blogspot.nl/search/label/ShadowCoat


you will also need some low-pass filtering, as others have suggested. This is the general idea of what you need to be doing:

Code: [Select]
float alpha = 0.8;
float rawSignal = sensorInput;
float oldCeanSignal;
float cleanSignal;

void loop()
oldCleanSignal = cleanSignal;
cleanSignal = alpha * oldCleanSignal + (1 - alpha) * rawSignal;



Shoot me if I am wrong, but if your are reading each axis one after the other, won't there be an error component due to switching analog inputs ? In which case a immediate improvement would be to take a dummy reading from each input and discard it before taking the reading you intend to use ?


read zaxis and discard
read zaxis for stable reading
read xaxis and discard
read xaxis for stable reading
read yaxis and discard
read yaxis for stable reading

All the other comments re filtering still apply, but my understanding is that errors on analogReads immediatley following a change in the pin being read are an expected feature of Arduino and that dummy readings should be take to allow the new input to stabilise

Duane B

Read this
then watch this




I was told the same thing, however, when I was using the CD74HC4067 together with an Arduino mega, I never observed the behavior you just described.



thank you all for your replies.

I have switched to the adxl335 accelerometer and it is less noisy, as marketed, but not sensitive enough for my application: +- 3g opposed to +- 1.5g in the same voltage interval from the mma7361.

due to the lack of time till the deadline I adopted fkeel's solution with gyros and they work great. now it's just a matter of adjusting the threshold values.

in the future I will probably try to implement the accelerometer solution.

thank you again


actually, I use stretch sensors...

or are you referring to the low pass filtering?

Go Up