Gyro Rate

Is it possible to get the gyro rate in EasyC? Do you just get the analog value, and if so, is that affected by or affect the 20 msec sampling taking place in the background?

Thanks.

You are correct, just poll the analog value. Keep in mind that the value you receive isn’t truly analog, but the result of the analog to digital conversion. It returns a 10 bit value. To use it you need to find the resting value after the gyro is turned on (wait a second). That is the gyro’s center. You also need to figure out the degrees/sec/bit for your gyro. As the value varies from resting value you can convert it to turn rate. So if you look at the spec sheet for your gyro, it will have a spec for mV/degree/sec. Take that along with the max turn rate (80, 150, 300, etc.) and the fact that the 10 bit value is proportional to 5v and you can figure out the turn rate. I’ll let you figure out the math…

good luck!

Regarding this topic I have a similar questions about the gyo

1.) If the gryo’s results give a 10 bit value would 1024 represent a 360 degree angle.

2.) Can I take the assumption that the gryoscope uses flat plane of x and y coordinates.

3.) When you start the robot is the value initialized at 0 or at some angle that it captures
a.) if you were to turn a robot backwards would the values be the opposite value (ie. 25 to -25)

easyC Pro has natve support for the ADXRS Series of Gyros. Look at the inputs menu and Gyro is on the list. The analog ports are not effected by the 26ms loop.

Ok I am bit confused with your comment, does that have anything to do with the questions I have above?

Aerex,
You cannot get the angle by reading the analog input only. The gyro outputs an analog value, approx 2.5v when not moving. It will read above 2.5v when rotating clockwise, below counterclockwise.

see page 4 of this data sheet:http://www.analog.com/UploadedFiles/Data_Sheets/ADXRS300.pdf

If you want the angle, you would need a routine to convert the rate output of the gyro (over time) to get the angle. This has already been done by EasyC/WPILib and Kevin: http://www.kevin.org/frc/

  1. No. See my comments above. 1024 (read from the analog input, not the gyro routine) would represent a rapid clockwise turn.
  2. Yes, I suppose so, if it is mounted parallel to the plane of x & y. I do not know the results if mounted on an angle.
  3. No. See documentation for Easy C/WPILib or Kevin’s routines.

The Gyro output of 0-1024 represents the ‘rate of turn’ and should return a value of approximately 512 when at rest.

I see, so as you mentioned from 0 - 511 would be counterclockwise and 513 - 1024 would be clockwise. But you also said that EasyC has already converted this analog to digital and returns the header, which is the angle correct. So what would the angle rest be when the analog output is 512. I appreciate the time for you to answer my questions.

I think we were confusing the topic by talking about the original post question about reading the analog input and gyro rate. Forget about that for now.

Assuming you want an angle, so you can turn x degrees, use the built in Easy C routines. Examples can be found in the help file, and in gyrotest.ecp, which is in the \frc\projects est code directory. After InitGyro(A) and StartGyro(A) (where A = analog input gyro is plugged into) GetGyroAngle(A) will return an integer which represents tenths of degrees (900=90 degrees clockwise, -900=90 degrees counterclockwise)

I apologize, I intial thought that the gryo’s analog input was in degress but I realize that that is not the case because EasyC convertes the voltage and intergrating the rate to a degree. Sry for the misunderstanding.

Anyway from what you said I am getting that initially the bot would read 0 degrees when starting and if the bot would turn completly 180 from the right it would positive and from the left negative (-180). I have a pic to what I mean

gryo.PNG


gryo.PNG

Yes, that should be correct. A few precauctions, when the gyro is initialized, the robot needs to be still/stable for a second. We found that pressing the reset button after the robot is in place helps to get more predictable results. We have also found it possible to turn faster that the gyro can keep up. A rapid turn will not register properly.

Ok thanks, so if I the bot were to be in autonomus mode I would have to slowing decrease one motor and slowly increase another motor for the gyro to read an angle (turn)

Depends how easy your robot rotates. You probably will not need to slowly increase the motors. Just set the PWMs for a moderate turning speed. (not 255 & 1!)