Subsection11.2.3Part 3: The TB6612 Driver and Its Truth Table
The TB6612 packages two complete H-bridges (the switches themselves and the logic that prevents shoot-through) onto one small breakout board, a circuit board with the chip already soldered down and its pins brought out to header pins we can wire by hand. It exposes each bridge through a few logic-level pins, driven at the ordinary 0 V and 3.3 V logic levels which we will drive via the STM32C031C6.
The motor’s own power does not come through those pins, and this is the whole reason the driver exists. The chip has a separate set of terminals for it: an input pin VM, which we connect to an external supply, and the two output pins that go to the motor. The motor equations give the reason we cannot skip this. A stopped motor draws \(V/R_a\) at the instant it is switched on, which for our motor is hundreds of milliamps, where a GPIO pin can source a few, so the current the motor needs is fetched from the external supply through the driver’s switches, and the microcontroller only ever tells those switches what to do. Each bridge can pass roughly 1.2 A to its motor; draw much more than that and the chip protects itself by shutting down until it cools.
Figure11.2.17.Inside the TB6612: the full chip, which holds two independent motor channels, A and B. We will only use channel A, but if you wanted to control several motors independently you could use both channels for this purpose. Channel A’s three logic inputs are labeled AIN1, AIN2, and PWMA on the breakout (also referred to as IN1, IN2, and PWM below). These pass through the control logic that drives the four switch gates, and the switches connect channel A’s two outputs (AO1, AO2) to the motor supply VM or to ground. The motor’s large current flows only in the output half; the input side is ordinary 3.3 V logic.
Logic inputs at 3.3 V on one side: AIN1, AIN2 and PWMA on the breakout, which the datasheet’s table calls IN1, IN2 and PWM. On the other side the motor’s own supply enters at VM, and each bridge can pass roughly 1.2 A. A stopped motor draws V/R_a at the instant it is switched on, which for our motor is hundreds of milliamps where a GPIO pin can source a few.
The two inputs, IN1 and IN2, choose what the bridge does, which yields the motor direction, and a third, PWM, controls the average voltage at the motor terminals by rapidly switching it on and off for speed control, which we come to next. A fourth pin, STBY (standby), must be HIGH for the driver to do anything at all; on our breakout it is pulled up already. How the inputs map to the four modes (clockwise, counter-clockwise, brake, and stop) can be found in the TB6612FNG datasheet, in the table named “H-SW Control Function” on page 4.
Figure11.2.20.The TB6612 “H-SW Control Function” table, from page 4 of the TB6612FNG datasheet. IN1, IN2, and PWM set the outputs OUT1 and OUT2, and so the mode. “H/L” in a cell means the value in that position does not matter for that row.
Read the mode off the table, not off the bridge drawing. “H/L” in a cell means the value in that position does not matter for that row.
Activity11.2.4.What the table says that the mode names do not.
Work from the “H-SW Control Function” table (Figure 11.2.20), with STBY HIGH throughout, and compare it against what you worked out about the bridge.
Select a direction (say IN1 HIGH and IN2 LOW) and then read the row that with PWM HIGH. What are OUT1 and OUT2 and what mode does the table name it? How does that compare to your earlier prediction?
The table shows both a short brake mode and a stop mode. Find the input combination for each, and read off OUT1 and OUT2. One of them describes the outputs as “OFF (High impedance)”: explain what that phrase means about the four switches, and match the two rows to the two pictures of braking and stopping.