ckkkkk
Posts: 11
Joined: Fri Apr 26, 2019 4:39 pm

How to find "dt" in the equation of converting raw gyro data into angle?

Fri May 10, 2019 12:26 pm

Recently, I just bought the MPU 6050 and been no problem playing around with it. Until, i ran into the problem which i do not understand how to determine the "dt" in the equation of converting raw gyro data into angle. So, any Masters here can help a little bit on this?
This is the equation
angle += gyroRate * dt

scotty101
Posts: 3597
Joined: Fri Jun 08, 2012 6:03 pm

Re: How to find "dt" in the equation of converting raw gyro data into angle?

Fri May 10, 2019 1:09 pm

dt is "delta time" meaning the change in time.

In this case it means how long has elapsed since the gyro reading was last taken. The value of this can either be calculated by recording the current time when you take a reading and comparing it to the last time or it can be a fixed value if your system reads the gyro consistently at 50Hz for example.

The gyro reads how far the unit has rotated as a measure of radians per second, this is the gyro rate. To calculate the angle you multiply the gyro rate by the amount of time elapsed (dt) and add the change in angle on to the last angle reading.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

ckkkkk
Posts: 11
Joined: Fri Apr 26, 2019 4:39 pm

Re: How to find "dt" in the equation of converting raw gyro data into angle?

Fri May 10, 2019 1:41 pm

In this case it means how long has elapsed since the gyro reading was last taken. The value of this can either be calculated by recording the current time when you take a reading and comparing it to the last time or it can be a fixed value if your system reads the gyro consistently at 50Hz for example.
Hi scotty101,
Can i know how can i make the system reads the gyro consistently? Is it just to make a loop and limit it to 100 times?

scotty101
Posts: 3597
Joined: Fri Jun 08, 2012 6:03 pm

Re: How to find "dt" in the equation of converting raw gyro data into angle?

Fri May 10, 2019 3:54 pm

Yep a loop will work. Could be an infinite loop or as your say you could just loop 100 times
(Or as many as you want)
If you put a small delay in the loop it will slow down how often the sensor is ready and increase dt.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

ckkkkk
Posts: 11
Joined: Fri Apr 26, 2019 4:39 pm

Re: How to find "dt" in the equation of converting raw gyro data into angle?

Sat May 11, 2019 3:34 am

Hi scotty101,
If i use the infinite loop then what would be the "dt"? If i used a 100 times loop the "dt" would then be the time used for the loop right, so a timer is needed?

Return to “General discussion”