Errorplayer
Posts: 10
Joined: Wed Sep 27, 2017 10:49 am

MPU 6050 Gyrosensor

Wed Sep 27, 2017 11:08 am

Hi everyone

This is my first attempt to sensor programming, so please describe everything from basics.

I am not sure that my data from the mpu6050 is correct. Could you please write what data you get if you do read the register 0x43 when the gyro is in rest.

Secondly i want to know if It ist possible and how to read a single Bit of a register.?

Thirdly: to calculate the Angle i sum Up All Data in degrees per second( scaled) (so integrating) but my Drift ist enormous. Its about 1.5 DEG per second. What can I do?

Thanks a lot for your answers.

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: MPU 6050 Gyrosensor

Wed Sep 27, 2017 9:27 pm

Ok as your about to discover get accurate direction is very complex thing to do.

First your reading the gyro sensor out put without and calibration for temp. The temp of the chip will greatly change the calibration. The chip has an on board temp sensor and an on board MCU that will process the gyro sensor output and scale/calibrate it according to the temp sensor reading then put the result value in the FIFO register for reading.

Hopefully u understand how a FIFO (first in first out)register works. It basically works like a line of data, when new data is a available it doesn't write over the top of the last data but rather puts it on the end of the line. When you read data from the FIFO it reads the beginning of the line then moves everything up 1 position. If when new data becomes available and the 512bytes FIFO is full then the sensor just throws away the data because it doesn't have any room for it. So you need read the FIFO at the rate it is filling up if you don't want to loose data, also if you have read data from the FIFO in awhile then it will over flow and new data is being thrown away and all the data in theb FIFO is old data so if you want new data you need to flush out the FIFO (read all the data in the FIFO and discard) so new data can be written to the FIFO

If you want to read just 1 bit from a register then you need to read the whole 8 bits and use the bit wise operator & to pick off just the bit you want.

Errorplayer
Posts: 10
Joined: Wed Sep 27, 2017 10:49 am

Re: MPU 6050 Gyrosensor

Thu Sep 28, 2017 5:40 am

Thanks a lot.
But how can i activate the MCU Processing? And in which Register will the Data be?

Could someone please send his unscaled data from the register 0x43 and 0x44?
It seems incorrect. Even if I scale my data the drift does not change. (About 1.5 deg per second^2

Thanks

User avatar
OutoftheBOTS
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: MPU 6050 Gyrosensor

Thu Sep 28, 2017 7:53 pm

I am away atm so hard for me to find all the info but a quick google for the register map I found the FIFO enable control register is decimal register 35 and the data for the FIFO is read from decimal register 116.

search this forum for a discussion that I had earlier for subject "MPU9250" which is the replacement for the MPU6050 but all the registers r the same and it works the same but it also has a compass built in as well. In this discussion someone posted a link to their code they r using for a RPi contoled drone and it has really good MPU6050/MPU9250 python code :)

Errorplayer
Posts: 10
Joined: Wed Sep 27, 2017 10:49 am

Re: MPU 6050 Gyrosensor

Fri Sep 29, 2017 4:51 am

Thanks a lot

User avatar
Hove
Posts: 1205
Joined: Sun Oct 21, 2012 6:55 pm
Location: Cotswolds, UK
Contact: Website

Re: MPU 6050 Gyrosensor

Fri Sep 29, 2017 7:13 am

OutoftheBOTS wrote:
Thu Sep 28, 2017 7:53 pm
search this forum for a discussion that I had earlier for subject "MPU9250" which is the replacement for the MPU6050 but all the registers r the same and it works the same but it also has a compass built in as well. In this discussion someone posted a link to their code they r using for a RPi contoled drone and it has really good MPU6050/MPU9250 python code :)
Probably mine. Have a look at https://github.com/PiStuffing/Quadcopte ... dcopter.py - the top two classes cover I2C and MPU6050 / MPU9250. Only difference is 6050 can't use the compass code. I've used this code on both. There is specific gyro calibration prior to each flight of the piDrone as part of its takeoff preparation on the ground where gyro should be 0 in all 3 axes. Look for setGyroOffsets and the call to it just under the "Thunderbirds are go!" comment :-) All data uses the FIFO, so that's there too.
www.pistuffing.co.uk - Raspberry Pi and other stuffing!

Return to “Automation, sensing and robotics”