Home › Lessons › Embedded (ESP32) › PWM actuator: DC motor through a MOSFET

PWM actuator: DC motor through a MOSFET

Embedded (ESP32) · Intermediate · about 20 minutes · part of Zen’s Electronics Design Mastery

A GPIO pin gives a few milliamps; a motor wants an amp. A logic-level MOSFET switches the motor’s own supply, and PWM sets the average voltage: at duty d the motor sees d × V. The diode across the motor carries its current when the MOSFET switches off, so the inductive kick never reaches the MOSFET.

PWM actuator: DC motor through a MOSFET: the circuit on the simulator's bench

Open this lesson in the labFree, in your browser, no account needed.

How it works

Duty d = 54 % → average motor voltage ≈ d × 6 V = 3.22 V

Average current ≈ d × V / Rmotor = 527.6 mA (the motor is about 6 Ω here; RDS(on) at 3.3 V gate is 54 mΩ)

The simulator averages the 20 kHz switching; on a scope the drain would be a 20 kHz square wave. The 10 kΩ pull-down keeps the motor off while the ESP32 boots and its pins float.

Try it on the bench

  1. Scroll over the pot to change the duty: the motor current and speed follow.
  2. Delete the flyback diode. In a real circuit every switch-off now slams the MOSFET with a voltage spike (see the inductive-load lesson).
  3. Set the duty to 100 %: the MOSFET is fully on and dissipates only milliwatts.

Parts on the bench

In the course

Zen’s Electronics Design Mastery, module “Microcontrollers & Embedded”.

More on embedded (esp32)