PWM makes other GPIO noise

Hi,all

I have two pins with PWM for my DC motors,and two UC-SR04s ultrasonic sensors
connect to some regular digital pins,if I disconnect PWM ,sensors are fine ,If I connect PWM ,it would cause
noise to influence the sensors to make wrong ECHO value,I don know why, how to fix this kind of problem?

Thanks!

Hi,
Welcome to the Forum

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html
then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Including how you are supplying your project with power.

Tom.... :slight_smile:

@yangkai, do not cross-post. Other thread removed.

Why the 78M05.
Can't you power the logic half of the L298 from the Mega's 5volt pin.

Did you connect the 7.2volt battery to the Mega's V-in or DC jack.

Wise to have some heavy decoupling on pin4 of the L298 (1000uF or more).
Leo..

If I connect PWM ,it would cause noise to influence the sensors to make wrong ECHO value,I don know why,

The why is because the motor brushes cause tiny sparks that generate interference that effects other circuits.

how to fix this kind of problem?

Suppression of the sparks, and limiting the distance the interference can travel.
see De-coupling

The attached PDF shows how to solder caps direct onto the motor.

solder_caps.pdf (299 KB)

Wawa:
Why the 78M05.
Can't you power the logic half of the L298 from the Mega's 5volt pin.

Did you connect the 7.2volt battery to the Mega's V-in or DC jack.

Wise to have some heavy decoupling on pin4 of the L298 (1000uF or more).

The motor driver board is designed to connect to 78m05 and also can directly from 5 volt pin ,I just use the original way it gave to me.
I use 7.2volt battery to DC jack and motor driver board.

Grumpy_Mike:
The why is because the motor brushes cause tiny sparks that generate interference that effects other circuits.

In this layup drawing ,the situation is more stable with occasionally noise occurs ,before this connecting ,I connected pin 17,16 instead of 43,42 of the UC-SR04, PWM pin6 instead of 3 .
and its noise like a maniac,and pin 17 16 is closed to the PWM pin,does physical distance of pin to pin also have influence?

also thanks for your caps suggestion ,I will study it .

Hi,
What value/type of caps have you got around the 78M05, and are they as close as possible to the regulator.
7.2V into 5V reg is a bit close, can you measure your 5V as you operate the motors please.
7.2 - 5 = 2.2V differential, that is not really good to help the 78M05 to regulate 5V output.
A small DC-DC switch mode would be better.

Can you post a picture of your project so we can see your layout.

Thanks.. Tom.. :slight_smile:
Also I assume you have gnd of the mega connected to the gnd of the L278.

TomGeorge:
What value/type of caps have you got around the 78M05, and are they as close as possible to the regulator.

I have no idea ,it is so tiny(2mm long) and no value label on it.

  1. 7.2V into 5V reg is a bit close, can you measure your 5V as you operate the motors please.
  2. A small DC-DC switch mode would be better.
  1. measure the Vout is 5V or not?
  2. Do you mean connect it with 5v pin directly rather than through 78M05?

Can you post a picture of your project so we can see your layout.

Just as the drawing, what is the difference? My motor driver board and mega board are put in different layers of the little car ,the picture may not clear because driver board is on the first layer.
and the wires are mess around.
If you insist ,I can separate the car for the picture.

Also I assume you have gnd of the mega connected to the gnd of the L278.

I thinks it does .
Because the mega and l298 are powered by the same battery.

Thanks!

Hi,
I think we are losing something in translation.
A picture please, a picture is worth a thousand words.

,the picture may not clear because driver board is on the first layer.
and the wires are mess around.

The wires being a "mess around" may be one of the causes of your problem.

Connect a DMM from gnd to the 5V output of the regulator, and measure the voltage when the problems occur.

Thanks.. Tom.. :slight_smile:


c3&c2 are the caps

does physical distance of pin to pin also have influence?

Yes, airborne interference drops off with the inverse square of the distance.

Had a quick look at the hardware.
Could be wrong, but it seems the best way of connecting this is:

Battery ONLY to the power pins of the motor terminals.
The Mega and sensors will now get power from the 78M05, so powering the DC jack is not needed.
Leo..