Digital Outputs and Relays
Digital Outputs and Relays
Digital Outputs and Relays
Many control tasks require only a binary type of output, i.e. turning on or
off a switch, light, motor or other device. Examples would be turning on or off a
conveyor, a gas valve to your furnace, a fan or pump. You can think of many
more, I'm sure.
Digital Outputs
The DAQ board has 32 digital IO lines, of which 16 are configured as
digital outputs, and 16 as digital inputs.
The Matlab command line for digital output is called “digital_out”, and it takes two
input argument, the channel, which can assume values from 1 to 16 and the
value, which can be either 1 (High) or 0 (Low).
Try “help digital_out” from the Matlab command line and look for yourself.
The first 8 outputs are connected to both the relays and the red LEDs on the
side. By giving 1 as a value to a certain channel (from 1 to 8), the LED lights up
and current flows into the corresponding relay, therefore switching the relay on.
But what does it exactly mean “to switch a relay on” ?, Read on.
Relays
The digital outputs of the DAQ are capable of sourcing only about 32 mA
each. Many digital outputs can provide even less current to drive external
devices. That current is not enough to drive Lego motors, let alone turning your
air conditioner on/off or controlling a conveyor in a robotic workcell.
The relay schematic in Figure L4.1 is one of the simplest; it has only four
terminals and is called Normally Open (NO), Single Pole Single Throw (SPST).
The term “Pole” stands for “Switching Circuit”, which in this case is only one.
Single Throw means that the internal switch has only one contact on one side of
the common pole.
Regarding the number of poles and throws, relays (as well as switches in
general), can be of the following types, as described in the next figure:
SPST - Single Pole Single Throw. These have two terminals which can be
switched on/off. In total, four terminals when the coil is also included.
SPDT - Single Pole Double Throw. These have one row of three
terminals. One terminal (common) switches between the other two poles. It is the
same as a single change-over switch. In total, five terminals when the coil is also
included.
DPST - Double Pole Single Throw. These have two pairs of terminals.
Equivalent to two SPST switches or relays actuated by a single coil. In total, six
terminals when the coil is also included. This configuration may also be referred
to as DPNO.
DPDT - Double Pole Double Throw. These have two rows of change-over
terminals. Equivalent to two SPDT switches or relays actuated by a single coil. In
total, eight terminals when the coil is also included.
NO
Coil Coil
SPST SPDT
NC
NO
NC
Coil NO
DPDT
Coil
DPST
The following Figure shows the inside of the above electromechanical relay:
This relay is shown in the Normally Closed (NC) position, i.e. there is no
current supplied to the relay coil. A separate power source connected to the
Common (C) terminal would supply power to a load connected to the NC
terminal. If a small current is sent through the coil, it creates an electromagnet,
which attracts the “common” terminal down, connecting (C) with Normally Open
(NO). Power would then be removed from the load on the NC terminal and
applied to the NO terminal. The contacts of this relay can carry up to 30 Amps of
current and can switch a 2 hp motor on and off. The coil operates on 12 VDC
and requires only a few tenths of an Amp to operate. When the coil current is
removed, the spring on top of the relay pulls the common conductor back up so
the connection between C and NC is re-established.
4 5
3 6
2 7
1 8
The pin numbers are as seen from the bottom of the relay and are marked
on the base of the relay. The socket (right) has numbers by each of the screw
terminals that correspond to the relay pin numbers, making connections easy for
those with eyes good enough to see the tiny little buggers. Note that the relay is
"keyed" so it only fits in the socket one way.
Terminal 1 on the relay socket is connected to the little circle marked 1 on
the relay schematic above—the common terminal for pole 1. Screw terminal 4 is
connected to the NC terminal of pole 1 and screw terminal 3 is connected to the
NO terminal of pole 1. Screw terminals 2 and 7 connect to the relay coil. Putting
12V across pins 2 and 7 causes the relay to switch from the NC to the NO
position, i.e. pin 1 is now connected to pin 3 and pin 8 is now connected to pin 6.
Even though they are shown backwards here, both poles switch at the same
time.
You are not expected to understand the above circuit, but note that the two sides
of the relay are actually separated from each other, and the switching happens
whenever the light emitted by a diode on the left side hits the phototransistor on
the other side. Both diode and phototransistor are inside the element “TIL 111”.
Construct this system. Trace the connections so you can completely understand
how the logic works.