Modbus
Modbus command can be used to communicate with other devices over Modbus protocol.
Please note that your controller board needs to have the Modbus feature and that the controller board has to be the master device.
Parameters
- s defines the slave number.
- f function number
- a address
- n number of bits or registers
- v value
- u user variable
- b baud rate
- If not specified, baud rate of 115200 is used
- fb parity / stop bits configuration designation
- If not specified, no parity and 2 stop bits are used
- t data type used in RMR/3 and WMR/16
- o the data ordering used in RMR/3 and WMR/16
Supported baud rates
- 9600
- 19200
- 38400
- 57600
- 76800
- 115200
Supported function numbers
| | |
|---|---|---|
1 | RMC | Read Multiple Coils |
2 | RDI | Read Discrete Inputs |
3 | RMR | Read Multiple Registers |
4 | RMIR | Read Multiple Input Registers |
5 | WSI | Write Single Coil |
6 | WSR | Write Single Registers |
15 | WMC | Write Multiple Coils |
16 | WMR | Write Multiple Registers |
17 | RS | Report SlaveID |
The abbreviation can be used instead of the number, so F=RMC or F RMC is equal to F1
Parity / stop bits configuration designations
Setting | Parity | Stop bits |
|---|---|---|
E1 | even | 1 |
O1 | odd | 1 |
N2 | none | 2 |
N1 | none | 1 |
Data type designations (introduced in version 5.3)
Value | Type information |
|---|---|
u16 | 16-bit unsigned integer (default) |
u32 | 32-bit unsigned integer |
u64 | 64-bit unsigned integer |
i16 | 16-bit signed integer |
i32 | 32-bit signed integer |
i64 | 64-bit signed integer |
d32 | 32-bit floating point number |
d64 | 64-bit floating point number |
Data ordering designation (introduced in version 5.3)
Value | Ordering information |
|---|---|
n | No reordering of data (default) |
b | Swap the bytes within each register(16-bits) |
w | Swap the placement of each register used in the combined value |
bw | Swap both the register placement and the bytes in each register |
Example
Write single coil
Write single coil, baud rate of 19200, even parity with 1 stop bit
Read multiple coils, store beginning at user variable #300
Read discrete inputs
Write single register
Write multiple coils
Write multiple holding registers
Report slave id
Read a double value (64-bit floating point) from a slave device with no data reordering. (introduced in version 5.3)