WRITE_READ_VAR
: Read and Write Internal Registers on a Modbus Device
This function reads and writes internal registers (MW type only) to an external device in the Modbus protocol. The read and write operations are contained in a single transaction.
The write operation is performed first. The WRITE_READ_VAR
function can then:
write consecutive internal registers and immediately read back their values for verification
write some consecutive internal registers and read others in a single unique request
WRITE_READ_VAR
- Specific Parameter Description
Input |
Type |
Comment |
---|---|---|
|
|
|
|
DINT |
|
|
UINT |
|
|
POINTER TO BYTE |
Pointer address to the array that holds the data which shall be written to the target device. The array must be equal or greater than the data which shall be written. You must use the ADR function to pass the address of the first byte of the array (see CFC chart in the example). |
|
DINT |
|
|
UINT |
|
|
POINTER TO BYTE |
Pointer address to the array that holds the received data which have been read from the target device. The array must be equal or greater than the data which shall be read. You must use the ADR function to pass the address of the first byte of the array (see CFC chart in the example). |
This example shows the implementation of the WRITE_READ_VAR
function block in conjunction with the ADDM
function block in order to write two registers starting at address 11 and to read two registers staring at address 1 of a Modbus slave. The Modbus slave is specified with address 8 and must be reachable through the serial line interface 1. A precondition is the configuration of the Modbus Manager as master under the serial line interface 1.