Page 178 - Making things move_ DIY mechanisms for inventors, hobbyists, and artists
P. 178
156 Making Things Move
7. Connect pin 1 of the H-bridge to this 5V power column. This is the enable pin,
which means it needs to be powered to tell the H-bridge chip you’re ready to go.
Connect pin 16 to this power column to give the circuit inside the chip power.
8. It’s always a good idea to use separate power supplies for the motor and the
control logic parts of circuits. Chips like the H-bridge we’re using always want
5V, but motors usually want something different. Connect your motor battery
(a 9V in this example) to the power and ground columns on the left side of
the breadboard. This H-bridge chip will allow you to run motors that need up
to 1A of current, which should be good for most of the motors we’ll talk
about in this book.
9. Even though motor power and control power come from different places, the
ground columns should still be linked so they share a common zero point. You
can do this on your breadboard by using a long jumper to link the two ground
columns across the top of the board.
10. Connect pin 8 to the motor power column on the left side of the board.
11. Try to flip the switch from on to off to on, and see how the motor spins. It
should spin clockwise at one extreme, stop in the middle, and then spin
counterclockwise at the other extreme.
At this point, you might be saying, “Whoa, that’s a lot of wires. What’s actually going
on here?” For starters, most IC chips want power and ground like the H-bridge. An
H-bridge will allow current to flow through the motor in one direction when given a
digital on (high or 5V) signal. We’re using a switch in this example to create the on
signal. When you flip the switch to the other extreme, another on signal triggers the
H-bridge to allow current to flow through the motor in the opposite direction.
Speed Control with Pulse-Width Modulation
By now you know how to turn a motor on and off with a switch, but what if you
want to control the speed? Pulse-width modulation (PWM) lets you do this by creating
a duty cycle—the percentage of on time versus off time—that is between 0% and
100% of a given time period (see Figure 6-23).