Subsection11.2.4Part 4: First Exercise, Direction by Hand
Now we wire the driver and a motor and drive it directly, with no program yet, so that the modes in the truth table become things you have seen the motor do. The motor needs its own current path and more than the 3.3 V logic can give, so it runs from a separate supply. A 6–12 V wall adapter plugs into the barrel connector of a small regulator board; on that board a regulator brings the input down to a steady 5 V and brings it out on a header, and we feed that 5 V to the motor driver’s VM pin, which is the motor supply. The driver’s logic side, VCC, on the other hand runs from the Nucleo’s 3.3 V.
Figure11.2.21.The regulator board that supplies the motor, seen close up. The barrel connector at the bottom takes the 6–12 V wall adapter; the regulator is the black component in the middle, with C1 and C2 below it, one either side of its center lead; and each of the two headers at the top brings out three pins, labeled 5V, GND and Vin. Take the motor supply from the 5V pin. The Vin pin is the raw, unregulated input from the adapter, and wiring it to VM would drive the motor at up to 12 V rather than its rated 3–6 V.
The motor needs its own current path, and more than the 3.3 V logic rail can give. So it runs from a separate supply, and not from the Nucleo. We use the voltage regulator shown on the right.
A 6–12 V wall adapter plugs into the barrel connector; the regulator brings that down to a steady 5 V and brings it out on a header (pin labeled 5V at the top).
We feed that 5 V to the motor driver’s VM pin, which is the motor supply. The driver’s logic side, VCC, on the other hand runs from the Nucleo’s 3.3 V.
Two supplies, one ground: 5 V for the motor, 3.3 V for the logic.
The 5 V motor supply and the 3.3 V logic supply share a common ground (one wire joins the regulator board’s GND to the Nucleo’s ground) but are otherwise separate. That separation is crucial to get right: the motor is supplied from the 5 V output of the voltage regulator, the logic pins from the Nucleo. All 5 V wires need to stay on the motor side and never touch the 3.3 V rail. That way a mistake on the motor side stays on the motor side and does not reach the 3.3 V parts of the board.
Figure11.2.22.The circuit for the first exercise. The TB6612 breakout takes the regulated 5 V at VM, the Nucleo’s 3.3 V at VCC, and a ground shared with the Nucleo; the motor connects to the two channel-A outputs. The 0.22 µF capacitor across the breakout’s logic supply is a smoothing capacitor: it sits between VCC and ground and holds that rail steady when the motor’s switching disturbs it. For this exercise the PWM pin is held HIGH and the two direction wires, AIN1 and AIN2, are left unconnected, so that you can move them by hand between the power and ground rails.
Disconnect all power while you wire this up (no USB, no adapter), and have your wiring checked before you apply power. The two supplies share a ground and are otherwise separate: every 5 V wire stays on the motor side and never touches the 3.3 V rail. After the wiring check, connect USB first for the 3.3 V logic, then connect the wall adapter for the motor’s 5 V.
Here is the truth table again, to work from while you wire and test.
Activity11.2.5.Drive the motor’s direction by hand.
Disconnect all power while you build the circuit (no USB, no adapter), have your wiring checked by an instructor before you apply power, and then work through the settings by hand. Keep the “H-SW Control Function” table in front of you.
With everything unpowered, wire it up as in the image above, paying special attention to the regulator’s 5 V only going to the motor driver’s VM pin whereas the motor driver’s VCC is supplied by the Nucleo’s 3.3 V. The regulator and the Nucleo share a common ground. Connect the motor to the two channel-A outputs of the motor driver. Tie the PWM pin HIGH, to the 3.3 V rail, and leave the AIN1 and AIN2 wires dangling free for now.
You will move AIN1 and AIN2 between the 3.3 V rail (call it “+”) and ground (“−”). Using the truth table, predict for each of the four settings of (AIN1, AIN2), (+, +), (+, −), (−, +) and (−, −), both what the motor will do and what voltages you would measure at the two motor terminals. Write all four predictions down before applying power.
Once your wiring has been checked, power the circuit: first connect the Nucleo to your computer over USB for the 3.3 V logic, so that the driver’s logic side is running, and then plug the wall adapter into the regulator board for the motor’s 5 V. Then move the AIN1 and AIN2 wires through all four settings. Does the motor do what you predicted each time? If the motor does nothing in any of the four settings, check that the regulator’s 5 V actually reaches VM before checking the individual wires; if a single setting is wrong, check that one wire against the truth table.
Confirm the other half of your prediction. Put oscilloscope channel 1 (the orange lead) on one motor terminal and channel 2 (the blue lead) on the other, with both ground leads on the board’s ground, so that you see both terminals at once. Measure them for the two turning settings, for (+, +) and for (−, −). Do the measurements match the OUT1 and OUT2 columns of the truth table? One of the four settings behaves differently from the others when you measure it: which, and can you say from your measurement what “OFF (High impedance)” looks like on a scope?
Two of the settings stop a spinning motor, and we reasoned that they stop it in very different ways. Get the motor up to speed in one direction, then switch to (+, +) and watch how long the shaft takes to come to rest; get it up to speed again and switch to (−, −) instead. Which stops it faster, and does that match what you predicted about braking against coasting?
One caution about the direction names. The truth table calls its two turning modes CW and CCW, but the chip has no way of knowing which way round you connected the motor’s two wires, so the direction you actually see may be the opposite of the one the table names. That is not a fault, and if it bothers you, swapping the motor’s two wires swaps which mode turns it which way.