Hardware Academy
Robotics

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.

Brushed DC motor cutaway: magnets, armature windings, commutator and brushesEnd view through the motorCommutator endNSpermanent magnetcopper windingarmature polesteel canrotation+−commutator: 3 copper segments on the shaftcarbon brushspringAs the shaft turns, each brush slides onto the next segment,flipping coil currents so the torque never changes sign.
Brushed DC motor: magnets on the stator (dashed arrows show the field from N to S), a three-pole armature on the shaft, and the commutator and brushes that switch each coil's current as it turns.

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

DriverSwitchesMotor supplyCurrent per channelLoss at 1 A
L298NBipolar Darlingtonup to 46 V2 Aabout 2 V drop, 2 W
TB6612FNGMOSFET2.5-13.5 V1.2 A (3.2 A peak)about 0.5 V, 0.5 W
DRV8833MOSFET2.7-10.8 V1.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.

H-bridge with four switches, a DC motor, current paths and the TB6612FNG truth tableVM 7.4 VGNDmotor stoppedABQ1onQ2offQ3offQ4onPWM at 20 kHz, duty 60%average 4.4 VTB6612FNG, one channelIN1IN2PWMresultHLHforwardLHHreverseHHxshort brakeLLHstop (coast)xxLshort brakePWM low = short brake: slow decaybetween pulses, current keeps flowing

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.

Top view of a hobby servo whose horn angle follows the pulse width, with the 50 Hz pulse trainSG900°45°90°135°180°signal wire, two 20 ms frames (50 Hz)010203040 mszoom: the first 3 ms of a frame1.0 ms0°1.5 ms90°2.0 ms180°1.50 ms
Servo calibration
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.

Two-phase stepper with coil currents and the rotor following the stator fieldA+B+A−B−NSCoil A+71%Coil B+71%+100%−100%01234position in full steps (one electrical cycle = 4 full steps = 7.2° of shaft)coil currents over one electrical cycleAB
Drive mode
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?

worked answertext
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 total

Answer. 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?
An H-bridge puts four switches around the motor: two high-side switches to the supply and two low-side switches to ground. Turning on one high-side switch and the opposite low-side switch drives current through the motor one way, and the other diagonal pair reverses it. Speed comes from pulse-width modulation at around 20 kHz, so the motor sees duty times supply on average. Brake turns on both low-side switches, shorting the motor so its back-EMF drives a current that opposes rotation and stops it quickly; coast turns everything off and lets it spin down on friction.
screenWhy would you choose a TB6612FNG over an L298N for a 7.4 V robot?
The L298N uses bipolar Darlington switches that drop about 2 V in total at 1 A, so on a 7.4 V pack the motor sees roughly 5.4 V and the chip burns about 2 W per amp. The TB6612FNG uses MOSFETs with about 0.5 Ω total on-resistance, dropping about 0.5 V at 1 A, so the motor gets more voltage and the board stays cool without a heatsink. It is rated 1.2 A continuous and 3.2 A peak per channel, which suits N20 gearmotors, accepts 3.3 V logic and switches at up to 100 kHz. The L298N only wins when you need its 46 V rating or 2 A continuous.
deepWalk me through sizing a motor and gear ratio for a small wheeled robot.
I start from the requirements: mass, wheel radius, top speed, the worst slope and the acceleration I want. The force at the wheels is m·g·sinθ for the slope plus rolling resistance plus m·a, and the torque per motor is that force times the wheel radius divided by the number of driven wheels. Top speed divided by the wheel circumference gives the wheel rpm I need. Then I pick a motor and ratio so the operating point sits at about 20-30% of stall torque, which leaves margin for acceleration and keeps efficiency reasonable, with a no-load speed about 20-30% above my top speed. Finally I check the running current against the driver's continuous rating and the stall current against its peak rating.
deepWhat is shoot-through in a half-bridge, and how is it prevented?
Shoot-through is both switches in one leg conducting at once, which shorts the supply through two on-resistances; from a stiff battery that can be tens of amps, enough to destroy MOSFETs in microseconds. It happens if the logic commands it, or during transitions, because MOSFETs turn off more slowly than they turn on. Drivers prevent it with interlocks that never allow both inputs of a leg on, and with dead time, a gap of roughly 100 ns to a few microseconds where both switches are off while the inductive current freewheels through the body diodes. Integrated drivers like the TB6612FNG handle this internally; with discrete gate drivers you set the dead time yourself and verify it on a scope.
screenWhen would you pick a stepper, a hobby servo or a DC gearmotor with an encoder?
A stepper gives precise open-loop positioning and strong holding torque at low speed, which is why 3D printers use NEMA 17s, but it loses torque as speed rises and silently skips steps if overloaded. A hobby servo is the simplest way to hold an angle within about 180°, such as panning a sensor, because you only send a 1-2 ms pulse every 20 ms. A DC gearmotor with an encoder and a PID loop is best for continuous rotation and efficient driving, as on wheels. On the course robot that means an SG90 for the sensor pan and encoder gearmotors for the wheels.

Quiz

1. A brushed DC motor has 4 Ω windings and runs from 6 V. What is its stall current?
2. Which H-bridge state stops a spinning motor fastest?
3. A servo receives a 1.5 ms pulse every 20 ms. What is the duty cycle?
4. A 200-step stepper is driven at 1/16 microstepping. How many microsteps make one revolution?
5. An L298N drops about 2 V at 1 A. Roughly what voltage reaches the motor from a 7.4 V pack at full duty?
6. A motor makes 0.002 N·m through a 50:1 gearbox that is 70% efficient. What torque reaches the wheel?

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.