# Rotated gyroscope 180 degrees but integration shows 90

I'm a student new to sensors. I'm currently calibrating the gyroscope from the following IMU: ICM42670. I was able to get the bias by leaving the gyro for some time and getting the average of the errors. I am attempting to get the scale factor by rotating the gyro to a known angle (180 degrees) and seeing the offset but I'm having trouble integrating the data.

I configured the gyroscope to have a range of +-250dps and sensitivity of 131 LSB/(dps). The gyro also has an output data rate of 50Hz and a low pass filter at 53Hz (I can change this in case that this is the problem). These are my steps for integrating:

1. get raw data from the gyro with a sampling rate of 50Hz as well (0.02s apart). I rotated the gyro 180 degrees and back
2. I loaded the data onto Matlab
3. converted it to deg/sec by dividing by the sensitivity.
4. Applied previous found bias (which was almost 0)
5. Used the cumtrapz() function to integrate

This is that code snippet:

dT = 1/50;
rate_raw = importdata("esp\gyro_calibration\gyro_integration_data.txt");
rate = (rate_raw / 131) + y_bias; % convert to deg/sec and add bias

angle = cumtrapz(rate*dT);
t = linspace(0,10,length(angle));

figure(2)
plot(t, angle, 'LineWidth',1);
grid on
title("Gyroscope angle output");


The output is at exactly around 90 degrees which is half and I've spent a whole day trying to understand why. Any help is greatly appreciated!

• Adding on to my question. Is it possible that the scaling factor is around 2? Just thinking about it, I'm doing this to find the scale factor for calibration so there isn't a reason why it can't be that. I just find it extremely big... Commented May 28, 2023 at 5:25
• Are you absolutely sure that you have configured the GYRO_UI_FS_SEL bits the way you want them? Have you tried changing this setting to see what happens to the data? Commented May 28, 2023 at 11:47

• Do know that simply using cumsum(data) * dt_sec should be plenty accurate from validation you are doing.