I am using mpu-6050 for my maze-solving robot. After some research online, I have found it is a common problem with mpu-6040 gyroscope to freeze in a couple of seconds. If it is lucky, the robot can at maximum work for 2minutes. However, I am not sure how to resolve this problem. I do not know what to change in my gyro code setup part to make it work.
From some googling, I found that if you make mpu-6050 work without the use of interrupts, you code can work without any crash/freezing problems. I do not know on to do that exactly.
Is it a common problem that the MPU-6050 freezes ? I have not heard of that before. If a servo motor introduces noise into the I2C bus, that can stop a sketch, but as far as know, the MPU-6050 never freezes.
What is your sketch ? The text that you have attached, "Gyro Setup.txt", what is that ?
Do you use the official and original ic2devlib, or just some code you found on the internet ?
Do you use a 5V Arduino board ? how did you connect that to a 3.3V MPU-6050 ?
Do you have long wires for SDA and SCL ?
Can noise and voltage drops by the motors have any influence on the Arduino or I2C bus ?
From what I saw online, I did see many peope having issues with the I2c sketch getting froze up or the program crashes midway while running.
The Gyro Setup.txt file is the mpu 6050 intialization stekch that I took from Jeff's library. In my robot, I am using mpu-6050 only for measuring angle of robot based on reference angle which does work until program crashes usually while displaying ypr.
I am using a 5V arduino board.
This is my pin configuration:
//VDD on Gyro chip connected to -> 3.3V pin on arduino
//GND -> GND
//INT -> digital pin 2
//SCL -> analog pin A5
//SDA -> analog pin A4
//VIO -> VDD on gyro(3.3V)
I am using DC motors; I am not sure; maybe the noise from the motors could be causing the issue. Or it might as well be the interrupt on gyro on pin 2.
SDA and SCL have short wires.
You can get rid of many noise problems by level shifting the SDA, SCL and INT signal.
Is your Arduino board a Arduino Mega 2560 ? Then you must use a level shifter.
Is the MPU-6050 module with voltage regulator ? then you better apply 5V to power input of the module. But if it doesn't have the voltage regulator, then 5V might destroy the MPU-6050.
Does the MPU-6050 module have pullup resistors ? which value ?
The SDA and SCL have short wires, only 10 cm or less ?
There could be ground currents from the motors that might introduce noise into the I2C bus.
There are many things that can go wrong with noise, ground currents, and current peaks, it will be hard to solve that via a online forum. Adding a few large capacitors for the different power voltages might also help.
Some have a 7805 voltage regulator without capacitors, then the 7805 can behave as an oscillator. There are many, many others things that increase the electrical noise.
Mega also has onboard pullup resistors. Can remove them by removing 8-pin part RN1.
You can determine which it is by using a multimeter and checking for continuity from the SCL SDA pins to the various resistor networks.
Then turn off internal pullups (in Wire.h?) and use external 3.3V pullups if needed.
Hello,
You can check the value for pull up resistors that should be connected on SDA and SCL lines if the sensor shield does not have an onboard pull up resistor.
Even after check all the connections your code is freezing, you can refer to a similar arduino code for MPU-6000 Ardunio MPU-6000.
You can add decoupling capacitors to separate power and reduce noise if you use MPU-6050 and also you can refer to this mini module MPU-6000 which can solve problem on noise. Arduino adapters are also there which you can use easily and are easily available.
Replying late as this came up and I found a solution - was getting mpu6050 lock ups bad whenever a motor shield was running a motor, a Seeed Studio 4A shield on a Uno - the solution that finally worked for me, after trying shielded wire, bypass caps, etc - was putting two 390uH inductors on the mpu6050 power leads right at the board. After that it would run just fine.
That's two 390uH - bigger might be better, that's just what I had in the junk box - plus a 0.1uF bypass, right on the MPU6050 pins cured the locking up from the PWM motor hash noise. It was a miracle cure.