Yaw Rate Sensor.. Questions

I haven’t found any documentation about how to use this censor in C this year. I wonder are we allowed to use them… and if so does anyone know where I could find some information on how to use it?

Our team is working with a jointed arm, and I was thinking of using the sensor to keep track of what angle exactly each section of the arm is, so I can determine how exactly the device at the end is pointing.

If this doesn’t work… I could track the movement of the arm when I output to the two motors that power it? Any thoughts would be appreciated, thanks.

If you’re referring to the gyro from years past, it is not legal to use this year.

From the Q&A on FIRST’s site:

Q: Are we allowed to use gyros that were given by F.I.R.S.T. last year?
A: This issue has been reviewed. The answer is now NO, you cannot use gyros that were in prior year’s kits.

Try a 100K pot as an analog input to track position.

You can get the Analog Devices ADXRS150 or 300 from one of the approved suppliers. I actually got the evaluation board from Analog ($50) and it is super easy to use: Apply +5v and you get rate, voltage reference and temperature outputs (I just use the rate). http://www.analog.com Click on “mems” and then “gyro” and then look for the samples order form.

the 150 is good to 150-200 deg/sec max and the 300 is double that. With some additional external components, you can quadruple the range. Contrast that with the FIRST supplied yaw sensor with only 75 deg/sec range. The low range was our limiting factor, last year, in how fast we could spin around and still accurately hit the center of the ramp.

Anyway, all I use the yaw sensor for is to keep track of heading. I integrate (i.e. figure out the rate offset, and add the results to an accumulator each cycle) Then the output of the accumulator is multiplied by some factor to get heading in degrees. When the robot enters autonomous mode I reset the accumulator and use that heading to control angles, etc. until I get to my target. Offsets from the desired heading are fed into the motor control to straighten the robot out.

In normal user mode, I just use the raw yaw output, again scaled by some suitable factor, to dampen robot motion. I.e. add to the left drive, subtract from the right drive. This “fights” turning when you don’t want it.

Cheers!

Just for your enjoyment I attached the sensor code for our robot (as of today…) It includes a nifty quadrature decoder routine and my own ADC stuff (I tossed all the IFI code…) as well as the Gyro routine. Note: I run the gyro routine at 100hz.

Sensor.zip (3.12 KB)


Sensor.zip (3.12 KB)

Larry , thats awesome. Only thing I would add is you can accumulate the sensor output in a 16 bit register, I usually start it out at 32000 so you can kept track of having turned left or right

and there really is no need to multiply the heading accumulator by a constant to get degrees - I think multiplying takes a lot of instruciton cycles (not sure) and dividing really takes a lot.

Last year we did almost the same as you described, except we figured out what the accumulator value would be in its ‘native’ units - for example, if 32000 is 0° heading then maybe 43500 would be right 90°.

you can do the same thing to determine the position of the arm as it rotates up and down - Ive used potentiometers on arms before - its very difficult to get a good mechanical coupling that doesnt destroy the pot.

This has been said a bunch of times already, but if you do decide to order that part from Analog you need to get the one with “EB” appended to the part number. You can only use the ADXRS150EB anyways because the 300 is more than $100.00 at FutureActive. The part number is ADXRS150EB. You can get a 20 pin socket at radio shack and have it working in about 5 minutes. Its a nice part, but will kill your budget if you’re using packaged encoders as well.

The accumulator for the heading can be a signed int initialized to 0. On each iteration of the ISR you add (current gyro - gyro bias) to the value. If you sample at 100Hz, the time between samples is 10ms. At max scale in the clockwise direction the gyro will output 150 degree/sec, converted to 512 by the ADC. Since it hasn’t been a full second, the output is really 1.5 degrees/sample. Since 512 = 1.5 degrees, 1 degree = 512/1.5 = 341. If you add up the value of (current gyro - gyro bias) on each loop, whenever the sum is greater than 341 you’ve moved 1 degree.

Each time through the ISR you want to keep the accumulator between -341 and 341. If you’re moving clockwise then each loop you’ll add one degree to the heading and subtract 341 from the accumulator until its less than 341. Only two subtractions or additions at the most per loop is needed because it can’t go faster than 1.5 degrees per sample. 341 is a constant that will need to be verified experimentally.

if you get the evaluation board, the device is already soldered to a small printed circuit card.

  1. Right, my code doesn’t initialize the yaw value correctly. Duh. Anyway, I reset the value when transitioning to autonomous so it sort of doesn’t matter.

  2. I like working in degrees. That allows for more than simply tagging when the robot has turned 90… I.e. I can trace paths. Because there is plenty of power available I maintain a floating point accumulator. It isn’t that much more expensive than calculating long values and scaling is brain dead simple.

  3. The budget is pretty reasonable: two encoders + gyro and you really don’t need anything else. The current IFI controller is powerful enough to do just about anything you want. Everything else is off-budget (banners, etc).

Things I do add: an RS232 buffer for the TTL serial port so I can have debug & download at the same time (the IFI terminal window is pretty wretched). I also add a quad opto-isolator. The LED side I connect across the main motor circuit breakers so if one pops, I can tell and then shut down the other side. That way the robot still goes straight, rather than slewing side-to-side as breaker do their thing. The goal is to avoid popping circuit breakers, but you never know.

We got ours in the mail from Analog today. The PCB actually comes on a 20 pin chip socket.

Thank goodness they increased the electronics budget to $300. We were looking at creative book-keeping methods to get our budget into the $200 and include all of our encoders, potentiometers, limit switches, and the yaw rate sensor as well.

On the ADXRS300EB, there is an interpretation question. The cost to buy one from future-active (the only available legal supplier) is $100.50. The cost to buy 2 is $90.45 each, and the cost to buy 5+ is $77.05 each. (incidentally, the cost to buy from analog devices is $50, but you cannot use this for book-keeping purposes.)

Which number are you supposed to use in the cost accounting? I’m pretty sure that FIRST has given some latitude, especially for raw materials. For instance, if you buy a 4’x8’ sheet of aluminum and only use 4’x4’, you can book-keep the price at the 4’x8’ rate (ie the 4’x4’ section is 50% of the cost of the 4’x8’ sheet).

So, an argument could be made that you can use $77.05 in your cost accounting for the ADXRS300EB and that therefore it is a legal part.

We’re using the ADXRS150EB, so I’m not concerned about this argument. However, if the ADXRS300EB were critical in your design, I would consider asking the question on the Q&A system.

w/regard to the sensors: check the data sheet. You can adjust the yaw scale by up to 4x (e.g. 150 deg/sec -> 600deg/sec) with a simple resistor network.