TestIT:Programming Modbus
Contents
5.3.20 Modbus
TcpConnect
Description:
Connects to the modbus device.
Code example:
Modbus.TcpConnect(mydevice,_B01,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Connected | Bool symbol | 0 = Error, 1 = Connected OK |
Result message | String symbol | Result text |
TcpDisconnect
Description:
Disconnect from to the modbus device.
Code example:
Modbus.TcpDisconnect(mydevice,_B01,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Connected | Bool symbol | 0 = Error, 1 = Connected OK |
Result message | String symbol | Result text |
TcpRead
Description:
Reads all configured values into symbols for the given Modbus object type
Code example:
Modbus.TcpRead(mydevice,_IN01,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Type | Int or Int symbol | The Modbus type (1 = Input register, 2 = Holding register, 3 = Discrete Input, 4 = Coils) |
Result message | String symbol | Holds error messages |
TcpReadSingle
Description:
Read the selected value from the device to the TestIT symbol for the given Modbus object type
Code example:
Modbus.TcpReadSingle(mydevice, _IN01, _IN02,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Type | Int or Int symbol | The Modbus type (1 = Input register, 2 = Holding register, 3 = Discrete Input, 4 = Coils) |
Address | Int or Int symbol | The Address/Index of the value to read |
Result message | String symbol | Holds error messages |
TcpWrite
Description:
Write all configured Modbus symbols of the selected type, to the Modbus device. Note that by common Modbus standards, some types are read only.
Code example:
Modbus.TcpWrite(mydevice,_IN01,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Type | Int or Int symbol | The Modbus type (2 = Holding register, 4 = Coils) |
Result message | String symbol | Holds error messages |
TcpWriteSingle
Description:
Write the selected value from the symbol to the device, for the given Modbus object type
Code example:
Modbus.TcpWriteSingle(mydevice, _IN01, _IN02,_ST01)
Parameters | ||
---|---|---|
Parameter | Type | Description |
Device name | Device | Modbus device to use |
Type | Int or Int symbol | The Modbus type (2 = Holding register, 4 = Coils) |
Address | Int or Int symbol | The Address/Index of the value to read |
Result message | String symbol | Holds error messages |