1. ## L3G4200D gyro integration

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

2. ## Re: L3G4200D gyro integration

First off, you won't get a meaningful measurement by integrating a gyro: they drift too much. There are lots of similar inquiries on the internet if you do a search.

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:
Code:
```FS = 250 dps     8.75  mdps/digit
FS = 500 dps     17.50
FS = 2000 dps     70```
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.
Code:
```As it is, the RAW data has a value
associated to it of Deg/sec but there is no real weight or meaning to
that value if you don't integrate time with the reading.  It's just an
arbitrary unit of measurement without time associated to it.```
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.

Code:
```The easy way to do this is to clear an accumulator, take as many
RAW readings as you can in a fixed or known amount of time and add those
...```
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.
Code:
```PUB Test(accumulator_address)
repeat