MPU-6500 freezing over I2C

Hello,

Thanks in advance for everyone on this forum always being so helpful. This is the first time in years that I've had to post a question, because I've always found my answers easily after a quick search.

That being said, forgive my lack of experience and knowledge with electrical theory and circuits - I'm a long time tinkerer but by no means do I claim to understand how or why many of my projects work the way they do.

The current project I am working on consists of two Arduino Uno's, both with a CNC Shield "3.0" version designed by Protoneer. Although, mine are undoubtedly cheap Chinese clones.

One of the Uno's has four stepper motors attached on the shield, and the other has two. The project is essentially a self balancing robot, where I am using I2C to communicate between Arduinos. The main Uno moves the four wheels depending on the selected program, pauses, and sends a transmission to the second Uno when the move is completed. The second Uno then stabilizes a platform to offset any movement caused by the wheels moving over uneven terrain. Once the stabilization is complete, a transmission is sent back to the main Uno to indicate that it can make its next move.

This has worked without issues, using a BNO055 breakout board on the stabilized platform. My issue with the BNO055 is that its resolution was not quite good enough to consistently stabilize it at very precise sub-degree angles. I had tried setting the accelerometer to 2g range and not using the fusion mode - rather relying on raw accelerometer data. But this still wasn't quite as precise as I wanted.

After reading about the MPU-6050 and its apparent ease of use, accuracy, and very low cost - I figured I'd give it a try. I ordered a couple of the GY-521 breakout boards (when I refer to the 6050, I am referring to this breakout board).

After setting it up, and figuring out how to use low & high pass filters and a moving average function, I finally got the more precise angular measurements I was looking for. I hooked everything back up and modified the original software but it didn't work.

After some troubleshooting I discovered that the MPU-6050 was freezing when the 12v power was connected to the CNC shields. I have spent hours and hours reading similar forum posts, but have been unable to locate a solution that works for my setup.

[u]What hasn't worked:[/u]

  • The stepper motors are powered via a large 12v AGM battery, which is connected directly to the CNC shield. Both shields on both Uno's are wired in parallel. I have tried different 12v power sources with no change.

  • The Arduino's themselves are connected to USB ports wired to the same battery, but I've tried connections to a computer, a separate USB power supply, and even 9v using the barrel jack. This has not made a difference.

  • Grounds are connected between both Arduino's and CNC shields.

  • I have tried shortening the I2C wires, and moving them as far as possible from power wires, but this has not made a difference.

  • I have attempted decoupling using various sized capacitors on the power connection to the 6050, but no change.

  • I have tried using different scripts on both Arduino's and determined that it does not matter what program they run, or what wire library I use (Wire, i2cdevlib, I2C Master). I have even tried changing the FIFO rate in the library, but to no avail. I have the same issue whether I run the most basic MPU-6050 data reading script, or my much more complicated robotics program.

  • I tried removing the serial.print functionality of the scripts and used LED's to indicate status, and still no change.

  • I have also tried separating the two Arduino's and connecting only one with the MPU-6050. Initially the MPU-6050 remained connected for a couple seconds, rather than immediately cutting out, but it still cut out promptly after attaching the 12v power to the shield.

[u]What has worked, sorta:[/u]

After reading and reading about pull-up resisters on the I2C lines, I tried a few combinations. The best solution I have come up with so far is the following:

  • 10k resisters pulling both SCL and SDA up to 5v, AND removing connection to the second Arduino

I wasn't sure if 5v pull-ups on this breakout board would damage the 6050, but no issues yet. I have a backup just in case.

This setup has allowed the MPU-6050 to run without issues. Once I connect the second Arduino via the I2C lines however, it will cut out. Sometimes this happens immediately, and sometimes this happens 20 seconds later. As always, the issue is only when the 12v is connected to the shield. But, this seems to verify for me that it is a hardware issue, and it must be resolvable - I'm just halfway there.

I can't for the life of me figure out how to properly make the connections between both Arduinos and the MPU and not have the I2C freeze. I have tried multiple other combinations of pull-ups, using different values of resistors, different placement of the pull-ups, shortened wires, etc. No change. I even desoldered the 2.2k pull-ups on the MPU-6050 breakout board and this hasn't made any difference.

While messing with pull-ups, I tried using 750ohm resistors instead of 10k ohm. This seemed like it would be far too strong of a pull-up, but it actually allowed the MPU-6050 to run for 20-60 seconds on both Arduino's without issues. After a certain point though, the values in the serial monitor as usual begin to appear unstable, and the data cuts out. From what I read, these values of resistors don't seem like good choices for I2C pull-ups, but then again that's why I'm here asking the experts.

Hopefully you guys have some ideas!

Thanks!

So .... what happens if the stepper motors are left disconnected.... ie. the motors are removed from the system? Does the mpu6050 work when stepper motors are removed?

Same issue, as long as the 12v is still connected to the CNC shields - It makes no difference if the motors are disconnected.

Thanks

  • Jeff
  • 10k resisters pulling both SCL and SDA up to 5v,

Not a good idea. Pullups MUST go to 3.3V instead.

Okay thanks I corrected that and the pull-ups were moved to 3.3v - but no change in performance. I also switched to a new MPU-6050 in case the first one was damaged. Still no change.

Ok..... so what happens if you remove the MPU-6050 completely. Can the arduino's communicate with each other reliably (for long durations of time) via I2C communications (with 12V feeding the CNC shields)?

I tried an MPU9250 which works better than the 6050 but still freezes under the same conditions. Pullups (on 3.3v) don't seem to solve the issue, nor does high qualitiy shielded wire versus standard jumpers.

To answer your question, the system works fine without the 9250 or 6050. I am using the BNO055 using the same exact connections and configuration on i2c with absolutely zero issues.

Still no solution...