PWM Signal Noise on GND

I am working on a project that has a motor and a fan. This is my first time using a DC motor vs a Servo so I went online and found a motor driver circuit that seemed like it should work.

And it does…mostly. My version of the circuit is attached. The motor turns well, I am able to control the speed with different PWM signals, etc. However, I have been experiencing weird issues with my circuit where the ATMega328P resets randomly, or freezes on a line of code, or the motor or fan will latch on even when the code moves past where they should turn off.

Here is my motor control code:

    if ((tnow - tlast) >= motorInterval) {
      Serial.println("motor on");
      analogWrite(motorPin, 150);
      Serial.println("Motor 100");
      delay(1000);
      analogWrite(motorPin, 100);
      Serial.println("Motor 150");
      delay(1000);
      analogWrite(motorPin, 50);
      Serial.println("Motor 50");
      delay(1000);
      digitalWrite(motorPin, LOW);
      Serial.println("motor off");
      tlast = millis();
      motorCheck = true;
    }

When it freezes, it stops after printing “Motor 150” or “Motor 100”

I have a feeling that the problem is related to the fact that I can see the PWM signal on the ground line when probing with an oscilloscope. I can see on ground exactly when the fan comes on (very small wave visible) and when the motor comes on (distinguishable PWM signals ~20mV amplitude).

I have triple checked that all my grounds are connected. I am at a loss as to what else to try. Any help would be appreciated. Thanks

Please post all the code, describe your motor power supply and post a link to the motor, or to its data sheet.

The 10K resistor should be connected from the Arduino pin to ground, not from the MOSFET gate to ground.

pyfi:
I am working on a project that has a motor and a fan. This is my first time using a DC motor vs a Servo so I went online and found a motor driver circuit that seemed like it should work.

Well, it probably would except for a couple of details. :astonished:

If using PWM, a 1N4001 power diode is not fast enough though since a motor does - or should - not behave as an inductor and have a “kick-back”, this will not be a problem. You have substituted a Schottky - which is a fast recovery diode and makes sense, while its low conduction voltage is entirely irrelevant to this purpose.

The 0.1 µF capacitor should be mounted on the motor terminals, since the motor is the source of the interference. Better still, a couple of 0.1 µF capacitors connected from each brush (and soldered) to the motor casing. Be careful not to melt the motor end piece in the process. This is more a matter of RF suppression than interference that will affect the Arduino. While my garage door opener is actually in the process of closing or opening my garage, neither the garage door remote, or the remote for my car doors, will work and we lose TV reception for that interval. I really should delve into the opener. :grinning:

pyfi:
I have a feeling that the problem is related to the fact that I can see the PWM signal on the ground line when probing with an oscilloscope. I can see on ground exactly when the fan comes on (very small wave visible) and when the motor comes on (distinguishable PWM signals ~20mV amplitude).

553f273a20f336cb2998755fea0b3e334f4df639.png

“Lead dress” is critical. Obviously you cannot be powering the motor from the Arduino with its on-board regulator, so you have the power supply leads for the motor kept together as they go to the FET, where you have a 1000 µF capacitor across them. The negative connects to the FET source and the diode connects between the drain and the positive close to that capacitor. The wires from the diode to the motor then travel as a pair. Note, the diode does not mount at the motor as it is there to “catch” the impulse generated by switching the FET.

What is good about the original diagram:

Is that it shows the ground connection to the Arduino branching off at the FET source. The motor current must not travel through any part of the ground connections on the Arduino. If the power supply is common to powering the Arduino, the ground should travel separately from the power supply to the Arduino (and of course, as a pair with the Vcc).

And yes, the 10k pull-down is not there to “pull down” the driving voltage to the FET however minor that effect. It is there to define the output state of the Arduino during reset and initialisation of the code, so it goes - directly across the Arduino output pin.

Hi,
What are the specs of the motor?

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

How have you got the gnds of the controller connected to the gnd of the motor power supply?
It sounds like your gnd circuit is not complete or has some loose or inadequate wires.

What model Arduino are you using?

Thanks.. Tom... :slight_smile: