I am integrating gyroscope values to get orientation data, but I have a few problems with my code.
When I move my IMU and make like 100 degrees, the IMU can detect the movement somewhat accurately. When I turn it back to its first place, it doesn't read 0. It reads something around 40 degrees which means a huge 40 degrees of error.
I'm not really sure of the reason for this problem. My best guess is my sampling of the IMU being too slow. In my code I also use an RF module and an SD card module which makes my code really slow. My code runs at a speed of 5 times a second (my MCU runs at 154MHz.) That is too slow for fast movements, I think.
Summary of the question is:
Is this error happening because of the slow sampling rate, or is it caused bysomething else? If it's because of slow sampling rate, how can I solve this problem and get 10s of datas from my IMU?