Classroom Resource: Eliminating Gyro Sensor Drift

Note: The technical discussion below pertains to the older version of the Gyro sensors (N2 or N3 codes).  If you have (or suspect you may have) the newer Gyro sensor (N4 and above codes) you will want to refer to the "Advanced Gyro Sensor Techniques" lesson in the Advanced Sensor Use unit.

The EV3 User Guide provides this warning about using the Gyro Sensor: "Note: The sensor must be completely motionless while being plugged into the EV3 Brick. If the Gyro Sensor is attached to a robot, the robot should be held motionless in its starting position as the Gyro Sensor is plugged into the EV3 Brick." This is required when using Port View or On Brick Programming.  If using using the EV3-G software, alternatively rather than unplugging the gyro to cure your drift problem, try changing the gyro block mode from angle to rate or angle & rate while the robot is stationary.  It takes a second or two to reset and zero out any offset but seems to cure the drift problem if the robot is immobile during the mode change.  Also, to reduce errors make sure your gyro sensor is oriented absolutely perpendicular to the plane of rotation to reduce or eliminate any cross-axis sensitivity.

Technical Background

Looking through the EV3 firmware and hardware documentation it seems the EV3 gyro sensor uses a Z-axis integrated dual-mass, vibratory MEMS rate gyroscope which was designed for high performance game controllers and audio-video remote controllers which require wide dynamic range motion processing, high impact shock resistance, and low cost. It features a primary output with a full-scale range of ±2,000°/sec to track the widest range of physical motions, as required by fast-motion gaming; and a secondary output with a full-scale range of ±440°/sec, for tracking slower motions, such as required in pointing applications.   The fast primary output (±2,000°/sec) is not supported in EV3 View and Datalog apps, but seems to be implemented somewhat in the firmware but not with the EV3 gyro block which supports only three of the five modes implemented in the firmware. The slower secondary output (±440°/sec) is fully supported by EV3-G, View and Datalog apps. The Z-axis gyroscope is controlled by a small 8-bit microcontroller which does all the Analog-to-Digital conversion of both the fast primary 2000°/s channel and the slower secondary 440°/s rate channels and the temperature compensation.  It also provides all the I²C communications and the EV3 sensor auto-ID functions with the host EV3 brick.

Gyroscope Features:

• Two separate outputs per axis for high-speed gaming applications and lower-speed menu navigation: 2000°/s full scale range (high-speed gaming) 440°/s full scale range (pointing)

• Low bias drift over temperature

• On-chip temperature sensor

• Temperature sensor Integrated amplifiers & low-pass filters 

• Dual-mass, vibratory MEMS gyroscope offers superior vibration rejection over a wide frequency range. The dual-mass design inherently rejects any signal caused by linear acceleration.

• 10,000 g shock tolerance The Rate-Out of the gyro is not ratiometric to the supply voltage. The scale factor is calibrated at the chip foundry and is nominally independent of supply voltage.  Overall it is a decent quality gyro and well implemented in hardware.  I haven't dug in to the source code yet, but believe that by changing the mode of the Gyro Sensor Block enables firmware code to reduce or zero out any DC offset caused by bias drift.