2021-06-11 09:04 AM
I am using the bluepill board and was trying to compute the angle from gyroscope raw data. However, when I tilt the sensor, the angle measured doesn't change as expected. It's changing between 1.xx and 2.xx regardless of the tilt angle. The sensor is being read every 4ms (I have configured the timer to interrupt at every 4ms). I have attached my code here, can anyone please help to to figure out what is the problem? Thanks!
Update: I try to remove the offset but the reading is still inaccurate. When the row angle is 45 degrees, it shows around 20 degrees; when the row angle is 30, it shows around 13 degrees. Both the angle calculated seems to be around 2.3 times less than the actual angle.
2021-06-14 03:10 AM
OK. Will try to change that during free time. Thanks for your help. =)
2021-06-16 06:38 AM
The printing problem is solved but right now the drift in the gyroscope reading is extremely severe. I have already take 100 samples of the gyroscope reading prior to actual measurement and take the average of them. This offset is then subtracted from the raw data during actual measurement. The variable used to store the accumulated offset is a int32_t variable, so it's definitely large enough to store the value. What could be the problem?