Switching on a relay for an event


Recommended Posts


I have configured a relay on LabJack and tested it using a push button, however I need it operate using a sequence.

The relay needs to switch on when;

It is 6.00 am and remain on only when the temperature is below 25 deg C

It must then switch off at 6.00 PM irrespective of what the temperature is.

The sequence also needs to toggle a LED to green when the relay is on or to red when it is off.

I know it sounds simple - but what might take me a few weeks to work out might be a snap to you - assistance would be appreciated

Link to comment
Share on other sites

OK, first the easiest part: to create an LED that changes with the relay, just select one of the LED components and enter the relay's channel name as the expression.

As for the control part, I'm assuming you read temperature continuously, even after 6pm. Let's assume the temperature channel is called "temp" and the relay channel is called "relay". In the Event for the temp channel (click on the channel in the workspace under CHANNELS: and select the Event tab), the script would look something like this:

if ((systime() > 6h) && (systime() < 18h))
   relay = temp[0] < 25
   relay = 0

Note that this form will send the command continuously every time temperature is read, even if the relay state doesn't change. On a LabJack doing lower speed acquisition, this should not be an issue.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.