L3GD20H gyro calibration

I’m having difficulty calibrating the gyroscope.
Using the serial code file, the sensor outputs a stream of raw data, which confirms that the gyroscope is functioning properly.
However, after starting the calibration, the readings became inaccurate. For example, when I rotated approximately 90° around the positive X-axis, the output showed only about 60°. I’ve applied a low-pass filter (LPF), but I’m not sure if it’s implemented correctly.
it wasnt showing zero while standing still

W
Serial.ino (936 Bytes)
calibration2.ino (2.5 KB)

I’m having difficulty calibrating the gyroscope.

That is not the problem. Accurate numerical integration requires appropriately sized small time steps. This line is likely a problem:

  delay(100);  // faster loop makes the LPF effective

The gyro rates should probably be integrated at 100 Hz or higher, instead of 10 Hz. Experiment!

Also, if you are not using an Arduino with Serial.print running at native USB speed, using this glacial baud rate is a problem:

  Serial.begin(9600);

Here is an example of gyro-only 3D orientation estimation using the Mahony filter. It is for the MPU-6050, but could easily be adapted to the L3GD20H.

Hint: integration is a low pass filter!

1 Like

I should add that the angles you get from this calculation are not Euler angles (by any of the several definitions), and in the case of rotation about more than one axis, you will have difficulty interpreting them. Rotation operations about multiple axes are not independent of each other, in the sense that the order of applying the rotations matters a great deal.

  // 4) Integrate filtered rates to angles
  angleX += filtX * dt;
  angleY += filtY * dt;
  angleZ += filtZ * dt;

This is why the generally accepted and most widely used method of rate gyro integration is to update the quaternion, from which any desired set of 3D orientation angles can be derived.

2 Likes

3 posts were split to a new topic: Magneto