Electric Motors

DC Motor Speed Control Using PWM (With the Equivalent Circuit)

How PWM controls DC motor speed: duty cycle, a MOSFET switch, a flyback diode, and the equivalent circuit that explains why speed follows voltage.

On this page
  1. Duty cycle sets the average voltage
  2. The equivalent circuit
  3. Why the duty cycle sets speed
  4. A basic MOSFET circuit
  5. Arduino sketch
  6. Using a 555 timer instead
  7. Troubleshooting
  8. Safety

Pulse-width modulation (PWM) controls the speed of a brushed DC motor by switching the supply on and off quickly. The motor responds to the average voltage, so a longer “on” time means a higher speed. This article explains the duty cycle, the equivalent circuit behind the behaviour, and a simple MOSFET and Arduino build.

Duty cycle sets the average voltage

The duty cycle is the share of each switching period during which the supply is on. On a 12 V supply, a 50% duty cycle gives an average of about 6 V, and a 25% duty cycle gives about 3 V. These are ideal figures. Real motors have losses, and the motor’s own inductance smooths the switching, so the average is what matters.

PWM wastes less power than a series resistor. A resistor drops the voltage by turning the extra energy into heat. A switch that is fully on or fully off dissipates little power, so less energy ends up as heat.

The equivalent circuit

A brushed DC motor can be modelled as a few simple parts in series:

  • V: the supply voltage, or the average PWM voltage at the motor
  • R_a: the armature winding resistance
  • L_a: the armature inductance
  • E_b: the back-EMF, a voltage that opposes the supply and grows with speed

The circuit equation and the two motor constants are:

V   = I_a × R_a + L_a × dI_a/dt + E_b
E_b = K_e × ω         (back-EMF is proportional to speed)
T   = K_t × I_a       (torque is proportional to armature current)

In SI units, K_e and K_t have the same numerical value. Once the current settles, the L_a term drops out. Solving for speed gives:

ω = (V − I_a × R_a) / K_e

This shows that, at a fixed voltage, speed falls as load increases. A heavier load draws more current. That puts more voltage across R_a and leaves less to turn the motor.

The back-EMF also keeps the speed steady. If the motor spins faster, the back-EMF rises, the current falls and the torque drops until the motor and the load balance.

Why the duty cycle sets speed

At a steady duty cycle, the average voltage is roughly duty × V_supply. The motor settles at the speed where its back-EMF and the average voltage balance the load. The inductance filters the switching pulses, so the average matters more than any single pulse.

The switching frequency needs to be high enough that the motor does not whine. A frequency around 20 kHz is above human hearing and avoids most of the whine. Many Arduino boards produce PWM at about 490 Hz on most pins by default, which can be audible. That is one reason a simple sketch can make a motor whine.

A basic MOSFET circuit

Use a logic-level N-channel MOSFET as a low-side switch. The motor sits between the positive supply and the MOSFET’s drain. The source goes to ground.

  • Motor + to the motor supply +.
  • Motor − to the MOSFET drain.
  • MOSFET source to ground, joined to the Arduino ground.
  • Arduino PWM pin to the gate through a resistor. About 100 Ω is a common starting value.
  • A pull-down resistor, about 10 kΩ, from gate to ground, so the MOSFET stays off when the pin is idle.
  • A flyback diode across the motor, cathode to the motor supply +, anode to the drain. See why a DC motor needs a flyback diode.

Pick a MOSFET rated for at least the motor’s stall current and the supply voltage, with a low on-resistance. Check the datasheet for the gate voltage needed to switch it fully on.

Arduino sketch

const int MOTOR_PIN = 9;   // PWM pin wired to the MOSFET gate

void setup() {
  pinMode(MOTOR_PIN, OUTPUT);
}

void loop() {
  analogWrite(MOTOR_PIN, 128);   // 128 of 255 is about a 50% duty cycle
}

analogWrite takes a value from 0 to 255, so 128 is roughly half speed. For manual speed control, read a potentiometer with analogRead and map the result to 0 to 255.

Using a 555 timer instead

A 555 timer in astable mode can produce PWM without a microcontroller. A potentiometer sets the duty cycle. In a basic astable circuit, the duty cycle cannot drop below 50%. To reach lower duty cycles, add a diode that changes the charging path.

Troubleshooting

  • The motor stalls at low duty cycle: the average voltage may be too low to overcome friction. Raise the minimum duty cycle, or give the motor a short start-up pulse.
  • Audible whine: raise the PWM frequency, or use a driver designed for higher frequencies.
  • The MOSFET gets hot: the gate may not be driven fully on. Check the gate voltage and use a logic-level part. Check the current against the MOSFET rating, and add a heat sink if needed.
  • Speed drops under load: this is expected. The equivalent circuit shows why.

Safety

A stalled motor draws much more current than a running one. Check the stall current before you connect the supply, and fit a fuse or current limit if the supply can deliver more than the MOSFET and wiring can handle.

For reversing the direction, see how to reverse a DC motor with an H-bridge. For the terminal labels on DC motors, see what A1, A2, and S1, S2 mean on DC motors.

The complete guide to electric motors

Types of Electric Motors: DC, Servo and Stepper Compared
Read the guide

Keep exploring

Guides from other topics

All topics →