Modbus Client
Purpose
Configure a Modbus client interface of an RT Box
Description
The Modbus Client block configures a Modbus TCP client interface.
A Modbus TCP client communicates with a Modbus TCP server by sending discrete inputs or input registers to the server and requesting the state of coils and holding registers from the server. Discrete inputs and coils consist of single bits and are mapped to boolean signals in PLECS. For input and holding registers, the Modbus protocol supports 16 bit values. The PLECS implementation supports 32 bit values (int32, uint32, float) and 64 bit values (double) by using multiple registers with consecutive addresses.
It is possible to use multiple Modbus client blocks within the same model. Each Modbus client block may connect to any Modbus server on the network. Several Modbus client blocks may connect to the same Modbus server, for example if different update intervals are desired.
Modbus coils and registers with consecutive addresses are sent and queried in single Modbus requests.
The execution of Modbus commands is asynchronous. The current values of discrete inputs and input registers are sent when the block is triggered. The value of coils and holding registers at the outputs of the blocks are updated when new data is received from the Modbus server. The v output is set to 1 in every simulation step where new valid data has been received. If no new data was received it remains 0. Note that there is no guarantee that all outputs are updated in the same simulation step and that the order of updates is undefined.
The status port s provides information on any errors that may have occurred. The following table lists the possible values and their meanings:
Value |
Error description |
|---|---|
0 |
No errors have occured. |
1 |
An error occured during a read operation. |
2 |
An error occured during a write operation. |
3 |
An error occured while trying to connect to the server. |
4 |
An error occured because of an invalid configuration parameter. |
5 |
A network timeout ocurred. |
6 |
A Modbus protocol error occured. |
7 |
The server was disconnected. |
8 |
An unknown error occured. |
9 |
An error occured while parsing the Modbus response. |
Parameters
- Modbus server hostname or IP address
The hostname or IP address of the Modbus server that this client instance communicates with.
- TCP Port
The TCP port of the remote Modbus server (default: 502).
- Execution
Specifies if the block is triggered by an external trigger signal or at regular intervals.
- Trigger interval
The trigger interval, in seconds, at which the block sends new Modbus requests to the server (when Execution is set to regular).
- Trigger type
The direction of the edges of the trigger signal upon which the data is sent, as described above (for triggered execution only).
- Unit identifier
Identifies a remote server connected on a serial line. It is typically used to communicate with a Modbus server through a gateway betwen a TCP/IP network and a Modbus serial line to which multiple servers with different identifiers are connected. For servers connected directly via TCP, it is recommended to be set to 255.
- Inputs, Outputs
Signal specification of the data to be made available via Modbus. Each line corresponds to an input or output of the block. The width column specifies the signal width. If it is set to a value greater than 1, multiple registers with consecutive addresses are used.
- Multi-register order
The data format of 32 and 64 bit data types (int32, uint32, float, double) is not covered by the Modbus standard. If set to lowest word first, the word with the least significant bits will be placed at the lowest address (little endian word ordering). If set to highest word first, the word with the most significant bits will be places at the lowest address (big endian word ordering).
The byte ordering within a 16 bit word is defined by the Modbus standard to be highest byte first (big endian).