Home › Lessons › Embedded (ESP32) › H-bridge: PWM speed, direction and braking

H-bridge: PWM speed, direction and braking

Embedded (ESP32) · Intermediate · about 15 minutes · part of Electronics Technician

Four switches let current flow through the motor either way. The DRV8833 takes two logic inputs per motor: one high, one low sets the direction; PWM on the high one sets the speed; both high shorts the motor terminals together (brake); both low lets it coast.

H-bridge: PWM speed, direction and braking: the circuit on the simulator's bench

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

How it works

analogWrite(…, 128) is a duty of 50.2 %. The motor (6 Ω) sees the average, less the two switches’ 0.36 Ω each: 7.4 × 0.502 × 6 ÷ 6.72 = 3.32 V.

Braking shorts the motor through the low-side switches, so its own generated voltage stops it; coasting leaves it free.

Try it on the bench

  1. Change the 128 in dutyA to 200: the motor runs faster.

Parts on the bench

In the course

Electronics Technician, module “Transistor circuits”.

More on embedded (esp32)