Figure 3 shows
one way to configure
two single pole double
throw (SPDT) relays to
control a motor (both
relay modules in
Figure 2 use SPDT
relays). This
configuration is called
an H-bridge, and
allows the motor to go
forward when one
relay is triggered, and
reverse when the other
is triggered. The two diodes in red allow stopping by either coasting or braking.
Coasting switches the motor off to slow down gradually. Dynamic braking stops
the motor quickly by switching the motor leads together (very handy to avoid
overshoot and/or to stop on a dime).
You can see the difference between coasting and braking at www.youtube.
com/watch?v=n9PWwmQJfIs. You could easily make two relay H-bridges from a four-relay module, and your PICAXE’s four output pins could control the robot chassis
shown back in Figure 1.
Transistors and MOSFETs are modern solid-state alternatives to electromechanical
relays. They have the advantage of offering motor speed control since the PICAXE can
rapidly switch them on and off using Pulse Width
Modulation, or PWM. There is usually some voltage
drop through a transistor or MOSFET, compared to
little or no voltage drop through a relay. I won’t
delve into transistor/MOSFET selection here, other
than to say that TIP31s and IRF510s are pretty good
parts to start experimenting with when you are so
inclined.
A single relay or transistor is fine for spinning a
motor in one direction, but when you need to
reverse it, things get more complicated. The right
side of Figure 4 shows a four-transistor H-bridge,
required for forward and reverse. H-bridges also
come as modules now which simplifies things. Notice
that there are two inputs to an H-bridge: make one
input high (and the other low) for forward, and vice-versa for reverse. However, it’s game over if you
make both inputs high simultaneously. You get a pair
of short circuits from V+ to ground which
generate smoke and destroy driver
transistors. Wiki “H-bridge” to read about
“shoot-through,” and avoid it at all costs.
You’ll get your chance later building and
programming RoboCar.
There are several affordable H-bridge
modules to pick from. Figure 5 shows an
800 mA L9110S (left) and a 2A L298N
(right). Both cost under $5 and have two
separate H-bridges, suitable for driving two
motors. The L298N offers dynamic braking
as shown in the previously mentioned video.
46 SERVO 12.2015
Figure 3.
Figure 6.
Figure 4.
Figure 5.