9.2.1.2 Example
With Function code 03h, starting from address 2000, 100 register are to be read from a
Modbus RTU slave with address 99 and stored in flag area starting from MB200. Errors
are to be stored. The Modbus RTU master is realized via the internal serial RS485 inter-
face of a VIPA CPU.
CALL SFC 216
Protocol :=B#16#5
Parameter :=DB10
Baudrate:=B#16#9
CharLen:=B#16#3
Parity:=B#16#2
StopBits:=B#16#1
FlowControl:=B#16#1
RetVal:=MW100
1. Calling of the SFC 216 (SER_CFG) to configure the internal serial interface of the
CPU from VIPA.
2. Protocol: "Modbus Master RTU", 9600 baud, 8 data bit, 1 stop bit, even parity, no
flow control.
3. DB10 has a variable of type WORD with a Modbus time-out (value in ms).
CALL FB 72 , DB72
REQ :=M101.0
HARDWARE :=B#16#2
LADDR :=
MB_UNIT_ID :=B#16#63
MB_FUNCTION :=B#16#3
MB_DATA_ADDR:=W#16#7D0
MB_DATA_LEN :=100
MB_DATA_PTR :=P#M 200.0 BYTE 200
DONE :=M101.1
BUSY :=
ERROR :=M101.2
STATUS :=MW102
UN M 101.2
SPB ERR1
L MW 102
T MW 104
ERR1: NOP 0
U M 101.1
R M 101.0
1. Calling the handling block of the Modbus RTU master with the correct parameters.
2. If the interface was correctly initialized in the OB 100, the master can be used and
MW102 returns 7004h.
Task
OB100
OB100 - Description
OB1
OB1 - Description
VIPA SPEED7
Modbus Communication
RTU > FB 72 - RTU_MB_MASTER - Modbus RTU master
HB00 | OPL_SP7 | Operation list | en | 18-30 192