Subsection 11.1.2 Reversing Direction: The H-Bridge

We saw above that reversing a motor’s direction means reversing the polarity of the voltage across it, and that a motor draws far more current than a small signal does. A GPIO pin can do neither: it drives its pin only to ground or to 3.3 V, never the reverse of that, and it can source or sink only a few milliamps where a motor wants hundreds. Both problems are solved by a motor driver IC, and at its heart is an H-bridge, a circuit of four switches arranged in an H around the motor.
Each of those four switches is a transistor, the same N-channel and P-channel switches from Day 6. Closing one diagonal pair of them sends current through the motor in one direction; closing the other diagonal pair reverses the current, and with it the direction of rotation. There is also a useful third setting that brakes the motor. We will work out in class exactly which switches to close for each of these, and why braking works.
The driver IC we use in this course is the TB6612FNG. The STM32C031C6 controls it with a few logic-level signals, two inputs that choose the direction (or braking) and a PWM input that sets the speed, while the motor itself runs from its own power supply. That separation is the point of the driver: our 3.3 V logic decides what the motor should do, and the driver switches the motor’s larger voltage and current to make it happen.
