Hello, me and my friends are trying to build a self-balancing robot. To get the angle of the robot, we're using a MPU 6050 gyro. It's working in I2C, we have managed to plug it to the grove shield and it's working well. The Motor Driver is wired too in I2C, and is working well alone. Our 2 DC motors are powered with an external battery.
But when we connect the two I2C devices together, it stops working correctly for some reason. For instance, at the moment i plug the I2C Motor Driver into the Grove, the MPU 6050 debug values stop working.
I heard of pull-up resistors but idk if we need to add one.
Do you have any idea of what may cause the issue ?
Thank you for your quick answer ^^.
The card is an Arduino Uno card. If it can help, i'm running Windows 10 x64.
I don't think the code is involved but anyway:
I added in attachment the mpu 6050 wiring diagram. We couldn't find the Grove shield on fritzing so we used instead A4/A5 arduino pins for I2C communication.
The I2C motor driver is directly plugged to an I2C port of the Grove.
For instance, at the moment i plug the I2C Motor Driver into the Grove, the MPU 6050 debug values stop working.
An I2C bus is not hot pluggable! Never connect or disconnect devices while the system is powered! You may damage your chips.
My guess for your problem is the different voltage of the two devices. You connect the MPU directly to your Arduino which is running on 5V but the input pins should not get more than 3.6V according to the datasheet. As the Sparkfun board has onboard pull-ups to 3V3 you probably have around 3.8V on the bus lines without any data transmission. This is theoretically over the limit for the MPU but may just not damage the chip.
I guess you didn't remove jumper J4 on the motor shield. So when you connect the motor shield the 5V from the shield go through the cable to the Arduino. Depending on how you power your Arduino this may lead to a reset of the board and maybe other issues.
Try powering the system up after connecting all components and removing J4 on the motor shield. You should use a (bi-directional) level converter to connect the MPU to the Arduino.
the MPU is connected to the 3.3V output of the arduino.
Yes, Vcc but the Wire library activates the internal pull-ups to 5V on the Arduino. Together with the pull-ups on the MPU board you get the 3.8V I wrote in the last reply.
Removing the Jumper 4 doesn't seem to be enough We still can't get the i2c motor driver and the mpu to work together ... However, the motor shield is now powered only by the battery. Again, the code is working well for each module ...
We didn't try to add a bi-directionnal level converter to the MPU but we're running out of time
EDIT: the gyro is working now while the motor driver is plugged, but the motors aren't spinning ...
It might be something wrong with the code, but i can't understand what ...
We followed Pylon's advice and finally after removing the Jumper 4 on the I2C Motor Driver, unplugging everything, resetting the Arduino Uno and the I2C Motor driver to empty capacitors, and plugging back, the MPU 6050 and the I2C Motor Driver were no longer interfering each other. (Although resetting electronic cards may be useless)
OK, so now we have another problem ! (I don't know if the nightmare is going to end one day !)
We removed the Wire.setClock(400000); and the motors are triggered as it should be, but the only "little" problem we have is that is seems the program crashes at the first time motors are trigerred ... If I comment Motor.speed() or Motor.stop() it doesn't happen ...
Every time the program crashes we have to unplug the I2C Motor Driver and plug it back to restart the program.
That sounds like a power supply problem. Motors are rather big inductors so they pull quite some current at start and return it when they're switched off. What kind of motors do you use? Please provide a link to the product.
I doubt it is a power supply problem because motors keeps spinning after the "crash".
A video is worth many words: 5 Star HD Porn - Free Porn Tube & Sex Tube – HD Porn Videos & XXX Movies (make sure to watch in 480p). In this video you can see that the MPU debug values stop in the serial monitor a few seconds after the program launch.
EDIT: Someone said built-in resistors stack up, could it be the case ?
EDIT: Someone said built-in resistors stack up, could it be the case ?
What do you mean by this sentence? There should be no more than one built-in resistor for each pin.
I doubt it is a power supply problem because motors keeps spinning after the "crash".
That does only mean that the motor shield still has power but there still could be a negative spike in the power supply of the Arduino that let it crash. Please provide a diagram of how you wired the different batteries to the Arduino and the motor driver board as well as the motors. Could you also post a picture of the setup where all connections are visible (if that's possible)?
First i want to apologize for the long time without answer, we weren't able to advance our project or even manipulate it.
EDIT: Someone said built-in resistors stack up, could it be the case ?
What do you mean by this sentence? There should be no more than one built-in resistor for each pin.
An engineer told us that. I will try to quote him in English as good as I can, sorry for the misunderstanding.
It is probably a pull-up resistors problem. Generally, each equipment incorporates his own resistors. So it works well alone. But as soon as multiple elements are on the bus, resistors become in parallel. So it is recommanded to remove pull-up resistors on the modules, except one.
I put the power supply wiring diagram in attachment, as well as two pictures of our project. The I2C Motor Driver and the DC motors are currently powered by an external power supply (and the Arduino is powered by a computer). We tried too with batteries and it works the same, but for testing purposes the external power supply is more convenient. If you want, i can take a picture of how the external power supply is wired but I think it is ok. The power supply is set to 8V.
I would try to stabilize the I2C bus. Insert a level converter between the main I2C bus and the MPU6050. That way you can drive the motor driver with the standard 5V it expects and still match the voltage range of the MPU6050.
If you have a 12V power supply, try that to power the motor board.