Erratic Mega Output when connected to USB cable

I have an unusual problem using a Mega with a Sabertooth motor driver. The motor driver runs a couple of DC brushed motors. Everything works fine until I plug in a USB cable to the Mega, whether or not the other end of the cable is plugged into a PC or not. Then the motor driver, which normally has a smooth output, has a sequence of short, jerky outputs. I'm using a protoshield with a 12v input and a LM7805 5v. regulator to power the mega and a couple of sensors. Putting a large capacitor across the 7805 output doesn't help.

Any ideas of what's causing the problem and suggested solutions?

Thanks,
John-

Post a diagram of the connections / code using the code tags.

I've had this issue before too

The problem is that your USB cable is acting as an antenna and picking up interference from your motors.
Large capacitors are useless in these situations as they only work at low frequencies and do nothing to remove high frequency interference from a motor. For this you need to use low value, like 0.1uF ceramic capacitors with very short leads.
These are needed across the motors as close to the motor power input as possible, as well as the power supply regulators input and output in parallel with the large capacitors you should have there.

If your motor only goes in one direction then you must have a reverse diode across it. If it can reverse then the driver must use four diodes to ensure there is always a reverse diode.

Also the layout of your wiring is very important and you should follow star wiring configuration, where all the grounds meet at one point. Keep all signal wires away from the motor and its wiring.

Thanks. I suspected something like this and I'll try out your suggestions. Normally I do put capacitors across the motor terminals. A little difficult with these 350 W motors running a 100 lb robot. The power leads are heavy duty, insulated wires that carry 45 amps in skid turns and I don't want to bare any insulation. I'll first try putting the capacitors on the motor driver output. BTW, the problem also occurs when the robot is sitting on a stand with the 24v, PbSO4 battery charger connected.
I also understand about ground loops; I'll see if there's any improvement I can make.

John-

It would have been good to mention your project was dealing with those sorts of currents to start with.

I feel you need some good solid industrial power supply decoupling solution like using pi filters with large inductors.

Can you link to your motor drivers.

I apologize for not more completely describing my problem. I'd be glad to send you
a lot more information, if you want to be burdened by it.

I'm using a Sabertooth 2*60 motor driver.

https://www.dimensionengineering.com/products/sabertooth2x60

The issue with erratic operation when connected to the battery charger is not important, I thought it might be diagnostic.

John-

And you never said this USB lead was a battery charger.

These are important things and are a total game changer with regard to what solutions you might pursue.

It's not, that's a separate issue.

  1. USB plugged into Mega - erratic operation
  2. Battery charger attached to battery terminals - erratic operation.
    This is not important, because the robot is not moving, only on
    a test stand and tests can be made without the charger attached.

I'm on my way to the lab where the robot is; I'll send a picture.

John-

OK then have it your own way.

Good luck with the rest of the project.

Whoa, you misunderstood, is that why you call yourself Grumpy_Mike?
I was trying to disintangle confusion I caused by implying that a USB
cable was used for the battery charger. I value your input.

John-

Hi,
What system are you using to comm with the Sabretooth, if it is serial, what port are you using?

If it is the Serial port rather than Serial1 or 2, the Mega is programmed through Serial, so connecting the USB will put data on that Serial and corrupt the Sabretooth data stream.

A complete schematic will be preferable as we can then see if you have bypass caps etc.
Use a pen(cil) and paper, it can be quicker, please label components and pin name.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Then why are you

  1. ignoring it
  2. reluctant to change anything

I talked about star wiring and you said

Star wiring has nothing to do with ground loops. It has to do with noticing where the heavy currents flow and isolating those heavy currents from the light signal currents to avoid ground bounce. For example in that schematic you have the power ground first going to the mega and then on to the motor driver. That is exactly the situation you need to avoid.

Why? Because I misunderstood. In the past, whenever I encountered the term star wiring, the stated purpose was to avoid ground loops. I had never heard of ground bounce ( just looked it up) and that certainly would cause the effect I'm seeing.
More later when I attempt a more complete schematic.

Thanks Tom and Mike,
John-

Some additional info

It will take me a while to make a good wiring diagram. Although the diagram I posted shows the electronic and power grounds as one continuous path, actually, the negative terminal of the battery goes separately to the Sabertooth ground and to the electronic supply ground.
Taking Mike's advice, I did put 0.1 uf capacitors across the Sabertooth outputs to each of the motors and that corrected the problem. However, I then discovered something more bizarre. When the laptop AND the battery chargers are both plugged in, with the mains side in the same outlet, the motors are violently erratic.

Well don't?
Make a USB cable for your Arduino that has the 5V wire cut in it, so you do not try and feed PC current into a project that is already 5V powered.
5V is not exactly 5V, some 4.9V others 5.1V some 5.0V, the differences in two supplies connected together can cause problems.

Tom... :smiley: :+1::coffee: :australia:
PS, this is my 5V isolation cable, only the 5V wire is cut and bought out to terminals, that way you can still use it as a powered cable and/or fit an ammeter to measure currnet.

Tom,

It's not the USB cable giving me trouble anymore, since I put the capacitors across the Sabertooth outputs.
It's when the PC is plugged into its charger at the same time as the Robot is plugged into its charger. Sorry I need
more time to send out more complete messages.

Thanks,
John-

Hi,
Are they sharing the same outlet?

What happens if you have one of the chargers in another room on another outlet?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Tom,

TomGeorge Jackson
November 9

Hi,
Are they sharing the same outlet?

Yes.

What happens if you have one of the chargers in another room on another outlet?

I'll check it out tomorrow. Sounds weird, what is your suspicion?

John-