Gyro Calibration

Does anyone have any ideas for calibrating a gyro. Your ideas would be really useful. I don’t quite understand the calibration instructions in the readme file for this years Gyro Code.

Using Kevin’s instructions, you need to make some changes to the
gyro.h. Specifically, you need to change /add /delete some
#define statements to select your gyro, sampling rate, and
number of samples. I have copied/pasted below part of the
gyro.h file that has worked for me for the BEI GyroChip AQRS-0075.
Note the four #define statements that have the // removed

#define GYROCHIP_75 // BEI GyroChip AQRS-00075-xxx
#define TENTHS_OF_A_DEGREE
#define GYRO_CAL_FACTOR 1000/1000
#define GYRO_SAMPLE_RATE_1600HZ

In order to calibrate, I download the program after compiling with
the settings for the BEI Gyrochip, make sure the gyro is steady
and let the Terminal display output about 5 times. I have read
the gyro angle to be about 0 degrees. Then I slowly turn the
gyro 180 degrees (about 6 seconds for the turn) and read the
gyro angle display. It should read about 1800, since the #define
is set to TENTHS_OF_A_DEGREE. Next, I return the gyro to
it’s original position (slowly) and it should read about 0 degrees.

If you turn it quickly, you will probably see that it won’t read
the 1800 and return to 0 degrees. Why?

// Pick your gyro by removing the // from one of the six lines below.

#define GYROCHIP_75 // BEI GyroChip AQRS-00075-xxx
// #define ADXRS300 // Analog Devices’ ADXRS300EB

// Pick the angular unit by removing the // from one of these two lines.
// #define MILLIRADIANS
#define TENTHS_OF_A_DEGREE

// For optimum performance, you’ll need to calibrate the scaling factor
// to match that of your gyro’s. One way to calibrate your gyro is to
// mount it very securely to a hefty, square or rectangular object.
// Mounting the gyro to a hefty object will help dampen higher frequency
// vibrations that can adversly effect your measurements. Place the
// mounted gyro against another square object and start the included
// demonstration software. To get good results, the mount must be
// absolutely still when the “Calibrating Gyro Bias…” message appears
// on the terminal screen. After a few seconds, the gyro angular rate
// and angle will be sent to the terminal screen. If the angle drifts
// rapidly while the mounted gyro is motonless, you need to restart the
// software to acquire a new gyro bias measurement. Again, gyros are
// very sensitive and must be still while the bias is calculated. Once
// the gyro is running with little drift, rotate the mount 180 degrees
// and note the reported angle. If the angular units are set to tenths
// of a degree, the ideal reported angle is 1800. If set to milliradians,
// the ideal angle 1s 3142 (Pi times a thousand). For every tenth of a
// percent that the angle is high, decrease the GYRO_CAL_FACTOR numerator
// by one. Conversly, for every tenth of a percent low, increase the
// numerator by one. Repeat until you’re satisfied with the accuracy.
#define GYRO_CAL_FACTOR 1000/1000

// Pick a gyro sample rate by uncommenting one of these lines. Faster
// is better, but your CPU will spend more time servicing interrupts.
// Pick the slowest sample rate that still meets your performace criteria.
// These #defines are used below to set the value of GYRO_SAMPLE_RATE and
// to set the timer 2 update rate in gyro.c/Initialize_Timer_2().
// #define GYRO_SAMPLE_RATE_200HZ
// #define GYRO_SAMPLE_RATE_400HZ
// #define GYRO_SAMPLE_RATE_800HZ
#define GYRO_SAMPLE_RATE_1600HZ

// Number of ADC samples that will be averaged for each gyro update. More
// is better, but your update rate will decrease proportionatly. This must
// be sixty-four or less. The gyro sample rate divided by number of samples
// per update should be at least equil to fifty, which is the number of
// gyro updates per second.
#define GYRO_SAMPLES_PER_UPDATE 64

// If you modify stuff below this line, you’ll break the software.

#define ADC_VOLTS_PER_BIT 5/1024
#define MILLIRADIANS_PER_DEGREE 349/20
#define TENTHS_OF_A_DEGREE_PER_DEGREE 10

#ifdef GYRO_SAMPLE_RATE_200HZ
#define GYRO_SAMPLE_RATE 200
#endif

#ifdef GYRO_SAMPLE_RATE_400HZ
#define GYRO_SAMPLE_RATE 400
#endif

#ifdef GYRO_SAMPLE_RATE_800HZ
#define GYRO_SAMPLE_RATE 800
#endif

#ifdef GYRO_SAMPLE_RATE_1600HZ
#define GYRO_SAMPLE_RATE 1600
#endif

// BEI GyroChip AQRS-00075-xxx (sensitivity = 30.0mV/deg/sec)
#ifdef GYROCHIP_75
#define GYRO_SENSITIVITY 33 // in units of deg/sec/volt
#endif

// Analog Devices’ ADXRS300 (sensitivity = 5.0mV/deg/sec)
#ifdef ADXRS300
#define GYRO_SENSITIVITY 200 // in units of deg/sec/volt
#endif

We are also having problems with our gyro caliberation. We are trying to use Mr. Watsons latest code with the the ADXRS150EB gyro chip. We have followed the instructions step by ste but, the rate of print of the gyro angle is really slow and takes a long time to print out the change in angle (like an hour for a 180 deg change). I have doublechecked my wiring of the gyro and the gyro is on a surface free from any possible vibrations. I have tried it out at 1600Hz with 64 as the sampling rate, with similar really slow results. Can anyone suggest why this is so?

thanks for all possible help.

Can you be more specific? Are you saying that the angle information being sent to the terminal screen isn’t being updated fast enough? Are use using the user_routines.c code I included in the .zip file?

-Kevin

I apologize, Ill try to explain better:

The print of the gyro angle increments at a very slow rate, for example when i start the program the gyro angle stays at 0 till i actually move the gyro(as expected), after I turn the gyro slowly to say 90 deg, the gyro angle starts to change, but at a very slow rate. It increases by 1 for every 5-6 print outs of the gyro angle, so if it has to reach 900 (90 deg with setting at tenths of a degree), it will take a long time to increment to that value. Isnt the gyro angle supposed change faster?

I am using the frc_gyro code version 0.4 from your website, without any changes other than gyro sample ratte at 1600Hz and samples per update at 64 (Ive tried other values to but with same results). I have not changed anything with user_routines.

Hope this makes it clearer,

Thanks.

Yes, it should change much faster than that. When you assembled the gyro, did you connect a jumper wire between the AVCC (pin 1) and PDD pins (pin 13)? If not, connect the two pins together and it should start working.

-Kevin

i’ve been having the same problem as thinkpad…
we have the ADXRS150 gyro from analog devices, and we HAVE connected those pins (1 and 13).
here are pictures

also, i’ve noticed that the (excuse my terminology, im a programmer, not an electronics person) little terminal-thingies labeled C1 through C7 do not match up with the picture on the spec sheets.

http://kevin.org/frc/adxrs150eb.pdf (spec sheet, thanks Kevin)

:confused: ~Stephanie

P1010069.JPG
P1010070.JPG


P1010069.JPG
P1010070.JPG

It’s hard to tell, but it looks like you’ve attached a tantalum capacitor to the rateout pin. If so, that would certainly explain why you’re seeing the rate change so slowly. Remove everything from pin two except the white wire and try it again.

-Kevin

ok that’s done… it still drifts, but now it drifts less.
(instead of every 4-7 times changing by 1, it happens every 15 or so…)

thanks, :confused:
~Stephanie

Hmmm… Now I’m confused. Is it drift you’re seeing or slow response? Drift is where the angle changes without rotation of the gyro. Slow response is where the angle changes too slowly after you rotate the gyro.

-Kevin

o alright sorry… its drift

when i posted that, we had just tried seeing if they all ( the analog value from Get_Analog_Value and the Get_Gyro_Angle ) stayed zero when we didn’t touch the gyro or anything. it ended up drifting 1 (tenth of degree? its not in milliradians any more, so i believe its tenths of a degree) every 15 loops or so.
however, now the drift is much worse and its 1 tenth of degree every 2 loops…

thanks…
~Stephanie :confused:

Nevermind - we got it. We found it in the famous 1000/1000 of code in gyro.h. We followed the instructions above that code and it worked out fine. Thanks.
Our gyro had the following calibration number:

GYRO_CAL_FACTOR 958/1000