+ Reply to Thread
Results 1 to 12 of 12

Thread: Gyro - lisy300

  1. #1

    Default Gyro - LISY300

    This topic comes up from time to time, and if you've ever gone down the road of reading a Gyro or Accelerometer, you know the difficulties in determining a reliable position.

    Here is a method that I have used that works well. Keep in mind however A Gyro by-itself will have drift as would an Accelerometer. To get the most accuracy, it would be ideal to combine the efforts of different types of sensors.

    Tilt Orientation is also critical for a Gyro... Take this for example: If you orient a Gyro such that the rotational axis is horizontal and rotate it vertically (Perpendicular to the axis) you would expect Zero amount of influence and this would normally be true. However it's nearly impossible to rotate it exactly perpendicular to the axis, thus there would be a slight amount of 'drift' in the rotational reading. The opposite is true if you don't rotate the Gyro exactly on the intended rotational axis, you can also have a slight 'drift'.


    Code:
      Theory of Operation:
    
      There are a few things that need to happen to the RAW data in order to
      determine a relative Deg value.  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.
    
      We need to integrate time into the equation in order to get a valid Deg
      value.  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.
        
      An initial reading of the accumulator is used as a Reference to 'normalize'
      the remainder of the data.   This isn't the best approach, but it will work
      for this demonstration.    It's basically a single value that represents
      several data samples and could be looked at as though it were an average
      although we aren't dividing it over a number of samples like you would
      with an average.  Ideally this value would be dynamic and track over
      time instead of an initial reading up front.
    
      So, the remaining values from the accumulator are subtracted from the
      Reference value, and added to a Rotation accumulator.
    
      The number of Samples taken within the fixed amount of time can be
      calculated (or even directly counted) by dividing the initial accumulator
      value by 512 (<- the mid position of the 10-Bit ADC representing Vdd/2)
    
      In the program Example the 'fixed time' is 1/50th of a second and the
      calculations are basically as follows... Hope it helps.

    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	GYRO.JPG‎
Views:	2023
Size:	93.8 KB
ID:	76295  
    Attached Files Attached Files

    email - Beau Schwabe || BS Circuit Designs

    web - www.BScircuitdesigns.com
    IC's * Inductive proximity sensors * Misc * and more!!

    Do YOU need custom programming? PIC micro? Basic Stamp? Propeller? A custom PCB design? ... Then send me an e-mail lets talk, I have +20 years experience.



    Asked about the ramifications of his discoveries, Hertz replied, "Nothing, I guess." Hertz also stated, "I do not think that the wireless waves I have discovered will have any practical application."

  2. #2

    Default Re: Gyro - LISY300

    Thanks for posting this Beau. I think it might explain why I was having issues getting my balance bot working (using a H48C and LISY300 turned on it's side). I had to put that project on hold for a bit, but when I get back to it I will try using this to help me sort it out.

  3. #3

    Default Re: Gyro - LISY300

    Beau,

    This looks like exactly what I have been trying to do! However I am using a Stamp 2. Will this method work on the Stamp 2 and how can I read the spin files to try and understand what's going on?

  4. #4

    Default Re: Gyro - LISY300

    crazyarch93,

    With the Propeller it is easy because you have multiple threads and can keep a good timing loop. With a BS2 it's a little more difficult, but not impossible. To do so you need to implement some sort of accurate external time base ... Something as simple as a CD4020B with a 1MHz crystal would give you 61.035 Hz ... If that's still too fast another 4020 or 4040 stage divider should get you there. The critical point here is that you know exactly what the time base is.


    Since the Gyro reports in Deg/sec you are basically solving for Deg by eliminating or canceling out the time mathematically.

    Here is a basic Flow-Chart of what you could do with a BS2... Keep in mind during the periods that you are determining the Degree, in other words NOT in the timing loop reading the Gyro, you are losing accuracy.

    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	GYRO.JPG‎
Views:	1953
Size:	50.7 KB
ID:	76363  
    Last edited by Beau Schwabe (Parallax); 12-15-2010 at 06:04 AM.

    email - Beau Schwabe || BS Circuit Designs

    web - www.BScircuitdesigns.com
    IC's * Inductive proximity sensors * Misc * and more!!

    Do YOU need custom programming? PIC micro? Basic Stamp? Propeller? A custom PCB design? ... Then send me an e-mail lets talk, I have +20 years experience.



    Asked about the ramifications of his discoveries, Hertz replied, "Nothing, I guess." Hertz also stated, "I do not think that the wireless waves I have discovered will have any practical application."

  5. #5

    Default Re: Gyro - LISY300

    Beau,

    I'm sure there is a fundamental detail that I just don't get. The data sheet for the module describes full scale rotation detection up to 88 Hz. If it updates 88 times a second why would you need to take samples any faster than that? Does "up to 88 Hz" mean that the updates occur at different rates?

  6. #6

    Default Re: Gyro - lisy300

    agfa,

    Sampling at a higher rate has to do more with the Nyquist sampling rate and increasing your overall signal to noise ratio. This is true for any kind of sensor, not just a Gyro.

    The 88Hz is only from the Gyro itself and is useful for determining what rate it should be sampled at. The ADC that is connected to the Gyro can be read at up to 4MHz.

    Nyquist dictates that you should at least read the sample twice as fast as the data rate ... 176 times per second ... to obtain a signal to noise ratio of 1

    The second part of this is noise. The ADC will generate plenty of noise from external influences such as temperature, RF, etc. One way to help reduce random noise and increase your signal to noise ratio is to sample above the Nyquist.

    For example if you sample at four times the data rate from the Gyro (352 times per second), you increase your signal to noise ratio by a factor of two!!! ... How?

    If you sum four samples, you get a value four times larger. If you sum the noise from four samples, the result is only two times larger. That's because the noise is sometimes positive, sometimes negative, at random. When you add random positive and negative numbers together, they have a way of canceling each other out.

    Thus, when you sum four samples, the 'signal' grows four times, but the 'noise' grows only two times. In this case, the signal/noise ratio increases by a factor of two.

    email - Beau Schwabe || BS Circuit Designs

    web - www.BScircuitdesigns.com
    IC's * Inductive proximity sensors * Misc * and more!!

    Do YOU need custom programming? PIC micro? Basic Stamp? Propeller? A custom PCB design? ... Then send me an e-mail lets talk, I have +20 years experience.



    Asked about the ramifications of his discoveries, Hertz replied, "Nothing, I guess." Hertz also stated, "I do not think that the wireless waves I have discovered will have any practical application."

  7. #7

    Default Re: Gyro - lisy300

    Thanks Beau. I do appreciate you taking the time to give such a thorough explanation.

    agfa

  8. #8

    Default Re: Gyro - lisy300

    Hi Beau,

    Many thanks for posting this method of angle determination.

    I must apologize, but I don't understand the theoretical reasoning regarding some of the algorithm aspects such as why an initial number of readings are used in "normalizing" subsequent data whereby these readings aren't averaged which intuitively seems the logical thing to do. Is there a name for this method where I can do further reading on it?

    Also, how would the results of this method compare to the standard approximation method of taking many gyro readings whereby each reading is multiplied by the time difference in order to obtain an integration value (or using a more precise method of integration)?

    In advance, thank you!

  9. #9

    Default Re: Gyro - lisy300

    robotics,

    "why an initial number of readings are used in "normalizing" subsequent data whereby these readings aren't averaged which intuitively seems the logical thing to do." - In a sense they are average integrated with time and treated as a whole sum rather than divided by the number of samples. Dividing introduces truncation errors.

    By 'normalizing' , the data is subtracted from an initial reading ... this basically just biases the Gyro delta to Zero before it gets added to the accumulator.

    "Also, how would the results of this method compare to the standard approximation method of taking many gyro readings whereby each reading is multiplied by the time difference in order to obtain an integration value" - The result should be the same. Multiplying individual readings by the time difference should have the same answer as multiplying a sum of several readings by the time difference and dividing by the number of data samples.

    The difference in the algorithm that I am using, is that the division by the number of samples to obtain an average happens 'outside' of the timing loop. This eliminates any truncation errors that may have a compounding effect when calculating an average within a critical timing loop.

    What I am doing is really no different than the standard approximation method.

    email - Beau Schwabe || BS Circuit Designs

    web - www.BScircuitdesigns.com
    IC's * Inductive proximity sensors * Misc * and more!!

    Do YOU need custom programming? PIC micro? Basic Stamp? Propeller? A custom PCB design? ... Then send me an e-mail lets talk, I have +20 years experience.



    Asked about the ramifications of his discoveries, Hertz replied, "Nothing, I guess." Hertz also stated, "I do not think that the wireless waves I have discovered will have any practical application."

  10. #10

    Default Re: Gyro - lisy300

    Has anybody adapted this time integration method using the 3-axis Gyroscope Module L3G4200D?

  11. #11

    Default Re: Gyro - lisy300

    BonanazaMan,

    I'm working on this on the side between projects. The L3G4200D reports its data slightly differently, so I'm adapting Beau's algorithm appropriately.
    Daniel Harris
    Application Engineer, Parallax Inc
    (916) 632-4664 x 3003
    dharris@parallax.com
    http://www.parallax.com

  12. #12

    Default Re: Gyro - lisy300

    Quote Originally Posted by Daniel Harris View Post
    BonanazaMan,

    I'm working on this on the side between projects. The L3G4200D reports its data slightly differently, so I'm adapting Beau's algorithm appropriately.
    Daniel,

    Did you ever successfully adapt this algorithm for the L3G4200D?

+ Reply to Thread

Similar Threads

  1. Reading LISY300 Gyro with a Stamp 2 Microcontroller
    By crazyarch93 in forum Sensors
    Replies: 2
    Last Post: 02-20-2011, 08:17 PM
  2. Question on sample code for LISY300 Gyro
    By crazyarch93 in forum Sensors
    Replies: 1
    Last Post: 12-09-2010, 06:16 PM
  3. Lisy300
    By Pichuqy_1 in forum BASIC Stamp
    Replies: 0
    Last Post: 08-11-2010, 04:16 PM
  4. Parallax LISY300 Gyro module
    By Siri in forum Propeller 1 Multicore Microcontroller
    Replies: 1
    Last Post: 05-30-2010, 11:14 PM
  5. Replies: 0
    Last Post: 03-25-2010, 03:35 AM

Bookmarks

Posting Permissions

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