Skip to content

Relay Control Based on OM-310 Fault

This example describes a program that in the event of fault of the OM-310 will turn on the 1st relay on EM-486. In the text 3 – MODBUS ID of the device is OM-310; 240 is the register address which is monitored for the accident.

# enabling relay 1 depending on bit 0 of register 240 of device 3
!META
#9th version of Protocol
* PROTOCOLVERSION 9
# program run will be fulfilled every 3 seconds
* UPDATE 3
# in case of error of the parameter reading, it will be read again 2 times
* PARAMRETRIES 2
# limit of response waiting for MODBUS query is 1000 msec = 1 sec
* PARAMTIMEOUT 1000
# after each query the delay is added, equal to the response waiting time,
# so the other clients can perform their queries
* PARAMLOADRATIO 50
!DEVICES
# EM-486 can read and record no less than 120 registers per one query
# note the second character * - it is MODBUS ID of the EM-486 device
* * WRHANY 120 120
# OM-310 has MODBUS ID equal to 3 and allows reading 4 registers per one query,
# but to record only one register per one query
* 3 WRHSINGLE 4
!PARAMS
# during each updating, it is required to read the storage register with address 240,
# from the device with MODBUS ID equal to 3
# UINT16 – means that the 16-bit value and unsigned one (it can't be less than 0)
0 3 UINT16 H 240
!VARS
# copy zero bit of the register 240
# now in the variable the parameter value is 240.0
0 PARAMBIT P0 0
!CONDS
# variable V0 is compared with 1, condition is met, if V0 = 1
0 VAREQVAL V0 1
# condition is met, if the previous condition is not fulfilled and vice versa
1 NOT C0
!ACTS
# enable the first relay, the second parameter is the number of the relay
0 RELAYON 1 1
# disable the first relay
1 RELAYOFF 1 1
!REACTS
# if C0 condition is fulfilled (if 240.0 = 1), then hold the relay 1 enabled
* C0 REPEAT A0
# if C1 condition is fulfilled (if 240.0 is not equal to 1), then the relay 1 is disabled
* C1 REPEAT A1
# END - a comment at the end of the file, or an empty line, for correct reading