+ Reply to Thread
Results 1 to 2 of 2

Thread: L3G4200D gyro integration

  1. #1

    Default 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.


  2. #2

    Default 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:
    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.
    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.

    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
      readings to the accumulator.
    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.
    PUB Test(accumulator_address)
          long[accumulator_address] ++

+ Reply to Thread

Similar Threads

  1. get data from l3g4200d with spi protocol
    By mohammadesmaili in forum Sensors
    Replies: 9
    Last Post: 05-24-2012, 01:20 PM
  2. Gyroscope L3G4200D
    By kaydara in forum Sensors
    Replies: 14
    Last Post: 05-08-2012, 01:35 AM
  3. L3g4200d
    By ratronic in forum Sensors
    Replies: 7
    Last Post: 04-27-2012, 11:37 PM
  4. L3G4200D Gyroscope
    By uosamor007 in forum Sensors
    Replies: 9
    Last Post: 03-17-2012, 09:37 PM
  5. Using a 3-axis Gyro (L3G4200D) To Rotate a Servo?
    By dannyv in forum General Discussion
    Replies: 7
    Last Post: 11-05-2011, 09:40 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts