Arduino w/ PWM expander and DC motor issue

Thread Starter

pidgin

Joined Oct 30, 2020
21
Separate power source doesn't help
Does the L298N get hot?
Not at all.
The motor is a very small motor. Doesn't take much current.
I will briefly post an update that makes the whole thing even more bizzare.. But maybe starts pointing to the real issue..
 

Thread Starter

pidgin

Joined Oct 30, 2020
21
OK! So.. update!.
I have updated the test code to use BOTH a PWM on the Arduino due, as well as on the PWM expander.
I've connected theL298N to use the Arduino Due PWM signal.
So now, the PWM expander module is not connected to any load or any driver. It just sits there generating equivalent PWM to the one on-board of the Arduino Due.

So.. IF the issue was that there is a signal going back from the driver (L298N or my circuit) back to the PWM expander, which causes the expander to hang, then now in the new setup there isn't such connection. Right?

So.. what happens?
The PWM expander module hangs anyway!
WHILE the on-board Arduino Due PWM port continues to function normally.

So.. I think VERY APPARENTLY, the issue is not at all with the fact that the driver or motor takes too much or too little from the PWM expander.
The issue seems to that the motor generates some interference that disrupts the PWM expander.

So what do you think?
Can it be maybe due to some effect the motor has on the power supply?
Or maybe
Can it be that this interference sips into the I2C bus and gets the PWM expander module go crazy?
Or
Do you have any other hypothesis?

I think we are getting closer to the root of the issue. No?
I hope so at least.
 

djsfantasi

Joined Apr 11, 2010
9,163
Does your latest circuit include a snubber? If the motor doesn’t have to reverse, a diode. Or an RC snubber... And does your power supplies include a filter capacitor?
 

Thread Starter

pidgin

Joined Oct 30, 2020
21
Does your latest circuit include a snubber? If the motor doesn’t have to reverse, a diode. Or an RC snubber... And does your power supplies include a filter capacitor?
DJ. I am not sure if the power supply has a filter capacitor, but I think so.
It is an S-360-12 : https://www.sunsky-online.com/view/...gulated Switching Power Supply 100~240V .htm

I did try a snubber. It had no effect. I am not using an 1N4007 diode.

Another update. Maybe we are getting to the bottom of the problem.. even if not to the solution yet.

I've removed the PWM expander altogether, and placed an I2C LCD display to show some info while the test goes on.
So now the L298 is only connected to the on-board PWM on the Arduino Due.

Very soon after as the motor is connected to the L298N the display either hangs, or starts showing garbage.

So, clearly, the motor creates an interference that disrupts the I2C bus.

I've tried placing the Arduino and LCD module on a separate power supply altogether (with common ground of course).
That did not help though.

What causes the interference? How does it get from the motor/L298N to the Arduino I2C bus?
And.. Any ideas how to resolve it?
 

KeithWalker

Joined Jul 10, 2017
3,098
I have found thet using the same supply for an arduino and motors or sevos usually causes the arduino to eventually hang. It will happen sooner if there is inadequate supply decoupling and no noise suppression across the motor. Try running the motor and arduino each from its own regulated 5V supply, with both commons connected together at the 12V supply source. I think it will help.
 

Thread Starter

pidgin

Joined Oct 30, 2020
21
I have found thet using the same supply for an arduino and motors or sevos usually causes the arduino to eventually hang. It will happen sooner if there is inadequate supply decoupling and no noise suppression across the motor. Try running the motor and arduino each from its own regulated 5V supply, with both commons connected together at the 12V supply source. I think it will help.
What about an optocoupler?
 

AlbertHall

Joined Jun 4, 2014
12,347
So, clearly, the motor creates an interference that disrupts the I2C bus.
In your layout, study where the motor current flows, especially the ground.
If any part of the ground of the arduino/LCD carries the motor current then that current can result in a noise voltage which is injected the other circuits.
All the grounds for arduino/LCD system should be connected together.
The grounds for the motor ciscuit should be connected together.
There should be one and only one connection between the two separate grounds described above.
This often called a star ground system.
 

sagor

Joined Mar 10, 2019
912
Did you try a 0,1uf or 0.01uF capacitor across the motor leads? The motor may be producing a lot of RF interference if it has brushes that are sparking. Such RF can get back into the power leads and hence into the controllers.
Also, does the I2C bus have pull-up resistors? Try putting 10k resistor to each line from Vcc. Some internal pull-ups are not strong enough in a noisy electrical environment.
 

Thread Starter

pidgin

Joined Oct 30, 2020
21
In your layout, study where the motor current flows, especially the ground.
If any part of the ground of the arduino/LCD carries the motor current then that current can result in a noise voltage which is injected the other circuits.
All the grounds for arduino/LCD system should be connected together.
The grounds for the motor ciscuit should be connected together.
There should be one and only one connection between the two separate grounds described above.
This often called a star ground system.
Sadly, I don't (yet) have an oscilloscope to be able to tell if there is noise across the lines.
I do connect grounds together when applicable.

What about an optocoupler? What would you do with it?
Just use a supply system that will work.
I am actually now using an opto-coupler to totally separate the the engine from the Arduino side.
AND, I now put the engine on a totally separate power supply with it's own ground, totally disconnected.

YET, I still see the I2C getting out of whack, breaking up I2C communication.
It now happens only few seconds (or sometimes minutes) into the process.. but still happens.

Did you try a 0,1uf or 0.01uF capacitor across the motor leads? The motor may be producing a lot of RF interference if it has brushes that are sparking. Such RF can get back into the power leads and hence into the controllers.
Also, does the I2C bus have pull-up resistors? Try putting 10k resistor to each line from Vcc. Some internal pull-ups are not strong enough in a noisy electrical environment.
Yes. I tried putting capacitors on the motor. It didn't help.
I've also added pull-up resistors to the I2C lines (4.7K, seems to be the recommended value). Also not helping.
I will try to replace the 1n4007 diode with a faster reacting one. I'm not sure it is going to help. But no harm trying.
 

KeithWalker

Joined Jul 10, 2017
3,098
Sadly, I don't (yet) have an oscilloscope to be able to tell if there is noise across the lines.
I do connect grounds together when applicable.
Have you taken any notice of all the advice you have been given on how to connect your supplies?
How about sharing a diagram of how you really have it connected, then we might be able to help.
 
Top