View Full Version : Gyro Sensors
How would you program a gyro and a yaw sensor? Also what specifically does a gyro and a yaw sensor return? Finally how do you install this? Thanks
~Fred
KenWittlief
21-02-2004, 19:45
the gyro actually is a yaw rate sensor - it tells you how fast the bot is turning on one axis (usually you point the axis up so you can tell how fast your bot is turning on the playfield as it steers).
there has been a lot of discussion and explainations - try the search function up in the orange bar - and search on gyro or yaw - you will probabally find what you need to know faster than I can type it out.
Astronouth7303
21-02-2004, 19:51
How would you program a gyro and a yaw sensor? Also what specifically does a gyro and a yaw sensor return? Finally how do you install this? Thanks
I'm looking at last year's. It's BEI GyroChip Micromachined Angular Rate Sensor. I'm basing this on the spec sheet, I haven't used it, so confirmation would be nice! :yikes:
You would add the output to a variable ("Compass") once a second, like:
Compass = (char)(Compass + (int)(rc_ana_in01 - 127))
Like I said, once a second (Or what ever is convienient, I'd use a interupt if you know how).
Hopefully that gets you started, good luck!
Jeff McCune
21-02-2004, 19:57
Here's a cool trick for the gyro sensors:
have your code print out a debug value, one per line, of the gyro sensor, and an increasing value before it. So you get this:
1,127
2,127
3,127
etc...
Use hyperterm or some other terminal program with a large scrollback buffer, attach a long cable, and drive your robot up a ramp or some object you want to climb while capturing the output. Copy and paste the entire thing into a text file with csv at the end, so foobar.csv or what not. Open the file in excel and graph it. It's great for finding thresholds and understanding what the gyro is trying to tell you at various points along the way.
KenWittlief
22-02-2004, 07:46
once a second would not be fast enough - the gyros have a bandwidth of 40 Hz - which means it can change values 40 times a second
so if you only read it once a second, you are only seeing 1 out of 40 possible outputs that it is creating each second.
If you want to integrate it to get compass heading, add the value to a integer variable in every pass (loop) of the SW - and make sure you subtract out the zero value (512 if you read it with a 10bit ADC - but you might need to see what the actual 'zero' value is by testing it on your bot).
Astronouth7303
22-02-2004, 20:13
I ment that the units given were mV/degree/second. So you would have to scale or use a finer unit. I don't actually know what happens if you use the straight rate faster than a second (or scaled to).
I think that if you divide by the number of times the interupt occurs per second, it will work. Again, I'd like a confirmation!
jacob_dilles
22-02-2004, 20:16
what type of algorithom would you use to determin your relitive postition from logged yaw rate data? is there something obious that im missing?
Astronouth7303
22-02-2004, 20:55
If you know your absolute heading and the heading relative to a beacon, you can figure your position. or be less dependent on the value and just use the compass for Red/Blue.
But if your not doing IR, you can use it for, say, Forward(600) TurnTo(3000) Forward(42).
KenWittlief
22-02-2004, 21:33
what type of algorithom would you use to determin your relitive postition from logged yaw rate data? is there something obious that im missing?
yes, the sensor output is degrees per second - so if you simply accumulate the sensor output, subtracting the zero point each time (512 for the 10 bit ADC) - then what you are doing is integrating the sensor (multiplying times time)
and you end up with degrees - compass heading.
you would have to calculate the correct constant to get your register into actual degrees, based on the scaling factor of your yaw rate sensor, and how many times a second you add it to the accumulator
or you can leave it in whatever units it comes out to be, and use it as a relative number - for example, if you initialize the accumulator to 32000 and turn right 90°, the accumulator might increase to 45,000 or 52,823 (whatever) - you just need to do some testing and see what the units come out to be - then you will know how many counts = 1°
Astronouth7303
22-02-2004, 21:36
You don't need it in degrees; just use robot units!
KenWittlief
22-02-2004, 21:46
°K (degrees Ken) :)
Robb Gerber
22-02-2004, 22:59
hope you're not planning on using it this year -
Yaw/Gyro from last year is not allowed - read the Q&A
we played with the idea of using it before the kick off but had to shelve the idea
KenWittlief
22-02-2004, 23:07
you can get gyro sensors from the catalogs - analog devices make great ones that you can get on tiny little exal boards - all you need to do is attach +5V, gnd and the signal wire.
search on 'yaw' or 'gyro' and you will find the threads with the parts listed.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.