Need help to troubleshoot connection between motor controller and MPU6050

Hi, I use a MPU6050 (those GY521 from Amazon) on a robot car with 2 DC motors to control the direction of robot movement. I use Pololu motor controller (dual VNH5019) on Arduino UNO. The MPU6050 is connected to A4/A5 pins and VCC/GND on the board. Most of time it runs fine (i.e., can go straight under PID, or turn to a desired degree). However, occasionally it goes very randomly completely losing control. I have checked all wiring and soldering, they all seem fine. It looks like the communication with MPU6050 with the board just got lost randomly. I also have similar issue on another pololu board TB9051FTG.

When I use the same MPU6050 on a cheaper controller LN298, it doesn’t have this problem. But it is an out-of-dated controller with a lot of voltage drop. So I prefer to get this working on the pololu boards.

I really need help to guide me on how to troubleshoot and fix this issue. As I read from internet, people talk about all kinds of possibilities (e.g., floating pins, noises, unstable voltage, timing/clock issues etc.) I am not sure what is the real problem in my situation.

Thanks in Advance.

It seems strange that the problem does not seem to occur when using the LN298, but if it only happens occasionally, it might be something more situational (like an overflow or some kind of bug in your code) and not actually related to the motor driver at all.

Is this something you have verified (e.g. by looking at the readings) or just a guess based on your observation? If you have not done so already, I recommend adding some debugging to your code to try to determine what is actually happening. Printing out the readings from your IMU and looking at what happens with them when the problem occurs is probably a good starting point.

Additionally, could you post some pictures of your setup that show all of your connections?

Brandon

Thanks for your response. This is a photo of the wiring.
The 4 vertical wires (taped together with blue tape) on top left connected to the MPU6050. The blue and white wires are VCC and GND connected to the pins on the board (near the battery side). From there I also used the 3.3V for the motor encoder and wired another VCC to breadboard where I can connect to other sensors. For troubleshooting purposes I removed other sensors but still have the same problem.

I was just guessing because it happens randomly at different spots and times so I couldn’t easily reproduce the problem.

I still recommend adding some debugging to your code like I mentioned in my previous post so you can try to get a better idea of what is actually going on.

It is hard to follow all of your connections, but it looks like some of them are going through multiple jumper wires chained in series; in general that is probably okay, but given that you’re having problems and it just adds another mode of failure I generally recommend simplifying your system as much as possible and making those connections are direct as you can. If you continue having problems and want to post some pictures of the underside of the motor driver boards, I would by happy to try to inspect your soldering.

By the way, the Arduino Uno uses 5V logic signals, so you should probably switch to powering your encoders with 5V instead of 3V if that is safe for them.

Brandon