Professional Documents
Culture Documents
2 Motor Driver
The most common method to drive DC motors in two directions under control of a
controller is with an H-bridge motor driver. H-bridges can be built from scratch with bi-polar
junction transistors (BJT) or with field effect transistors (FET), or can be purchased as an
integrated unit in a single integrated circuit package such as the L293. The L293 is simplest and
inexpensive for low current motors, For high current motors, it is less expensive to build your
own H-bridge from scratch.
The L293 is an integrated circuit motor driver that can be used for simultaneous, bi-
directional control of two small motors. The L293 is limited to 600 mA, but in reality can only
handle much small currents unless you have done some serious heat sinking to keep the case
temperature down. Unsure about whether the L293 will work with your motor? Hook up the
circuit and run your motor while keeping your finger on the chip. If it gets too hot to touch, you
can't use it with your motor.
The L293 comes in a standard 16-pin, dual-in line integrated circuit package. There is an
L293 and an L293D part number. Pick the "D" version because it has built in fly back diodes to
minimize inductive voltage spikes. The pin out for the L293 in the 16-pin package is shown
below in top view. Pin 1 is at the top left when the notch in the package faces up. Note that the
names for pin functions may be slightly different than what is shown in the following diagrams.
Assume you have only one motor connected with the enable tied to Stamp Pin 0, and the two
direction controls tied to Stamp Pins 1 and 2. Here is a table describing the control pin functions.
For the purposes of this article, I'm focusing on a basic H-bridge that is a good choice for most
robots and portable gadgets. This H-bridge can operate from a power source as low as two
nearly-exhausted 'AAA' batteries (2.2V) all the way up to a fresh 9V battery (9.6V).
The H-bridge circuit (below) looks complicated at first glance, but it is really just four copies of
a resistor + transistor + diode.
Schematic of a bipolar transistor hbridge circuit to drive a DC motor. Can you see the letter 'H'?
There are many different ways to draw the circuitry, but the above wiring diagram matches the
model of most h-bridges.
Q1, Q3: These are NPN transistors. They connect the motor to ground (negative terminal
of the battery).
Q2, Q4: These are PNP transistors. They connect the motor to +2.2V to +9.6V (positive
terminal of the battery).
R1-R4: These resistors prevent too much current from passing through the base (labeled
B) control pin of the transistor. The resistor value of 1 kilohm (1000 ohms) was chosen to
provide enough current to fully turn on (saturate) the transistor. A higher resistance would
waste less power, but might cause the motor to receive less power. A lower resistance
would waste more power, but wouldn't likely provide better performance for motors
running on consumer batteries.
D1-D4: Diodes provide a safe path for the motor energy to be dispersed or returned to the
battery when the motor is commanded to coast or stop. I notice many H-bridge circuits on
the web lack these diodes. I suppose that's safe enough for light loads at low voltages, but
without diodes, a motor voltage spike can force its way through the unprotected
transistors, damaging or destroying them.
M1: This is a direct-current (DC) motor. These are very common. You can find them in
surplus stores online or in salvaged toys. The motor should have only two wires. Measure
the resistance of the two motor wires using a multimeter. If it is much less than 5 ohms,
then the transistor parts listed in this article are too weak to power the motor.
Command R1 R2 R3 R4
GND or +VDC or
Forward: disconnec GND +VDC disconnec
ted ted
+VDC or GND or
Reverse: +VDC disconnec disconnec GND
ted ted
+VDC or +VDC or
Brake/Slow
Down:
+VDC disconnec +VDC disconnec
ted ted
Since there are 4 resistors, there are actually sixteen possible ways this circuit can be
commanded. Don't sweat the other variations (they're in the book if you're curious). Except,
Never apply +VDC to R1 and GND to R2 at the same time! You'll short circuit the battery.
Never apply +VDC to R3 and GND to R4 at the same time! You'll short circuit the battery.
3.3 Wireless Module Pair (TX & RX)
These days, the term wireless is very much hyped! Whenever we hear the term wireless,
stuffs like Mobile telecommunication GSM, Wi-Fi, Bluetooth, RF Communication, Wireless
networks, Zigbee, I2C, SPI, DTMF, 802.11b etc. Well, fortunately or unfortunately, all of these
protocols can be interfaced with a microcontroller in one way or the other. But what matters is
the level of complexity. To start off, RF (Radio Frequency) Communication is the most
preferred and low cost solution. All you need is a RF Module (Transmitter-Receiver Pair). Now,
thats not all. RF Communication works on the principle of Serial Communication. Thus, you
need something which converts the conventional n-bit (4-bit, 8-bit, 16-bit, etc) data into serial
data. For this, we have two choices:
Use a microcontroller to convert the n-bit data into serial data and vice-versa
3.3.2 RF Module
RF Modules are used wireless transfer data. This makes them most suitable for remote
control applications, as in where you need to control some machines or robots without getting in
touch with them (may be due to various reasons like safety, etc). Now depending upon the type
of application, the RF module is chosen. For short range wireless control applications, an ASK
RF Transmitter-Receiver Module of frequency 315 MHz or 433 MHz is most suitable.
Pin Description:
Features:
RX IF Frequency : 1MHz
RX Operating Voltage : 5V
TX Supply Voltage : 3V ~ 6V
This has single channel for data transfer, thus serial data communication is used. Its required to
have an antenna for signal transmission. Usually, a 20-30 cm wire serves best. It is sufficient to
give a range of 80 meters in open region. To improve the efficiency, you can also use a coiled
wire (take a wire and make it into a coil). It increases the signal strength.
The relay driver is used to drive the relay that is used in the circuit. The relay act similar
to the hook switch in the normal phone. When then line is in idle mode, the relay will be in OFF
state which is similar to the ON-Hook in the Phones. In On-hook state, through the relay path the
telephone line is connected to the ring indicator circuit. When a ring occurs, the ring indicator
will interrupt the controller and the controller will send a signal to the relay driver, for driving
the relay. The driving of the relay to the ON state will change the device to the OFF-hook state
and the call will be connected.
If the coil is energized with DC, a diode is frequently installed across the coil, to dissipate
the energy from the collapsing magnetic field at deactivation, which would otherwise generate a
voltage spike dangerous to circuit components. Some automotive relays already include a diode
inside the relay case. Alternatively a contact protection network, consisting of a capacitor and
resistor in series, may absorb the surge. If the coil is designed to be energized with AC, a small
copper ring can be crimped to the end of the solenoid. This "shading ring" creates a small out-of-
phase current, which increases the minimum pull on the armature during the AC cycle.
5.3 Relay Driver
The system contains 2 relays for controlling the phase and neutral lines. The relay driver
circuit is designed by using 2 NPN transistors 2N2222. When the port PIN is high, the transistor
T1 & T3 will be in ON state, lead the energizing of the relay coil. Since the relay contains an
inductor part, switching ON/OFF will generated a back emf across it and it can spoil the
transistor. For protecting it from the back emf, a fly back diode is connected in reverse bias
across the relays coil.