Problems with an IMU5DOF (IDG500 and ADXL335)

Hey all,

I'm currently a student at GaTech doing my Senior Design project. We're using an Atmega328 and an IMU5DOF from sparkfun to attempt to determine the lean of a motorcycle and actuate the headlight to "see" into the turn. The problem is, we're all Mechanical Engineers and are feeling out of our league on the electronics portion of the project.

The basic code we're currently using to convert the analog sensor readings into g's and deg/s is below (just showing the line for z-axis acceleration and x-axis angular velocity):

float zG = ((zAccel * arduino_power_supply / 1024) - vR) / .270; float xR = ((xRate * arduino_power_supply / 1024) - vR)/.0091;

where zAccel and xRate are the analog readings, arduino_power_supply = 5, vR is the measured and properly converted reference voltage and .270 and .0091 are the respective sensitivities for each sensor in mV/g and mV/deg/s.

Using a multimeter, I confirmed that the supply voltage is indeed 5V, and the sensor supply voltage is ~2.7V, confirming that the measured and converted vR value of 1.37V is correct. Unfortunately, the output from the accelerometer for x, y and z while the device is still is 1.18, 1.09 and 2.44 g's. Is this just some offset I have to account for or am I missing something?

Thanks for any input!

Assuming these are ratiometric devices, the zero points for each axis (0g or 0 degrees per second) will be half the supply voltage.

Have you tried printing the raw readings and making sense of those?

Just write a basic sketch that reads the accelerometers and prints the value.

[edit]

the sensor supply voltage is ~2.7V, confirming that the measured and converted vR value of 1.37V is correct

Hold on - if the supply is 2.7V, then 0g is at 1.35V, but if your reference vloatage is only 1.37V, how are you converting positive accelerations of more then a few tens of mg?[/edit]

You do have to subtract out the 0g offset voltage which will be around 1.35V.

Also, the C expression:

float zG = ((zAccel * arduino_power_supply / 1024) - vR) / .270

suffers from potential truncation if zAccel and arduino_power_supply are integer types since division by 1024 will not be floating-point division then. Either declare arduino_power_supply as a float number or just cast it explicitly:

float zG = (((float)zAccel * arduino_power_supply / 1024) - vR) / .270

http://www.ruggedcircuits.com