We were testing autonomous over the weekend and noticed that the KOP gyro was generating constantly larger and larger values.
We tried the other KOP gyro with the same result. We had been using the same code the past two years and other than class is now AnalogGyro
instead of Gyro. The code is basically calibrate, reset and get angle:
All electronic gyros drift over time. The question is how much is acceptable. When you say it is constantly generating larger and larger numbers, how much larger and over what time period?
Is this just a drift, or does it indicate that the robot is whirling like a dervish? We’ve had several old KoP gyros fail in a mode where they constantly had an output of either 0V or 5V (I don’t recall which). While the gyro is powered but not spinning, check the voltage between the 0V and signal output of the gyro. It should be approximately 2.5V. If it is in this range, you may just need to recalibrate. If it is closer to 0V or 5V, you probably have a short or a component failure.
Also ensure the gyro/robot is perfectly still while the code is going through the calibration routine. An analog gyro cal routine typically samples the output voltage for a short time and assigns the average value to zero rotation, during an initialization process. If the sensor is actually rotating (any movement at all could have a rotational component), the routine will map the zero-rate value incorrectly … then, when you ARE actually still (no rotation), the gyro will report a non-zero rotation rate, and you will accumulate rotational displacement (constant larger and larger values).
As Chris said, all analog rate gyros have some residual drift. One reason for this is the cal process can never be perfect, and any error in rate will be amplified as the rate is integrated over time to accumulate rotational displacement.
Small growth in displacement can be considered ‘drift’, maybe something much less than 1 degree per second, depending on the quality of the gyro. Growth much larger than this likely represents a failed or mis-wired sensor, or a bad calibration.
Understand that these MEMS KoP gyros are Rate Gyros, in that what they fundamentally sense is a rate of rotation (in units like degrees/second or radians/second). The signal is then integrated to get to displacement (in units like degrees or radians). This distinction is important as there is often confusion about ‘zeroing’ the gyro. Zeroing the rate, accomplished during the cal process, is different than zeroing the displacement, which you might do under some code condition. You can’t zero the displacement to fix error in the zero of the rate.
Be sure you’re using the correct gyro. There was no gyro in the KOP at kickoff. Every team got an ADXRS_450 gyro from FIRST Choice. If you are using that gyro, but calling AnalogGyro, all you’ll be integrating is noise. If you’re using the gyro from previous years KOP, then AnalogGyro is the correct class.
I also agree that you need to quantify the rate of the drift.