Actuators and motor drivers
Brushed, brushless, servo and stepper motors and the H-bridges that drive them.
Day 7 · 55 min
After this lesson
- You can explain how an H-bridge controls direction, speed, brake and coast.
- You can compare brushed DC, BLDC, servo and stepper motors for a job.
- You can size a motor and gear ratio for a small robot.
Turning electricity into motion
An actuator turns an electrical command into force or motion. Small robots use four kinds: brushed DC gearmotors for wheels, brushless motors for propellers and high-power joints, hobby servos for angles, and steppers for open-loop positioning. Every one needs a driver, because a microcontroller pin can supply about 20 mA and a stalled N20 wants more than an amp.
Brushed DC motors
A brushed motor has permanent magnets on the stator and coils on the rotor. The commutator, a split copper ring on the shaft, and two spring-loaded brushes reverse the current in each coil as it turns, so the torque always points the same way. Two equations describe the motor:
- Torque is proportional to current: T = Kt·I.
- A spinning motor is also a generator. Its back-EMF E = Ke·ω opposes the supply, so V = I·R + Ke·ω.
In SI units Kt equals Ke. Hobby datasheets often give Kv in rpm per volt instead, and Kt ≈ 9.55/Kv N·m/A. At zero speed there is no back-EMF, so the stall current is V/R: a 6 V motor with 4 Ω windings draws 1.5 A at stall, and the same surge at every start. As the motor speeds up, back-EMF rises and current falls. Torque falls linearly from stall torque at zero speed to nothing at no-load speed, so mechanical power P = T·ω peaks at half of each: P_max = T_stall·ω₀/4.
Gearmotors, brushless motors, servos and steppers
The course robot's N20 gearmotors pair a 12 mm brushed motor spinning thousands of rpm with a small metal gearbox. A 50:1 ratio divides speed by 50 and multiplies torque by 50 times the gearbox efficiency, often 60-80% for several spur stages.
Brushless (BLDC) motors put the coils on the stator and the magnets on the rotor, so there are no brushes to wear and efficiency reaches 85-90%. An electronic speed controller (ESC) commutates them using Hall sensors, back-EMF zero crossings or field-oriented control. Drones, e-bikes and quasi-direct-drive robot legs use them.
A hobby servo is a DC motor, gearbox, potentiometer and control board in one case. It reads one pulse every 20 ms (50 Hz): 1 ms is one end of travel, 1.5 ms the centre and 2 ms the other end, though many, including the SG90, need about 0.5-2.5 ms for a full 180°. An SG90 gives about 1.8 kg·cm and turns 60° in 0.1 s at 4.8 V.
A stepper moves in fixed increments as its two coils are energized in sequence: 200 steps per revolution (1.8°) for a typical NEMA 17. Half-stepping gives 400 positions, and microstepping drives sine and cosine currents to reach 3,200 at 1/16. Drivers such as the A4988 (up to 1/16, 35 V) and the Trinamic TMC2209 (up to 1/256, near-silent) regulate coil current by chopping. Steppers hold position without feedback but lose torque as speed rises and skip steps silently when overloaded.
The H-bridge
A DC motor reverses when its current reverses, which takes four switches arranged in an H. Closing the high-side switch on one side and the low-side switch on the other drives current one way; the opposite diagonal reverses it. Closing both low-side switches shorts the motor, and its back-EMF drives a current that opposes rotation: a brake. Opening all four lets it coast. Closing both switches on the same side is shoot-through, a short across the battery that can destroy MOSFETs in microseconds, so drivers insert dead time, a moment with both switches off, at every transition.
Speed comes from PWM. Switching at about 20 kHz, above hearing, lets the motor's inductance smooth the current, and the average voltage is duty × supply. During the off part of each cycle the current keeps circulating, either through the low-side switches (slow decay, which the TB6612FNG uses) or through diodes back to the supply (fast decay). That is why every bridge needs flyback paths: an inductor's current cannot stop instantly, and without one, L·di/dt becomes a spike of tens of volts.
Driver ICs
| Driver | Switches | Motor supply | Current per channel | Loss at 1 A |
|---|---|---|---|---|
| L298N | Bipolar Darlington | up to 46 V | 2 A | about 2 V drop, 2 W |
| TB6612FNG | MOSFET | 2.5-13.5 V | 1.2 A (3.2 A peak) | about 0.5 V, 0.5 W |
| DRV8833 | MOSFET | 2.7-10.8 V | 1.5 A RMS (2 A peak) | about 0.36 V, 0.36 W |
The L298N fills old tutorials, but on a 7.4 V pack it hands the motor only about 5.4 V. Many drivers also sense current, through a shunt resistor or an internal current mirror, so firmware can detect a stall or limit torque.
Torque, speed and sizing wheels
A wheel of radius r turns motor torque into force, F = T/r, and wheel speed into ground speed, v = ω·r. A gear ratio N multiplies torque by N times its efficiency and divides speed by N. To size a drive, add up the forces (slope m·g·sinθ, rolling resistance and m·a for acceleration), multiply by the wheel radius, divide by the number of driven wheels, then choose a motor and ratio that deliver that torque at no more than about 25% of stall torque while still reaching your top speed.
Interactive: drive a bridge, a servo and a stepper
H-bridge: drive, brake, coast and the short you must never make
Click the four switches or use the presets. The PWM duty sets the average voltage in drive; the motor's speed responds with its own time constant.
Forward: Q1 + Q4, current flows left to right through the motor. Average motor voltage 4.4 V (60% of 7.4 V). Speed 0% of full.
Run it forward and press Brake: the motor stops in a fraction of a second. Run it forward again and press Coast: it takes several times longer. Finally, click Q2 while Q1 is on.
Servo PWM: the pulse width is the position
A hobby servo reads one pulse every 20 ms (50 Hz). Its internal controller turns the horn until its potentiometer matches the pulse width, at about 60° per 0.1 s.
- Commanded angle
- 90°
- Duty cycle
- 7.50% of 20 ms
- ESP32 LEDC, 16-bit at 50 Hz
- duty = 4915
- Arduino Servo library
- writeMicroseconds(1500)
Stepper phases: full, half and microstepping
Two coils, A and B, steer a magnetic field; the rotor's north pole follows it. Drawn as a 2-pole rotor, so one turn here is one electrical cycle: 4 full steps, or 7.2° on a real 1.8° motor.
- Position
- microstep 0
- Electrical angle
- 45.0°
- Shaft angle (200-step motor)
- 0°
- Positions per revolution
- 400 (0.9° each)
Step through full-step mode and watch the rotor jump 90° electrical at a time, with both coils at 71%. Then switch to 1/16: the same motion becomes 16 small steps that trace a sine and a cosine.
In practice
Practice
Size the drive for a 500 g robot on a 10° ramp
The course robot weighs 500 g, has two driven 44 mm wheels and must climb a 10° ramp while accelerating at 0.5 m/s². What torque does each motor need, and what stall torque should you shop for?
Robot: m = 0.5 kg, two driven wheels, wheel diameter 44 mm -> r = 0.022 m
Ramp: theta = 10 degrees, sin = 0.174, cos = 0.985
Assume rolling resistance Crr = 0.02 (small rubber wheels on a hard floor)
and an acceleration of 0.5 m/s^2 while on the ramp
Slope force F_g = m g sin(theta) = 0.5 x 9.81 x 0.174 = 0.85 N
Rolling F_r = Crr m g cos(theta) = 0.02 x 0.5 x 9.81 x 0.985 = 0.10 N
Acceleration F_a = m a = 0.5 x 0.5 = 0.25 N
Total F = 1.20 N
Wheel torque, both wheels T = F r = 1.20 x 0.022 = 0.0264 N m
Per motor 0.0264 / 2 = 0.0132 N m = 13.2 mN m (about 0.13 kg cm)
Sizing rule: run at no more than about 25 % of stall torque
Required stall torque per motor >= 0.0132 / 0.25 = 0.053 N m (about 0.54 kg cm)
Check speed: 100 rpm x pi x 44 mm = 13.8 m/min = 0.23 m/s no-load
Mechanical power on the ramp: P = F v = 1.20 N x 0.2 m/s = 0.24 W in totalAnswer. About 13 mN·m per motor, so look for a stall torque of at least 0.05 N·m (0.54 kg·cm). Many 6 V N20 gearmotors in the 100 rpm class list 1-2 kg·cm at stall, a comfortable margin. Note that gravity is 70% of the load: a 20° ramp needs about 70% more torque, because the total force rises from 1.2 N to 2.0 N.
Real-world scenario
Real-world scenario
ESP32 resets every time the robot reverses
A robot's ESP32 and TB6612FNG share a 2S Li-ion pack: the driver's motor supply comes straight from the pack and the ESP32 runs from a small 5 V buck converter. The obstacle-avoidance code flips both motors from full forward to full reverse in one step when it sees a wall. About one reversal in three, the robot freezes for half a second and the serial monitor prints a reboot banner.
Symptoms
- The serial log shows 'Brownout detector was triggered' followed by the ESP32 boot banner, only right after a reversal command.
- Gentle speed changes never cause a reset, and the problem gets worse as the battery runs down.
- A scope on the 5 V rail shows a dip to about 3.3 V lasting roughly 2 ms at each reversal, plus ringing spikes on the motor supply.
- Unplugging one motor makes the resets rare.
Interview questions
screenHow does an H-bridge control a DC motor's direction and speed? What are brake and coast?
screenWhy would you choose a TB6612FNG over an L298N for a 7.4 V robot?
deepWalk me through sizing a motor and gear ratio for a small wheeled robot.
deepWhat is shoot-through in a half-bridge, and how is it prevented?
screenWhen would you pick a stepper, a hobby servo or a DC gearmotor with an encoder?
Quiz
References and further reading
Where the ideas in this lesson come from, and what to read next. Books are the standard texts; papers are the original sources; standards are what employers work to.
- Documentationfree online
Toshiba (2014). TB6612FNG: Driver IC for Dual DC Motor (datasheet). toshiba.semicon-storage.com.
Read: Output saturation voltage (0.5 V typical at 1 A) behind the L298N comparison.
- Book
Austin Hughes and Bill Drury (2019). Electric Motors and Drives: Fundamentals, Types and Applications. Newnes, 5th edition.
Read: Chapters on brushed DC, stepper and brushless motors.
- Book
Roland Siegwart, Illah R. Nourbakhsh and Davide Scaramuzza (2011). Introduction to Autonomous Mobile Robots. MIT Press, 2nd edition.
Read: The locomotion chapter on wheel configurations.
- Book
Paul Horowitz and Winfield Hill (2015). The Art of Electronics. Cambridge University Press, 3rd edition.
Read: The section on driving motors and H-bridges.