L3G4200D gyro integration
zwdavis
Posts: 8
I am trying to integrate data from the L3G4200D to get a degree measurement for each axis. I've read through the data sheet several times and can't figure out what the values output by the chip mean or how to translate them into deg/s measurements. I am using the code from the kickstart manual to read the values from the gyro and am able to see them through the parallax serial terminal. I also cannot figure out why my accumulators are not changing at all. I realize my current integration scheme isn't precisely what I need but I do not understand why the values are not changing at all. Any help anyone can give would be greatly appreciated!
Here is the code I am using thus far.
integratedgyroexample.zip
Thanks,
Zach
Here is the code I am using thus far.
integratedgyroexample.zip
Thanks,
Zach
Comments
Now, on to the theory. The L3G4200D has four possible measurement scales, and each scale has the associated milli-degress per second / digit. From Table 4:
So, if you are running at a scale of +-2000dps, then 1 unit from the gyro indicates 0.070 degrees per second (70 milli degrees per second). A reading of 425 from the sensor would indicate 0.070 * 425 = 29.75 degrees per second.
Integration is the sum of a function over time, so integrating a gyro is really easy: simply add up all the reading for a particular axis. In theory, you'll have your heading. To see why this doesn't work in practice, run it for a little bit with the gyro sitting on your desk without moving.
I'd like to comment some on the theory of operation that you posted.
This isn't correct. A degree per second measurement (such as from a gyro) does have time associated with it: hence the "second". In fact, it is velocity in a circular space.
While this may sound good, it has a major flaw: you don't know what the initial reading is. You could guess the first time, if you don't really care. But, as it says later in the comments, every time you "reset" the accumulator then you have to guess again. This makes the whole estimation a guess, except possibly for the very short term.
To figure out why your accumulator isn't changing at all, I'd make a demo program that launches a new cog that just increments the accumulator. If that changes the reading, then you've eliminated half the problem space and can narrow the rest down, binary search style.
and if possible could you re-post your amended code, I am using picbasic pro and converting the code but so far I have not had the proper results when using pic18f46k20