3
\$\begingroup\$

I built a small Arduino "robot" on a tracked chassis. The device uses MPU-5060 for direction finding (on a prototype shield) and Adafruit MotorShield v2 to control two 320-type motors. The goal at the moment is to simply be able to turn in 90 degree increments.

All communications between the devices happen on I2C bus. The motors have their own power supply, and the logic boards have their own. The I2C uses 4.7K pull-up resistors for 5v voltage. I tried 400K and 100K frequency on I2C

I wrote a bunch of code using the I2Cdev library and AdaFruit's own library for controlling the motors.

The problem is, as long as motors' power supply is off or at least the the motors are not connected to it (using LEds instead of motors) all the code works correctly.

When I turn on the motors, in a few seconds the I2C bus freezes. Even if I reset the Arduino, the motors stay running and the initialization of the MPU fails (it involves pumpung ~2K across the I2C bus and verifying the data reading it back. The read-back does not match, which tells me that I2C is still unstable).

I tried putting 0.1 uF capacitors across the motors, it does not help. I tried running motors on their own w/o connecting them to the controller - that does not reproduce the issue, so I think this rules out the RF interference. I don't have an osciloscope, and I am no tsure how I would use it to diagnise this issue anyway.

Could someone suggest what would be a good next step? I donot know what else I can do...

Update: The puctures of the setup.

Overall: enter image description here

As you can see, there are three shields. The bottom is Arduino Uno equivalent, the middle is the AdaFruit Motor Shiield V2. The top is MPU 6050 with two 4.7K pull-up resistors.

Motor Shield: Motor Shield

MPU 6050:

enter image description here

The connections on th elogical boards are plain to see, an I will try to add some schematics later.

Update:

Thanks everyvbody for the responses and comments.

I decided to try these steps in the following order:

  1. Change the layout by flipping the Arduino around. This will get my motor wires to be maybe 1.5cm long and vertical, so the opportunity for the interference is minmized.
  2. Use shielded cable for the motor battery wires.
  3. Change the pull-up resistors to below 2K.

Will see if any of it helps.

Also, as promised, the schematics. The most important part is the motor shield:

Motor Shield

It does have its own 10K pull-up resistors.

Update:

Items 1 and 2 done, very little improvement.

Here is what the system looks like now:

enter image description here

Note that the wires fromthe motors are vertical and as short as I can make them.

The shielded cable for motor power is grounded at the battery end to the "-" terminal of the battery.

As an "extra", I added 2 more capacitors to each motor as described here in the "Three-capacitor filter" section.

Will try item 3 later.

\$\endgroup\$
14
  • 3
    \$\begingroup\$ Related question: electronics.stackexchange.com/questions/173085/… \$\endgroup\$ – ErikR May 30 at 21:40
  • 2
    \$\begingroup\$ Without any details, the usual suspects are: poor layout, lack of ground plane, insufficient decoupling. \$\endgroup\$ – winny May 30 at 21:57
  • 2
    \$\begingroup\$ and even more so: very insufficient power supply. \$\endgroup\$ – Marcus Müller May 30 at 22:01
  • 2
    \$\begingroup\$ @MarcusMüller During testing, the Arduino and the shields are supplied with USB. Can that be insufficient? \$\endgroup\$ – user132018 May 30 at 22:16
  • 2
    \$\begingroup\$ of course it can. \$\endgroup\$ – Marcus Müller May 30 at 22:18
5
\$\begingroup\$
  • Both Cables must be at least twisted pairs.

  • Motor cable ought to be shielded.

  • Ground current must not be shared on the same wire.

  • Motor cable must at right angles to I2C.

  • Lower pullup R to 1k if not already.

  • Show block diagram of all physical connections and earth ground.

  • add grounds if unsure, incl. earth gnd

  • Report all changes in question with cause/effects

\$\endgroup\$
2
\$\begingroup\$

The I2C uses 4.7K pull-up resistors for 5v voltage.

Lower that to 1.5kΩ or even less. It will give you much better noise immunity.

\$\endgroup\$
2
  • \$\begingroup\$ I am afraid to burn out the I2C cirquits in the ICs... Is it safe to push 3.3ma there? The spec says minimum 3ma, so that's the only guarantee I have... \$\endgroup\$ – user132018 May 31 at 1:00
  • \$\begingroup\$ 3mA sink current is typical for I²C. Expect no problems unless you double that. \$\endgroup\$ – Janka May 31 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.