1 reading relay status values, 2 setting relay values, 3 cr200(x) programming – Campbell Scientific LR4 Four Channel Latching Relay Module User Manual

Page 13

Advertising
background image

LR4 Four Channel Latching Relay Module

7.4 SDI-12 Programming Examples for CRBasic Datalogger

The following CRBasic examples can be used with the CR800, CR850,
CR1000, CR3000, and CR5000.

7.4.1 Reading Relay Status Values

The SDI-12 “M” commands can be used to read the status of the LR4 relays.
Alternatively to the SDI-12 “M” commands, the LR4 also supports the “R”
command. The SDI-12 “R” command is available to sensors that can respond
immediately to a measurement request as the LR4 is capable of doing so. This
can be advantageous in reducing the execution time for reading information
back from the LR4.

'Programming line to Read the state of all 4 relays with an M command
SDI12Recorder(RelayReadState(),1,0,"M!",1.0,0)

'Programming line to Read the state of Relay #3 with an M command
SDI12Recorder(RelayState_3,1,0,"M3!",1.0,0)

'Programming line to Read the state of all 4 relays with an R command
SDI12Recorder(RelayReadState(),1,0,"R!",1.0,0)

'Programming line to Read the state of Relay #3 with an R command
SDI12Recorder(RelayState_3,1,0,"R3!",1.0,0)

7.4.2 Setting Relay Values

Relays on the LR4 can only be set in SDI-12 by using extended commands as
follows:

'Set all four relays to the 0 state
SDI12Recorder(SetResult,1,0,"XR;0,0,0,0,0!",1.0,0)

'Set all four relays to the 1 state
SDI12Recorder(SetResult,1,0,"XR;0,1,1,1,1!",1.0,0)

'Set relay #3 to the 0 state
SDI12Recorder(SetResult,1,0,"XR;3,0!",1.0,0)

'Set relay #3 to the 1 state
SDI12Recorder(SetResult,1,0,"XR;3,1!",1.0,0)

7.4.3 CR200(X) Programming

The CR200(X) programming differs from the other CRBasic programming as
follows:

• The channel field does not exist.

• The address field does not exist as the address is placed in the first digit of

the command.

7

Advertising