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!