Hi,
I tried to understand this:
q_m= ((float)average)*(1500.0/1024.0)*PI/180 ; // HAC remove 1.5 mult
and got a little confused, which even increased when I met this (another source of getting gyro output ratio metric):
conversion = 5.0 / 1024.0 * 1000 / 15 / 57.29578;
gyro = analogRead(gyroPin);
gyro = (gyro - 512.0) * conversion;
Then I decided to rewrite it step by step:
conversion = 5.0 * (1/1024.0) * 1000 *(1/15) * (1/57.29578)
Next, I added the dimensions, OMITTING 1000 ADDING m (milli-), getting dimension for (1/15) from the data sheet of gyro, under "Sensitivity":
conversion = 5.0 [v] * (1/1024.0) [1/LSB] * (1/15) [1/mV/deg/s] *(1/57.29578) [1/deg/rad]
Written easier:
conversion = 5.0 [v] * (1/1024.0) [1/LSB] * (1/15) [1/mV] [deg/s] * (1/57.29578) [rad/deg]
Reordering:
conversion = 5.0*(1/1024.0)*(1/15)*(1/57.29578)[1/LSB][v][1/mv][deg/s][rad/deg]
Canceling dimensions:
conversion = 5.0 * (1/1024.0) * (1/15) * (1/57.29578) [1/LSB][1/m][rad/s]
Canceling [1/LSB] and [1/m]:
ADC output: x [LSB], where LSB stands for Least Significant Bit,
Use a multiplier of (1000/1000) for canceling [1/m] as m = 10^(-3), so:
y = x [LSB] * conversion
That is:
y = x [LSB] * 5.0 * (1/1024.0) * (1/15) * (1/57.29578) * (1000/1000) [1/LSB][1/m][rad/s]
FINALLY:
y = x * 5.0 * (1/1024.0) * (1/15) * (1/57.29578) * 1000 [rad/s]
Now y is [rad/s] and ready to integrate to compute the angle, say:
angle [rad] = angle [rad] + y [rad/s] * dt
-----------------------------------------------
radian-degree conversion:
360 [deg] = 2 * PI [rad]
1 = 180/PI [deg/rad]
1 = 57.29578 [deg/rad]
-----------------------------------------------
I hope that this helps a novice like me to fully understand the dimension canceling hided. My IMU is the same as what used for this nice balancing robot of the post.
~~http://www.sparkfun.com/commerce/product_info.php?products_id=9249~~
-----------------------------------------------