Subsection11.2.2Part 2: The H-Bridge Reverses the Motor
Reversing a motor means reversing the polarity of the voltage across it, and in an embedded system there is no hand to swap the two wires. The H-bridge does it electronically. As we saw in the reading (Figureย 11.1.2), it is four transistor switches around the motor: two upper switches to the motor supply and two lower switches to ground. The upper two transistors are P-channel switches, which are on when their gate is LOW, and the lower two are N-channel switches, which are on when their gate is HIGH.
Whenever you work with a motor there is going to be an H-bridge involved.
Figure11.2.8.The four switches are power MOSFETs, and they are not all the same kind. The upper two are P-channel devices, which conduct when their gate is driven LOW; the lower two are N-channel devices, which conduct when their gate is driven HIGH. The gate of each is marked g. That opposition is what the next page turns into a single control line per side.
Two kinds of switch, opposite to each other: the upper pMOS conducts on a LOW gate, the lower nMOS on a HIGH gate. The gate of each is marked g.
Closing one switch on the upper rail and the opposite switch on the lower rail connects one motor terminal to the supply and the other to ground, so current runs through the motor. Closing the other diagonal pair connects the terminals the other way round, and the current (and the rotation) reverses.
That leaves a question the four switches do not answer on their own: what drives their gates? The bridge is not built with four independent controls. Each side is driven from a single control line (one we will call IN1 for the left pair and IN2 for the right pair), and the trick is that the two transistors on a side respond to that one line in opposite ways. A P-channel switch on top turns on when its gate goes LOW, and an N-channel switch beneath it turns on when its gate goes HIGH, so whichever way the control line goes, exactly one of the pair conducts and the other is off. One wire per side therefore chooses whether that terminal is tied up to the supply or down to ground, and two wires cover every state the motor can be put in.
Figure11.2.10.How two control lines drive four switches. On each side of the bridge the upper and lower gates are driven from the same line (IN1 on the left, IN2 on the right), and because the upper switch turns on when its gate is LOW while the lower turns on when its gate is HIGH, one control line puts exactly one of its pair into conduction. Each terminal is therefore pulled either up to the supply or down to ground, never both. This is the simplified picture; the TB6612 puts decoding logic between its input pins and these gates, which is what lets it also turn all four switches off.
One control line per side. The upper switch turns on when its gate is LOW and the lower when it is HIGH, so exactly one of each pair conducts.
Activity11.2.3.Four settings, four things the motor can do.
The two control lines give four combinations, and each does something different to the motor. Call the motorโs terminals OUT1 (left) and OUT2 (right), and recall that a control line (IN1 or IN2) HIGH pulls its terminal down to ground and LOW pulls it up to the supply: the lower switch on a side turns on when its gate is HIGH, and the upper switch turns on when its gate is LOW.
Two of the four combinations of (IN1, IN2) send current through the motor. Which two, and which switches conduct in each? For one of them, trace the path from the supply, through the motor, to ground. Which way does the current cross the motor?
The other two combinations set both terminals to the same place: both down to ground, or both up to the supply. In each case, how much voltage is across the motor, and so how much current does the supply push through it?
Take the case where both terminals are tied to ground, and suppose the shaft is still spinning when you do it. The motor is then a generator with its two terminals wired together. Using the back-EMF from the motor equations, what current flows, and what does it do to the rotation? Does it matter whether you tie both terminals to ground or both to the supply?
Call the motorโs terminals OUT1 (left) and OUT2 (right). A control line HIGH turns on the lower switch on its side and pulls its terminal down to ground; LOW turns on the upper switch and pulls it up to the supply.
The two combinations where the control lines differ. Current crosses the motor one way, then the other.
Figure11.2.12.The two driving diagonals. On the left, the upper-left and lower-right switches conduct, so current flows from the supply through OUT1, through the motor, and back through OUT2 to ground, one direction of rotation. On the right, the other diagonal conducts, and the current, and the rotation, are reversed.
The braking case and the case where the motor is simply let go are worth separating, because they look the same on a truth table and feel completely different on a real motor.
On the left, braking: the two terminals are shorted, so the back-EMF drives a current that opposes the rotation. The loop is dashed and carries no arrow because which way that current runs depends on which way the shaft was turning. On the right, stopping: all four switches are off, the terminals are left floating, and the shaft coasts.
Figure11.2.14.Braking, on the left, against stopping, on the right. To brake, the two lower switches conduct, so both motor terminals are tied together at ground and the spinning motorโs own back-EMF drives a current through that short, which opposes the rotation and brings the shaft quickly to rest. That loop is drawn dashed and without an arrow on purpose: which way the current runs depends on which way the shaft happened to be turning, and either way it is driven to ground through the lower switches and opposes the rotation. To stop, all four switches are off, so both terminals are left floating: no current can flow in or out, nothing opposes the rotation, and the shaft coasts down under friction alone. This all-off state is one the driverโs control logic produces; it is not something the two direction lines could ask for by themselves, which is why the modes are read from the datasheetโs table rather than from the bridge drawing.
So there are two different ways to stop a motor, and which one we choose is a design decision. Braking dissipates the shaftโs kinetic energy in the motorโs own windings and stops it in a fraction of the time. Stopping (the datasheet calls it stop, and it is what the bridge does when all four switches are off) leaves the shaft free and lets it coast. A wheel that must hold position wants the brake; a flywheel that should spin down gently wants the coast.
One combination is dangerous: the upper and lower switch on the same side conducting at once, which the two control lines cannot ask for. That connects the supply straight to ground through the two switches, with only their own resistance to limit the current, a near short called shoot-through, which can destroy them. The control lines make it impossible to command, because one line drives both gates of a side in opposite senses. It happens in the transitions instead: a real transistor takes time to turn off, so if one begins conducting before its partner has finished turning off, both are briefly on together. Reversing the motor is exactly when that is most likely, because both sides switch at once.
The TB6612 contains logic that staggers its switching so every transition passes through a brief state with one side fully off, one reason we drive a motor through a driver IC instead of wiring the H-bridge by hand.
If we allowed the upper and lower switch on the same side to conduct at once this would short the motor supply straight to ground, with only the transistorsโ own resistance to limit the current.
But it could happens in the transitions instead: a transistor takes time to turn off, so one can still be conducting as its partner turns on. Reversing the motor is when both sides switch at once, so it is the most likely moment.
This is one reason we drive a motor through a driver IC instead of wiring the bridge by hand.
Figure11.2.16.Shoot-through. The upper and lower switch on the right-hand side are conducting at the same time, so current runs straight from the motor supply VM to ground without passing through the motor at all. Nothing in that path limits the current except the resistance of the two transistors, which is why the state destroys them.