Acceleration Sensor Connected, but values are odd....

I got the Acceleration sensor working (if people are still having problems with this, PM me, i’d be happy to help) but the values i’m getting are odd…

when sitting still the value returned by Get_Analog_Value(rc_ana_in09) is around 716-717, and can get to about 915 or so when shaked…

is this normal?

how can i transofrm these to normal 0-255 values? should i?


I can’t really tell you if those values are normal since we haven’t looked at the provided accelerometer yet, but I can tell you why it’s not a value from 0-255. The RC analog inputs are 10-bit, meaning they have a range of 0-1023. You can obtain a 0-255 value by dropping the lower two bits (divide by four or use the bit-shift operator (>>)), but if you do that you’re just throwing away accuracy which is usually a bad idea.


pwm01 = (unsigned char) (Get_Analog_Value (rc_ana_in01) >> 2);

Theres no point in bit shifting the input from the accelerometer, seeing as that data is only being used locally in calculations, and not directly exported to a motor control.

what exactly are we suppose to understand from these readings? are the values in m/s^2 ? are they in ft/s^2 ? how can we use those values to determine the robot’s acceleration in m/s^2 ? is it in g’s?

someone from another team told me that in order to get the acceleration in g’s i have to calculate arctangent of the sinus of the value I’m getting , but that doesn’t make any sense to me . :confused: :confused:

The values are in “A/D counts”, which is a mythical unit. If you want to convert them into physical units, (like g’s or m/s^2) you need to do a little math.

The first thing to do is to look at the accelerometer data sheet to see what the accelerometer gain is. If should say something like: “Gain: 100 mV/G”

Now you need to use unit conversion (like you learned in chemistry or physics class) to determine the conversion between and G’s. For example:

             5000 mV            1 G
1 count * --------------- * --------------
           1024 counts        X  mV

where X is the accelerometer gain in mV/G.

Now you have a conversion factor from counts to G’s and vice versa.

(NOTE: sorry about using the “code” window. That’s not actually code: it’s the only way I could get my equation to look right.)

I need to add one thing:

When you sit the accelerometer flat on the table (NOT aligned with gravity), the A/D reading (in counts) is the zero G reading of the accelerometer. You should subtract this zero-G reading from your other readings before applying the conversion factor that I mentioned above.

For example:

on the table you see that the average is 705. This is 0 G’s

let’s say your accelerometer gain (also called accelerometer sensitivity) is 200 mV/G

Therefore, your conversion factor is 1 count = (5000 mV/1024 coutns) * (1 G / 200 mV)

Thus, 1 count = 0.024414 G (or 1 G = 40.96 counts).

Now, turn the accelerometer so that it is aligned with gravity. Your new reading should be approximately 746 A/D counts (i.e. 705 + 41 = 746)

For another example, let’s say you put the accelerometer at the edge of a centrifuge and you want to see what the acceleration is at the edge of the centrifuge. The accelerometer reads 923 (after averaging out the noise). How many G’s is that?

923 - 705 = 218 counts of acceleration.

1 G = 40.96 counts, so 218 counts = 218 counts * 1G / 40.96 counts

218 counts = 5.322 G’s

Therefore, you see 5.322 G’s at the edge of the centrifuge.

Thanks for your help. :slight_smile: