Computer Control: Relays and Computer Controlled Switching

If you are new to the idea of computer controlled switching, then this introduction to relays  and relay controllers will teach you all you need to know!

A relay is best defined as a switch that is operated by an electromagnet.  A relay controller is a device that is used to control a bank of switches.  A relay controller works by turning on and off magnetic coils under logic control.  A computer controlled relay driver allows your computer to send simple commands to activate a switch or a group of switches.

Relays are ideally suited for controlling everything from lights and motors to telecommunication, audio, and video signals.  Some relays can be used for switching radio frequency signals.  Relays come in many sizes and ratings.  There are literally tens of thousands of relay varieties on the market.

NCD relay controllers allow you to switch electrical equipment from a computer via RS232, USB, or Wireless communications.  There are many advantages to using a computer controlled relay controller.  When the controlling computer is connected to the internet, relays can be controlled from anywhere in the world.

Internet controlled relay switching allows a local computer or a remote computer to activate a relay.  Wireless relays have one additional advantage: wireless sensors can be used to automatically activate a relay without computer intervention.

Relays typically have two or three connections: Common, Normally Open, and Normally Closed.   The Common is the part of the relay that actually makes a mechanical movement.  By default, many relays have their common (COM) lead connected to the normally closed lead (NC).  When the electromagnet is energized, the COM disconnects from the NC and reconnects to the Normally Open lead (NO).  When the relay is deactivated, the COM reconnects to the NC (see diagrams at right).

Relays often have two ratings: AC and DC.  These rating indicate how much power can be switched through the relays.  This does not necessarily tell you what the limits of the relay are.  For instance, a 5 Amp relay rated at 125VAC can also switch 2.5 Amps at 250VAC.  Similarly, a 5 Amp relay rated at 24VDC can switch 2.5 Amps at 48VDC, or even 10 Amps at 12VDC.

An easy way to determine the limit of a relay is to multiply the rated Volts times the rated Amps.  This will give you the total watts a relay can switch.  Every relay will have two ratings: AC and DC.  You should determine the AC watts and the DC watts, and never exceed these ratings.

Relays are often rated for switching resistive loads.  Inductive loads can be very hard on the contacts of a relay.  A resistive load is a device that stays electrically quiet when powered up, such as an incandescent light bulb.  An inductive load typically has a violent startup voltage or amperage requirement, such as a motor or a transformer.

Inductive loads typically require 2-3 times the runtime voltage or amperage when power is first applied to the device.  For instance, a motor rate at 5 Amps, 125 VAC will often require 10-15 amps just to get the shaft of the motor in motion.  Once in motion, the the motor may consume no more than 5 amps.  When driving these types of loads, choose a relay that exceeds the initial requirement of the motor.  In this case, a 20-30 Amp relay should be used for best relay life.

Relays Come in Many Varieties, the most Common Relay Varieties Include:

SPST Single Pole Single Throw Relays simply connect two wires together.  The COMMON is the moving part of the relay that comes in contact with the Normally Open when the coil to the relay is energized.

This kind of relay is often available in a normally closed configuration if needed..

SPDT Single Pole Double Throw Relays have three connections.  Common, Normally Open, and Normally Closed.  When the relay is off, the common is connected to the normally closed connection of the relay.  When the relay coil is energized, the Common swings over to the Normally Open Connection of the Relay.

DPST Double Pole Single Throw Relays have two separate switches, activated by a single coil.  By default, the Common connections are not connected to anything.  When the relay coil is energized, both Common Arms move to the Normally Open Connections.

This kind of relay is often available in a normally closed configuration if needed.

DPDT Double Pole Double Throw Relays have a single coil with two arms that move at the same time.  There are two completely separate SPDT switch mechanisms inside a DPDT relay.  DPDT relays are most commonly used for signal switching applications, but can be found in high power switching applications.

AC Volts x AC Amps = AC Watts DC Volts x DC Amps = DC Watts
Since a relay is just a switch, it is very easy to wire up a relay to control just about any kind of electrical device.  Relays are unmatched in their versatility; offering fast response times, long life, and very low on resistance.  In the connection diagram below, relays are used to control a motor.  These connections are similar to the connections found on NCD relay controllers, whereby each relay has three points of connection to external electrical equipment.

Left: A simple circuit that turns on a motor when a relay is turned on.

Right:  When relay 1 is activated, the motor spins in reverse.  When relay 2 is activated, the motor spins forward.  When both relays are off, the motor is electrically braked to V+, bringing the motor to an immediate halt.  Activating both relays brings brakes the motor to ground causing an immediate halt, but causes electrical noise on the ground plane that can interfere with surrounding eletronics.

Longevity:  How Long do Relays Last?
The life of a relay is determined by many factors.  The most important variable in the lifespan of a relay is choosing a relay that adequately matches your switching requirements.  Relays can have a mechanical life of 10,000 to 10,000,000 or more on/off cycles.  But the contacts themselves can easily be damaged by choosing a relay that is below the requirements of your switching application.  Build quality tends to be very low on the list of important factors that determine the lifespan of a relay.  Today's relays tend to have an excellent build quality, regardless of manufacturer.  For the purposes of the NCD product line, we warrant our relays for constant use for a period of 5 years.  Meaning you can use the controllers as much as you want for 5 years, if the relay fails, we will replace it.
Speed:  How Fast Can a Relay Switch?
Most of the relays we use in our product line have a close time of about 5ms, and a release time of 10ms.  A close time is the time it takes for the COM to connect the NO.  A release time is the time it takes for the COM to connect to the NC.  Large power relays, rated at 20 Amps or greater usually take a little longer, in most cases, 25-50 ms.  Many of the relays we use are rated at 1,800 closures per minute.  Larger power relays may be rated for less frequent use, but few applications will require such speed.  Our relay controllers are capable of controlling relay signals at speeds that exceed the mechanical reaction speed of the relay, ensuring you will always have the best performance.
Sealed vs. Unsealed Relays
Sealed relays are typically preferred.  In today's relay controllers, we only use sealed relays with the exception of our 1 Amp DPDT series controllers.  Sealed relays are preferred because they have better resistance to dust and moisture.  Sealed relays also have one other property that is not often discussed.  In power relay applications, a relay will typically generate sparks between the contacts.  Relay sparking can be greatly reduced in a sealed relays.  The reason being, the sparking eventually burns up most of the oxygen inside the relay, greatly slowing corrosion on the contacts.
Solid State vs. Mechanical Relays
Both kinds of relays have their advantages and disadvantages.  Mechanical relays have the advantage of being able to switch just about any kind of signal you can throw at it.  They tend to be a little slower and a lot noisier.  Solid state relays on the other hand have the advantage of exceptional switching speed and there are no contacts to corrode, and they are much quieter.  Unfortunately, you must purchase relays for use in AC applications, which are different from solid state relays used in DC applications.  Solid State relays typically require a minimum signal for power switching applications.  They do not function properly if the minimum signal is not present.  In terms of life span, it is automatically assumed that mechanical relays would have a shorter life than solid state relays.  This is not true.  A properly chosen mechanical relay can last just as long as a solid state relays.  Mechanical relays are much more immune to electrical surges and can often outlast similarly rated solid state relays for this reason alone.  Mechanical relays are often available in more configurations, such as SPDT, DPDT, and DPST.  Most solid state relays are only available in SPST configuration.  Solid State relays and mechanical relays alike have the greatest life span when controlling resistive loads.
Extending Relay Life
The life of a relay can be extended in several ways.  One of the best ways to increase relay life is to choose a relay that is 2-3 times more powerful than your rated application.  You can also use capacitors and diodes to help shunt voltage spikes away from relay contacts when controlling inductive loads.  Keeping a relay turned on all the time doesn't necessarily hurt the relay, but does cause electrical wear.  Take advantage of the Normally Closed line if available on your relay.  When possible, wire up your relays so that it can spend most of it's time in the OFF state.
Latching Relays
All NCD relay controllers are latching.  When a command is sent to the controller, the relay is activated.  The relay will stay latched until you send a different command to turn off the relay. 
Communicating to an NCD Relay Controller
Communicating to one of our relay controllers is very easy, even if you have never used our products before.  Most of our products connect to the serial port of your computer (please consult the product manual for complete connection details).  You can use a USB to serial adapter if you do not have a serial port available.  Once connected, all you have to do is send a few simple bytes of data out the serial port to activate/deactivate a relay.  This can be done by either using software that we have developed, or by writing your very own simple programs to communicate to the relay controller.  Different relay controllers have different command sets.  Meaning, you send different bytes of data to do different thing with the different relay controllers we offer.
Your First Computer Controlled Switch
We have developed many resources on our web site that will get you started using our line of relays controllers.  We have also written a number of magazine articles that may be of use to you. Here is a list of important resources on our web site that will help you get started:

Writing Your First Relay Control Program

This guide shows you how to write your first Visual Basic program used for controlling relays.  This simple tutorial shows you every step to take.

Internet Relay Control

This tutorial shows how to use our products via the internet using the telnet Ethernet to serial adapter.

Opening Windows to the World Part II

This Magazine Article published in July 1998 Nuts and Volts Magazine shows how to use our relay controllers with an older version of Visual Basic. Additional articles can be found HERE.

Wireless Relay Controllers

Wireless relay controllers allow you to remotely control electrical devices from a computer up to 3,000 feet away.  This introduction to wireless controllers teaches you the basics.

Hybrid Relay Controller

Hybrid Relay Controllers combine I/O data collection and control functions within a single controller, Allowing you to monitor sensors and react to sensor signals.