Shop OBEX P1 Docs P2 Docs Learn Events
L3g4200d — Parallax Forums

L3g4200d

ratronicratronic Posts: 1,451
edited 2012-04-27 16:37 in Accessories
Since a couple of people have asked about this gyro I thought I'd post a modified version of the example given on the product page. This version will show the angular rate output and the integrated readings of the rate output (~attitude) of all axis. The only modifications I made were to add a 1 second delay to the beggining of the Calibrate method to ensure the gyro is still when powered up. I also added a 10ms delay to the main loop to mainly improve display speed and as a bonus better match to the update rate of the gyro. Remember this program shows a close approximation of the real rate output. This is also in the OBEX under sensors since I didn't see one there.

Comments

  • MaxBoxMaxBox Posts: 1
    edited 2012-04-09 05:30
    Hi ratronic
    I Need Help For Gyroscope Module L3G4200D With Arduino Uno
    it is working now in Serial Monitor , but how i can read the X Y Z degree to control The Servo in my project , i searched over the net & no guide.
    so please help me

    Thanks
  • ratronicratronic Posts: 1,451
    edited 2012-04-09 08:44
    MaxBox I haven't used an Arduino so I can't help you out with code for it. The Propeller code I posted above is a very simple program, it only gives the angular rate output and an integrated reading of the rate output which is a +/- # of it's
    approximate current position from the starting point in the rotation about that axis. Here is some psuedo code of what I did to Parallax's program above.
    Initialize Gyro
    
    Do
    
    Rate = Axis reading
    
    Intg_Rate += Rate
    
    Display  Rate , Intg_Rate
    
    Delay (gyro update rate)
    
    Loop
    
  • ratronicratronic Posts: 1,451
    edited 2012-04-15 08:46
    After MaxBox asked how to control a servo with this module for an Arduino, I am posting one way to do it with a Propeller using a modified version of the Parallax demo that is written for the PropBoe using it's P19 servo connection, the vga, P26, and P27 led indicators. The P26 and P27 leds both light when it is at 0 position (starting point) or one or the other will light indicating which way from the starting point it is off.

    Also the vga led indicators act as a bar graph starting at about the middle led for the starting positition and then moving to the next led for approximately every degree of movement from the module in the Z axis. (+4/-3 approximate degrees from 0 on leds)
    At the same time the servo will start out at the middle position and move along with the module in the Z axis. The serial display has been modified to show approximate +/- degrees from the starting point and the rate output of each axis.

    This is just a simple demo, everything is very approximate and I wouldn't use this to guide a rocket ship!
  • TtailspinTtailspin Posts: 1,326
    edited 2012-04-25 13:10
    Thanks ratronic, I finally got to play with the L3G4200D I purchased at the UPEW.

    Your code works a treat! It is fairly simple, and was easy to implement on a Proto board.
    And very entertaining too... It's a crowd pleaser. :thumb::thumb:


    -Tommy
  • ratronicratronic Posts: 1,451
    edited 2012-04-26 13:26
    Thanks Tommy, I should point out that the above code does not use the gyro to stabilize anything only to demonstrate it's output.
  • TymkrsTymkrs Posts: 539
    edited 2012-04-26 15:39
    ratronic wrote: »
    After MaxBox asked how to control a servo with this module for an Arduino, I am posting one way to do it with a Propeller using a modified version of the Parallax demo that is written for the PropBoe using it's P19 servo connection, the vga, P26, and P27 led indicators. The P26 and P27 leds both light when it is at 0 position (starting point) or one or the other will light indicating which way from the starting point it is off.

    Also the vga led indicators act as a bar graph starting at about the middle led for the starting positition and then moving to the next led for approximately every degree of movement from the module in the Z axis. (+4/-3 approximate degrees from 0 on leds)
    At the same time the servo will start out at the middle position and move along with the module in the Z axis. The serial display has been modified to show approximate +/- degrees from the starting point and the rate output of each axis.

    This is just a simple demo, everything is very approximate and I wouldn't use this to guide a rocket ship!

    Super thanks! I'm just now figuring out how to play with the gyroscope module and this example worked perfectly!
  • ratronicratronic Posts: 1,451
    edited 2012-04-27 16:37
    Thanks Tymkrs, just to let everybody know the way I came up with approximate degrees from center is to run the program in post#1, after it is started then manually rotate the module 360 degrees in a axis then note the integrated amount for that axis and divide it by 360 to use here -
    PUB RawXYZ | dx, dy, dz, tz, tz1 
                                                                                   
                                                                                                                    
      dx := ix / 38                                         'divide integrated axis amount for approximate degrees  
      dy := iy / 38                          '                                                                      
      dz := iz / 38                          '
    

    You may find a number other than 38 that is more accurate for each axis.
Sign In or Register to comment.