« Close

Datasheets and User Guides

App Notes

Software & Driver

 

2.8.1.4 - Output: Controlling Relays

All the digital I/O lines have series resistance that restricts the amount of current they can sink or source, but solid-state relays (SSRs) can usually be controlled directly by the digital I/O. The SSR is connected as shown in the following diagram, where VS (~5 volts) connects to the positive control input and the digital I/O line connects to the negative control input (sinking configuration).

Figure 2.8.1.4-1. Relay Connections (Sinking Control, High-Side Load Switching)

When the digital line is set to output-low, control current flows and the relay turns on. When the digital line is set to input, control current does not flow and the relay turns off. When the digital line is set to output-high, some current flows, but whether the relay is on or off depends on the specifications of a particular relay. It is recommended to only use output-low and input.

For example, the Series 1 (D12/D24) or Series T (TD12/TD24) relays from Crydom specify a max turn-on of 3.0 volts, a min turn-off of 1.0 volts, and a nominal input impedance of 1500 Ω.

  • When the digital line is set to output-low, it is the equivalent of a ground connection with 180 Ω (EIO/CIO/MIO) or 550 Ω (FIO) in series. When using an EIO/CIO/MIO line, the resulting voltage across the control inputs of the relay will be about 5*1500/(1500+180) = 4.5 volts (the other 0.5 volts is dropped across the internal resistance of the EIO/CIO/MIO line). With an FIO line the voltage across the inputs of the relay will be about 5*1500/(1500+550) = 3.7 volts (the other 1.3 volts are dropped across the internal resistance of the FIO line). Both of these are well above the 3.0 volt threshold for the relay, so it will turn on.
  • When the digital line is set to input, it is the equivalent of a 3.3 volt connection with 100 kΩ in series. The resulting voltage across the control inputs of the relay will be close to zero, as virtually all of the 1.7 volt difference (between VS and 3.3) is dropped across the internal 100 kΩ resistance. This is well below the 1.0 volt threshold for the relay, so it will turn off.
  • When the digital line is set to output-high, it is the equivalent of a 3.3 volt connection with 180 Ω (EIO/CIO/MIO) or 550 Ω (FIO) in series. When using an EIO/CIO/MIO line, the resulting voltage across the control inputs of the relay will be about 1.7*1500/(1500+180) = 1.5 volts. With an FIO line the voltage across the inputs of the relay will be about 1.7*1500/(1500+550) = 1.2 volts. Both of these in the 1.0-3.0 volt region that is not defined for these example relays, so the resulting state is unknown.

Mechanical relays require more control current than SSRs, and cannot be controlled directly by the digital I/O on the U6. To control higher currents with the digital I/O, some sort of buffer is used. Some options are a discrete transistor (e.g. 2N2222), a specific chip (e.g. ULN2003), or an op-amp.

Note that the U6 DACs can source enough current to control almost any SSR and even some mechanical relays, and thus can be a convenient way to control 1 or 2 relays.

The RB12 relay board is a useful accessory available from LabJack. This board connects to the DB15 connector on the U6 and accepts up to 12 industry standard I/O modules (designed for Opto22 G4 modules and similar).

Another accessory available from LabJack is the LJTick-RelayDriver. This is a two channel module that plugs into the U6 screw-terminals, and allows two digital lines to each hold off up to 50 volts and sink up to 200 mA. This allows control of virtually any solid-state or mechanical relay.

4 comments

You say that it is best to use output-low and input to control a SSR.

I am using DAQFactory and have set a digital out channel.  I can change this by setting the channel to 0 or 1, but as you say my low voltage is around 1.5 volt.

Would you give an example of how to change from output-low and input and back.

 

To find out if there is an easy way to change between input and output-low in DAQFactory, post on the AzeoTech forum.  For a quick workaround, use an analog output (DACx) rather than a digital I/O.

I am using an FIO.  Looking on the AzeoTech forum I found this question posted by NEWBIE in 2009:

[Hello,

I am trying to short two wires using my U3. And according to the Labjack folks, I would need to plug one of my wires to Ground and the other one to one of the digital I/O pins (i.e.: FIO0). Now, the FIO0 should be set as an input and when I want to short them, I should configure that port as output-low. How do I go about changing that?

I will need to be going back and forth with it:

If(x=1)
//set FIO0 as output-low
else
//set FIO0 as input

Much Thanks!

]

 

The answer was:

"You actually should ask LabJack this question. DAQFactory pretty much duplicates the format of the UD in script, so they should easily be able to help you, and since this is a hardware question, they would do a better job than us."

 

If this is what YOU suggest, then YOU should be able to answer.  If you answer as if for the UD script, I should be able to figure out the rest.

The technique of defining a DAQFactory "Channel" with I/O type "Dig Out", and then simply doing channelname=0 or channelname=1, is what I would call a DF shortcut and is what I meant by an "easy way".  See Section 7.1 of the DF-LJ App Guide.  When I suggested asking at their forum, the idea was to see if there is a DF shortcut way to toggle a line between input and output-low, or if you just need to use basic UD calls through script.

If the latter, first get an understanding of the UD driver from Section 4 of the U3 User's Guide, and specifically look at the digital I/O information in Section 4.3.5.  Then look at Sections 6 & 8 of the DF-LJ App Guide about scripting.  I would start with the example EI1050 U3.ctl.  You can delete various things from the example including the sequence "GetReading".  Change the "Setup" sequence to Auto-Start=TRUE, and just leave in 1 command to set FIO0 to input:

 

//Set FIO0 to input to start.
err = ePut (ID, LJ_ioGET_DIGITAL_BIT, 0, 0, 0)
eErrorHandler(err, 0, LJ_ioPUT_DIGITAL_BIT)

 

Then use that same command in any other sequence when you want to set FIO0 to input.  If you want to set it to output-low, use something like:

//Set FIO0 to output-low.
err = ePut (ID, LJ_ioPUT_DIGITAL_BIT, 0, 0, 0)
eErrorHandler(err, 0, LJ_ioPUT_DIGITAL_BIT)