16
\$\begingroup\$

i have an analogue devices ADXL203 accelerometer on a breadout board and was wanting to use this to measure the inclination of some equipment at a reasonably high frequency (20-30 Hz). i am hooking it up to a campbells cr3000 logger to do the sensing. Does anyone have directions on how to interpret the sensor outputs. thanks

\$\endgroup\$
2
  • \$\begingroup\$ thanks to everyone for the comments. very helpful regards TROY \$\endgroup\$ Commented Jun 10, 2010 at 3:27
  • \$\begingroup\$ I know I have the highest, but if you do not like mine, at least accepts someone's. \$\endgroup\$
    – Kortuk
    Commented Oct 5, 2010 at 14:52

5 Answers 5

12
\$\begingroup\$

I have a number of things to say here, and some of them do involve agreeing with pingswept and some with penjuin.

cr3000

The cr3000 sampling at 16 bits and 100 Hz is going to be sampling a little slow for you to easily remove noise from your data but at a significantly higher precision then will be usable. I doubt you can get 13 or 14 bits of precision without some pretty good filtering algorithms. Accelerometers have taught me that vibration is the devil, blasted phonons.

Output Capacitor

You need to make sure you do as the datasheet says and signal theory dicates. To quote the datasheet:

The output of the ADXL103/ADXL203 has a typical bandwidth of 2.5 kHz. The user must filter the signal at this point to limit aliasing errors. The analog bandwidth must be no more than half the analog-to-digital sampling frequency to minimize aliasing. The analog bandwidth can be further decreased to reduce noise and improve resolution.

This means you need to pick a capacitor to keep your rate below 50Hz. If you place it above this you can get aliasing, and aliasing makes vibration noise a devil you signed a deal with. They state how to calculate the noise levels from the device, and at a 50Hz bandwidth a peak to peak noise of .006 * Gravity will not even be noticed if you have this on a device with vibrations.

Interpreting Data

This is probably what you are most interested in, and is relatively easy to do. You need to tag a time that the device is at neutral, this being when it is flat and you have it relatively still. Give it a second or two at this point, and then you can take the median of this data to determine the no-G voltage. Then you can use this as a point you compare the device to. Now, from this point, I can directly quote the data-sheet:

When the accelerometer is perpendicular to gravity, its output changes nearly 17.5 mg per degree of tilt.

So you can just simply use this approximation if you are not going to tilt very much, but you will need to use geometry if you plan to tilt in both direction and in angles that are not extremely small.

If you are going to be going larger, they even have the equations spelled out as:

PITCH = ASIN(AX/1 g)
ROLL = ASIN(AY/1 g)

As far as I can tel your device gives a 1V change per 1G of acceleration placed on it. If you have done the calibrate phase, then you should be able to take measurments, subtract the offset, and you have the number of Gs being experienced.

Stop Reading Here unless you run into issues or you would like more information to improve approach.

I added a decent bit more talking about other approaches and methods to improve your approach for fast changing systems or systems where you are going to program the device doing the samples.

Sampling Frequency

You need to be sampling significantly faster than the speed at which your device changes the directions in which it is accelerating, as you have to measure orientation 20-30 times per second. you need to be able to measure quickly enough to filter out vibration noise and acceleration due to other affects, which i have found to be quite large when working with an accelerometer.

3-axis accelerometer

Second, if you have a three axis accelerometer, then you can quite easily recognize when one axis is losing part of the acceleration due to gravity(ie. When the z axis has it's magnitude drop by 2m/s^2, you know that the gain you saw on the other axis is gravity). This will still be messy, but in general there will be an addition of acceleration which gives the velocity needed to change your orientation and then a change in acceleration due to orientation change, often allowing you to recognize orientation.

Problems with 2-axis

This is going to be, as penjuin said, almost impossible with a 2 axis accelerometer, and sketchy at best if you have a system that can have 20-30 different orientations a second, or if you need to have an exact measure of orientation at all times. I am sure a master's student could write a pretty nice thesis on this, or a Doctorate could write a dissertation on improving this algorithm.

Vibration Noise

To add more, if you can put your device on top of something that will keep it statically locked to the motion of your device, but dampens vibration, you will get much better numbers and not need as much software filtering. Some simple foam type padding can be placed between the accelerometer and your device, and if it is digital this should not increase electrical noise and help absorb some vibration noise. This should only be done if you see problems with the vibration noise.

Digital Accelerometer

I would suggest a digital accelerometer that you can use SPI to connect to. Data can be clocked out at a very very high rate and you can work in the back ground as your SPI does the constant work of loading the next set of values. You will need to have a nice microcontroller if it is going to be done digitally. If you can give me better specifics on what you are wanting to do I can give better feedback. If you want a warning based on tilt detection then it should be very easy to do with all analog, but if you want to measure the position and angle of equipment during operation, get ready for some work.

Please let me know if there is something I can add to make this answer more clear or applicable to what you were looking for.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Just for the record, this answer is epic. \$\endgroup\$
    – pingswept
    Commented Jun 3, 2010 at 16:51
  • 1
    \$\begingroup\$ Dr. Kortuk, Ph.D in accelerometers! :-) \$\endgroup\$ Commented Jun 3, 2010 at 17:08
  • \$\begingroup\$ I wrote this answer because I kept thinking I had forgotten something, then I realized it was a bit long, and added the real quick how to do it answer, but it seems people prefer the long answer. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 21:57
  • \$\begingroup\$ On the vibration noise, I may have had a larger amount during operating time due to the presence of a Brushless DC(BLDC) Motor, but before it was turned on there were still significant vibration figures. \$\endgroup\$
    – Kortuk
    Commented Jun 4, 2010 at 14:33
3
\$\begingroup\$

I have written and rewritten this answer several times with many crazy mathematical ideas, but I honestly don't think this can be done with any accuracy. You can do some vector maths, but what if:

  • The object stops moving
  • The object has a constant velocity
  • The object hits a bump/you bump it
  • The force generated moving up the incline is below the resolution of the Z axis

While I'm sure there is some crazy workaround for doing this sort of thing, I'm not sure it would be worth it; accelerometers are simply not designed for this task (at least to my knowledge). For what you are trying to achieve, I would suggest a gyroscopic approach using any of these, all of which would be fairly resistant to all of the above problems.

\$\endgroup\$
6
  • \$\begingroup\$ Accelerometers are designed for this actually, there is an entire section on how to do it. Accelerometers are very very low cost in many cases and sometimes cost is a larger issue then perfect functionality. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 16:03
  • 3
    \$\begingroup\$ I always try to explain this to students, and I am going to add it here because I think it is an important concept. Engineering is not always about doing it the best way, it is about doing it in such a way that the user has cannot tell the difference in anything except the price tag. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 16:04
  • 2
    \$\begingroup\$ There is something to be said for doing it first, and there is alot to be said for doing it better than the last guy. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 16:04
  • \$\begingroup\$ I agree, but it depends on your motives (which troy has not stated); do you want it to work well, or do you want to learn ? They are not necessarily mutually exclusive, but you wouldn't write your own compiler just to blink an LED unless you specifically wanted to learn about compiler design. \$\endgroup\$
    – jeremy
    Commented Jun 3, 2010 at 20:33
  • \$\begingroup\$ Yeah, I adding that to discuss your answer, in general if he needs to be able to tell a different orientation 30 times a second it is going to have gigantic accelerations on it, which in turn means you need a lot more than 100 samples a second. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 20:42
3
\$\begingroup\$

If I understand the datasheet correctly, the output for each axis will vary between 1.5 V and 3.5 V as you tilt around the axis. When the device is flat (ignoring the ±1 degree package alignment error), both outputs should read 2.5 V.

If you only need to measure the tilt in one direction, you can take the arcsin of the deviation from 2.5 V to get the angle in radians, then convert to degrees. If the device can tilt in any direction, you can calculate the two angles, and then calculate the compound angle from those.

To be explicit: angle around one axis = (180/π) * arcsin (Vout - 2.5)

To get good frequency response, you'll need small output capacitors, Cx and Cy. From footnote 6 on p. 3 of the datasheet, it looks like 0.02 uF would give you a bandwidth of 250 Hz, which is probably about right for your sample rate. You could perhaps go as high as 0.1 uF, limiting the bandwidth to 50 Hz, but your signals will start to get attenuated.

\$\endgroup\$
2
  • \$\begingroup\$ I do not think it will attenuate the signals, unless you are referring to the higher frequencies, which is the point of the cap. He needs to go to 50Hz or lower to match his data sampling device. \$\endgroup\$
    – Kortuk
    Commented Jun 3, 2010 at 16:10
  • 1
    \$\begingroup\$ Ah, I hadn't thought about it from the aliasing perspective. I still think that large caps will attenuate high frequency signals, but that's actually a good thing in this case. So yes, setting the bandwidth around 50 Hz is good. \$\endgroup\$
    – pingswept
    Commented Jun 3, 2010 at 16:54
3
\$\begingroup\$

I am adding a second answer, because my other one is large, and you may just want simple.

Your filter cap needs to be 0.10 uF or larger to keep you below your aliasing rate(50Hz). You need to give a calibration phase of a couple seconds with your device sitting level with all Gravity acceleration in the Z direction, this is to determine your zero G point.

The voltage you measure for your zero G point, it will probably be different for the X and Y direction, represents nothing. Just take whatever voltage you get and subtract that from it. This voltage, with offset subtracted is the number of Gs that you are getting in that direction.

Take the arcsin and you are going to get your angle in that direction.

This ignores noise and other acceleration. be prepared for NaN to be a result if you have it fully tilted and there is any noise.

\$\endgroup\$
0
\$\begingroup\$

To get any angle, you need to measure gravity's acceleration in both X- and Y- directions. subtract out the middle voltage (2.5V) so that zero is "no acceleration."

Now you can find the angle with arcsin(y/x). But that is annoying to use, because of the division, and because the sign is ambiguous, so what you really want the C function atan2(y,x). atan2() gets the sign right for all 360 degrees.


Off-topic, since you aren't using a micro: If you are looking for atan2() to use on a microcontroller, there is an atan2() generator on my website: http://vivara.net/cgi-bin/cordic.cgi

\$\endgroup\$
1
  • \$\begingroup\$ It is not a guaranteed 2.5 V for 0G. since he will probably use a computer to do the math I doubt that the method he uses to do the math will mater. \$\endgroup\$
    – Kortuk
    Commented Jun 14, 2010 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.