Quote:
|
Originally Posted by naor52
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?
Thanks!
|
No one here gave a particularly helpful explanation unless you have a good understanding of the inner workings of the code, so here ya go.
Get_Analog_Value returns an int value from 0-1024, rather than the unsigned chars. This is based on the voltage returned along the signal wire from the accelerometer.
The readings from the accelerometer pointing straight up with it resting on a nonmoving surface should be equivalent to an acceleration of zero.
When you turn the accelerometer onto its side, one of the values it returns should change. The difference between this value and the original one represents 1g of acceleration, and can be used to scale all the readings.
Precisely how to do that in code is for you to figure out.
By the way, using a timer and low level access to the ADC (Analog-digital converter), it is possible to sample the device more than once per loop, and closer to if not more frequently than the rate than device updates itself. The adc code on
http://kevin.org/frc can help you do this. Use the gyro code as an example, or wait until kevin uploads his new accelerometer code. (Soon, please

)
On a related note, the specs for the accelerometer have it working at 3V. Is there a way to change the power supply to that?