Shop OBEX P1 Docs P2 Docs Learn Events
Was the gyro the wrong choice for this application? — Parallax Forums

Was the gyro the wrong choice for this application?

Thomas FletcherThomas Fletcher Posts: 91
edited 2010-05-09 13:03 in Accessories
I think I purchased the wrong thing for what I want to do.

I want to make a camera stabilizer that keeps the platform the camera is on horizontal reducing the effects of roll and pitch.

I thought each axis would be similar to a balancing bot so I got a LISY300 Gyroscope module thinking it gave tilt info only to find it gives rate of turn.

I am not understanding the values it is returning at all. Stationary it gives 505, the number then goes up/down randomly seemingly no matter
which way I turn it. I would think it would go down one direction, up the other?

I am totally confused on what information it is giving me.

Comments

  • Thomas FletcherThomas Fletcher Posts: 91
    edited 2010-05-08 16:21
    ARGH!!!!! Rereading the product info it says :

    the LISY300 Gyroscope Module can detect how many degrees it has turned on its planar axis

    How do I get that value?!?!?!?

    This is the code I am using that was on the product page, I modified it to print the measurement value to the serial terminal.

    CON                                                     ' Propeller Setup
      _CLKMODE = XTAL1 + PLL16X
      _XINFREQ = 5_000_000
     
    CON                                                     ' Gyro I/O Pins
      DOUT = 0 
      SCLK = 1
      nCS = 2
    
    
    
    VAR                                                     ' Gyro    
      long Center
      long Deg               
    
    OBJ                                                     
      DEBUG  : "Parallax Serial Terminal"  
        
    
    PUB MAIN
        dira[noparse][[/noparse]2..1]~~
        Measure
        Calibrate
        DEBUG.start(250000)
        DEBUG.clear
        repeat
           DEBUG.Position(20,20)  
           DEBUG.str(string("Gyro angle: "))
           DEBUG.clearend
           DEBUG.dec(measure)
    
    
    
    
     
      Measure
      Calibrate
    
     
    
    PUB Calibrate | Value, Sigma, Minimum, Maximum, Average
    
      result~
      Sigma~                                       
      Minimum := Maximum := Measure
      repeat 50
        Sigma += Value := Measure                           ' Sum Voltage Readings
        Minimum <#= Value                                   ' Find Minimum Voltage 
        Maximum #>= Value                                   ' Find Maximum Voltage
      Average := Sigma / 50                                 ' Find Average of Samples
      Center := Average
    
    
    PUB Measure ' Clock data in for 13 bits.  (First three are zero, next ten are data.)
    
      result~
      outa[noparse][[/noparse]nCS]~    
      repeat 13
        outa[noparse][[/noparse]SCLK]~
        outa[noparse][[/noparse]SCLK]~~
        result := result << 1 | ina[noparse][[/noparse]DOUT]
      outa[noparse][[/noparse]nCS]~~
    
    
  • Thomas FletcherThomas Fletcher Posts: 91
    edited 2010-05-08 16:41
    Nevermind. Missed an important part of the code.

    Deg := Deg + (Center - Measure) / 2
  • Thomas FletcherThomas Fletcher Posts: 91
    edited 2010-05-08 17:43
    Well Smile. That is just incrementing the reading fluctuations. This is really really confusing.
  • Thomas FletcherThomas Fletcher Posts: 91
    edited 2010-05-08 21:16
    Well, I am getting there. after some reading I am now concerned with drift but I hope to try it when I get a servo. I am hoping to soak up about 30 degrees in each direction
    of roll using a servo to control the platform. This is what I got so far.

    'servo.init
        dira[noparse][[/noparse]2..1]~~
        Measure
        Calibrate
        DEBUG.start(250000)
        DEBUG.clear
        repeat
           DEBUG.Position(20,18)  
           DEBUG.str(string("Gyro Center: "))
           DEBUG.clearend
           DEBUG.dec(center)
    
           DEBUG.Position(20,19)  
           DEBUG.str(string("Gyro measure: "))
           DEBUG.clearend
           av := avermeasure
           if av > 508 or av < 504
              Deg := Deg + (Center - Measure) / 2
           DEBUG.dec(deg)
                  
           DEBUG.Position(20,20)  
           DEBUG.str(string("Gyro angle: "))
           DEBUG.clearend
           degree := deg / 39
          if degree > 30
              degree := 30
          if degree < -30
              degree := -30
          DEBUG.dec(degree)
    
           DEBUG.Position(20,21)  
           DEBUG.str(string("Servo angle: "))
           DEBUG.clearend
          if degree > 0  
              servopos := 110 + (degree * 4)
          else
              servopos := 110 - (||degree * 4)
         DEBUG.dec(servopos)
    
  • wjsteelewjsteele Posts: 697
    edited 2010-05-09 13:03
    In order to eliminate the drift, you'll need to integrate it with an external source for correction information. An accelerometer coupled to the gyro through a Kahlman filter will do the trick. There is an object in the obex for just that.

    Bill
Sign In or Register to comment.