Running a DC motor(6.5A max input), motor driver (MD10C 7Amp peak output), and Arduino Mega. I am stabilizing an object with an accelerometer as my sensor. I switched to longer wires so I can have my board next to me and the stabilized object far away. Now I believe there are timing issues because of this. How would I fix this? How would i test to see how long it takes to travel through my wires?

I can add my code if that helps.

enter image description here

  • 1
    1. The extra 2 m of wires will delay the signals by about 10 ns. 2. A schematic of your setup might help. – Edgar Bonet Oct 13 '20 at 18:00
  • @EdgarBonet I have edited my original post with wiring setup – Thunder Dornhofer Oct 13 '20 at 18:35
  • 2
    I2C over long wires is bad. Very bad. You mustn't do it. Not without an I2C repeater / extender. – Majenko Oct 13 '20 at 18:57
  • @EdgarBonet is the repeater/extender a physical thing or something in the code – Thunder Dornhofer Oct 13 '20 at 19:15
  • 1
    @ThunderDornhofer I'm Majenko not EdgarBonet :P and it's a physical thing. I think Maxim do some. – Majenko Oct 13 '20 at 19:16

The pins of logic chips and processors are not line drivers and will not operate properly when used as such. Sometimes you may get lucky but that generally would be intermittent in operation. They make drivers to drive wires off board from the controller and other chips that are receivers on the other end. This needs to be done with each digital line. There are some specialty drivers such as I2C repeater chips, RS485 etc. Remember the wires are antennas and the system is operating at a high enough frequency to be a great radio transmitter. The main thing is to isolate the controller wires from the world.


A better solution would be to get a Pololu Wixel and companion shield for your Mega, and then put the Mega near the object. You can then program the Mega wirelessly and completely avoid problems with long signal lines. See this post for how I used it on one of my wall-following robots. You'll need two Wixels and one Wixel shield. They aren't particularly cheap, but you won't regret getting them.

There are other options for wireless control and programming, using Bluetooth rather than a proprietary protocol, but they aren't as easy to implement as the Wixel method.

  • I ended up putting everything close and then using a relay attached to my switch which is on a smaller signal wire. Runs great now. I think what I am doing is basically the wired version of what you were saying above. I like your idea better than what I am doing though, I am going to look into that and try to implement it, thank you! – Thunder Dornhofer Oct 15 '20 at 20:13
  • Would one wixel be on my computer and the other on the wixel shield which is on my mega? and is communicates through the two wixels? – Thunder Dornhofer Oct 15 '20 at 20:25
  • 1
    yes, exactly. The two wixels form a 'wireless serial bridge' so the two ends (your PC and the Mega) don't know they aren't wired together with the normal USB cable. Of course, this requires that the Mega have a separate power supply, as it will no longer have +5 & GND available via the USB cable – user3765883 Oct 16 '20 at 11:03

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.