MBSlaveRTU

Function Block - MODBUS RTU Slave protocol on serial port.

Inputs

IN : BOOL      Enabling command: the port is open when this input is TRUE
PORT : STRING  Settings string for the serial port (e.g. 'COM1:9600,N,8,1')
SLV : DINT     MODBUS slave number

Outputs

Q : BOOL      TRUE if the port is successfully open

Remarks

When active, this function block manages the MODBUS RTU Slave protocol on the specified serial communication port. The configuration of the MODBUS Slave map (designing MODBUS addresses) is done using the MODBUS configuration tool, from the Fieldbus Configurator.

There can be several instances of the MBSlaveRTU working simultaneously on different serial ports. Other MODBUS Slave connections (TCP server, UDP) can also be active at the same time.

The slave number entered in the MODBUS Slave configuration tool is ignored when MODBUS Slave protocol is handled by this function block. Instead, the SLV input specifies the MODBUS slave number.

ST Language

(* MySlave is a declared instance of MBSlaveRTU function block *)
MySlave (IN, PORT, SLV);
Q := MySlave.Q;

FBD Language

LD Language

IL Language:

(* MySlave is a declared instance of MBSlaveRTU function block *)
Op1: CAL    MySlave (IN, PORT, SLV)
     LD     MySlave.Q
     ST     Q
     LD     MyCounter.CV
     ST     CV

See also

MBSlaveUDP   MODBUS configuration