How to Design and Implement a PWM Motor Control Circuit

Learn how to design and implement a PWM motor control circuit using an Arduino, MOSFET, and diode to efficiently control DC motor speed.


Pulse Width Modulation (PWM) is one of the most effective techniques used to control the speed of DC motors. It is widely used in applications such as robotics, fans, pumps, electric vehicles, and industrial automation. This article provides an in-depth guide on how to design and implement a PWM motor control circuit from scratch, covering essential components, design principles, and practical implementation.

What is PWM?

Pulse Width Modulation (PWM) is a technique of controlling the average voltage supplied to a load (in this case, a DC motor) by rapidly switching the power on and off. The duty cycle of the signal determines how long the switch remains on in a given period.

  • Duty Cycle (%) = TONTON+TOFF×100\frac{T_{ON}}{T_{ON} + T_{OFF}} \times 100

For example:

  • 0% duty cycle = always OFF (motor off)

  • 50% duty cycle = ON half the time (motor at half speed)

  • 100% duty cycle = always ON (motor full speed)

Why Use PWM for Motor Control?

  • Efficient speed control (minimal heat loss)

  • Lower power consumption

  • Precise control over motor speed and torque

  • Reduced electromagnetic interference (EMI)

Key Components Required

To design a PWM motor controller, you'll need the following:

  1. Microcontroller (Arduino, STM32, PIC, etc.) – to generate the PWM signal

  2. MOSFET or BJT – as a switching device to handle motor current

  3. Flyback Diode – to protect against back EMF from the motor

  4. DC Motor – brushed DC motor for this guide

  5. Power Supply – rated for the motor voltage and current

  6. Gate Resistor (for MOSFET) – optional but recommended

  7. Snubber Circuit – optional for noise suppression

PWM Motor Control Circuit 



Step-by-Step Design and Implementation

Step 1: Generate PWM Signal

Using Arduino:

int motorPin = 9;

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

void loop() {
  int speed = 128; // 0 to 255
  analogWrite(motorPin, speed);
}
  • analogWrite() generates a PWM signal with 490 Hz (default on most Arduinos).

  • Values range from 0 (0% duty) to 255 (100% duty).

Step 2: Choose a Suitable Switching Device

Use a logic-level N-channel MOSFET like IRF540N or IRLZ44N:

  • Vds ≥ Motor Voltage

  • Id ≥ Motor current

  • Vgs(th) low enough to fully turn ON with 5V (Arduino output)

Add a 220Ω resistor between the microcontroller PWM pin and MOSFET gate to limit inrush.

Step 3: Add Flyback Protection

When the MOSFET turns off, the motor's inductance creates a high-voltage spike. A flyback diode (Schottky recommended for fast switching) like 1N5819 or UF4007 should be placed in parallel with the motor to protect the circuit.

Step 4: Assemble the Circuit

  • Connect the motor between +12V and the MOSFET drain.

  • Connect MOSFET source to GND.

  • Connect the PWM output pin from Arduino to the MOSFET gate.

  • Place the diode across motor terminals (cathode to +12V).

  • Optionally, use a heat sink on the MOSFET.

Step 5: Test and Tune

Upload your PWM code. Adjust the analogWrite() value to change motor speed.

You can also implement acceleration profiles (soft-start) using code:

for (int speed = 0; speed <= 255; speed++) {
  analogWrite(motorPin, speed);
  delay(10); // slow ramp-up
}

Practical Tips

  • Keep PWM frequency above 20 kHz to avoid audible noise (use Timer configuration for custom frequency).

  • Use low Rds(on) MOSFETs for better efficiency.

  • Ensure proper cooling for high current.

  • Add a capacitor (100 µF to 470 µF) across motor terminals to suppress voltage spikes.

Advanced Extensions

  • Use current feedback for closed-loop control.

  • Implement PID control for speed accuracy.

  • Control direction using an H-Bridge circuit (e.g., L298N, DRV8871).

FAQs

Q1. What PWM frequency should I use for motor control?

A: For DC motors, use a PWM frequency above 20 kHz to eliminate audible noise. However, too high a frequency (>100 kHz) may result in switching losses.

Q2. Why is my MOSFET heating up?

A: It may not be fully turning on due to insufficient gate voltage. Use a logic-level MOSFET, and ensure you're applying the full 5V/3.3V as per the microcontroller logic.

Q3. Can I control a 24V motor with a 5V Arduino?

A: Yes. The Arduino provides the control signal (PWM), and the MOSFET switches the 24V motor power. Ensure the MOSFET is rated for ≥ 24V and your flyback diode is properly rated.

Q4. What’s the advantage of using PWM over a variable resistor?

A: PWM offers higher efficiency, less heat dissipation, and precise control, unlike a resistor that wastes energy as heat.

Q5. How do I reverse the motor direction with PWM?

A: You’ll need an H-Bridge circuit (e.g., L298N, DRV8871, or discrete MOSFETs) to allow bidirectional control.

Conclusion

PWM is an efficient and versatile technique for controlling motor speed with high precision. By understanding the underlying principles and correctly implementing a PWM motor control circuit using a microcontroller and MOSFET, you can build reliable and efficient motor-driven systems. This guide serves as a foundation for both hobbyists and professionals working on motor control applications.

Prasun Barua is an Engineer (Electrical & Electronic) and Member of the European Energy Centre (EEC). His first published book Green Planet is all about green technologies and science. His other …

Post a Comment

© Prasun Barua . All rights reserved. Developed by Jago Desain