Instructions - Modbus
MODBUS_OPEN - Open Modbus Connection
Description
Opens a Modbus communication connection
Parameter List
| Parameter | Type | Required | Description |
|---|---|---|---|
| ID | int | Yes | Modbus master station process number, value range [1,9] |
| logout | bool | No | Whether commented out. true: this instruction will not be executed in the job file; false: not commented, executable |
| modType | string | Yes | Master/Slave. "Master": master station; "Slave": slave station |
| type | int | Yes | MODBUS_OPEN is 210 in the enumeration sequence type |
| userParamInt | int | No | Customer custom in secondary development, currently no meaning |
| userParamString | string | No | Customer custom in secondary development, currently no meaning |
Example
{
"ID": 5,
"logout": false,
"modType": "Master",
"type": 210,
"userParamInt": 0,
"userParamString": ""
}MODBUS_CLOSE - Close Modbus Connection
Description
Disconnects a Modbus communication connection
Parameter List
| Parameter | Type | Required | Description |
|---|---|---|---|
| ID | int | Yes | Modbus master station process number, value range [1,9] |
| logout | bool | No | Whether commented out. true: this instruction will not be executed in the job file; false: not commented, executable |
| modType | string | Yes | Master/Slave. "Master": master station; "Slave": slave station |
| type | int | Yes | MODBUS_CLOSE is 211 in the enumeration sequence type |
| userParamInt | int | No | Customer custom in secondary development, currently no meaning |
| userParamString | string | No | Customer custom in secondary development, currently no meaning |
Example
{
"ID": 9,
"logout": false,
"modType": "Master",
"type": 211,
"userParamInt": 0,
"userParamString": "",
"variable": {"data": 0.0, "secondvalue": 0, "value": 0, "varname": ""}
}MODBUS_CONNECTION_STATUS - Get Modbus Connection Status
Description
Stores the Modbus communication connection status into a variable. When the connection is successful, the variable value is set to 1; when the connection fails, the selected variable is set to 0
Parameter List
| Parameter | Type | Required | Description |
|---|---|---|---|
| ID | int | Yes | Modbus master station process number, value range [1,9] |
| logout | bool | No | Whether commented out. true: this instruction will not be executed in the job file; false: not commented, executable |
| modType | string | Yes | Master/Slave. "Master": master station; "Slave": slave station |
| type | int | Yes | Get Modbus connection status is 212 in the enumeration sequence type |
| userParamInt | int | No | Customer custom in secondary development, currently no meaning |
| userParamString | string | No | Customer custom in secondary development, currently no meaning |
Example
{
"ID": 1,
"logout": false,
"modType": "Master",
"type": 212,
"userParamInt": 0,
"userParamString": "",
"variable": {"data": 0.0, "secondvalue": 1, "value": 6, "varname": "GB[GI001]"}
}MODBUS_READ - Modbus Read
Description
Reads the value at the corresponding address in Modbus. Stores the obtained status into a variable (bool type variable or bound variable, global or local).
Address Type Description:
| Address Type | Description |
|---|---|
| 3x | Reads the value at the corresponding address in Modbus |
| 4x | Same as 3x |
| 3x-bit | Reads the status of any bit of the value stored at the selected address |
| 4x-bit | Same as 3x-bit |
| 0x | Readable and writable device type, equivalent to operating PLC output points |
| 1x | Read-only device type, equivalent to operating PLC input points |
When the address type is 3X-bit, the slave address count range is [0,16]
When the address type is 3X-bit, the 17th bit stored in the variable is the sign bit, 0 means positive, 1 means negative
When reading characters, all read values are stored into one variable. Unlike integer, floating-point, and boolean variables, it does not store sequentially into other variables based on the set first address and slave address count
Parameter List
| Parameter | Type | Required | Description |
|---|---|---|---|
| ID | int | Yes | Modbus master station process number, value range [1,9] |
| addressNumber | object | Yes | Slave address count to read. Manual or int type variable or bound variable, global or local. The number of addresses to read. If the slave address count is set to 3, after executing the read instruction, 3 addresses will be read from the Modbus first address (including the first address, reading 3 in total) |
| addressType | string | Yes | Address type. Available values: 3x, 4x, 3x-bit, 4x-bit, 0x, 1x |
| dataType | string | Yes | Data type. When the first variable for data storage is I or GI, the slave data type can be short or ushort (corresponding to short integer and unsigned short integer, the former range is [-32768,32767], the latter range is [0,65535]). The data type must match the slave data type when the first data storage variable is I or GI, otherwise data errors may occur |
| dataVariable | object | Yes | First variable for data storage. All variables or bound variables can be used. Stores the read parameters into variables. If the first variable is I001 and the address count is 3, after executing the read instruction, the parameter values will be sequentially stored into I001, I002, I003 |
| firstAddress | object | Yes | Slave register first address. Manual or int type variable or bound variable, global or local. Reads parameter values based on the first address set in the instruction parameters. If the first address is 5, after executing the read instruction, reading starts from the 5th Modbus address |
| logout | bool | No | Whether commented out. true: this instruction will not be executed in the job file; false: not commented, executable |
| modType | string | Yes | Master/Slave. "Master": master station; "Slave": slave station |
| type | int | Yes | MODBUS_READ is 213 in the enumeration sequence type |
| userParamInt | int | No | Customer custom in secondary development, currently no meaning |
| userParamString | string | No | Customer custom in secondary development, currently no meaning |
Example
{
"ID": 3,
"addressNumber": {"data": 0.0, "secondvalue": 1, "value": 4, "varname": "GI[I001]"},
"addressType": "4x-bit",
"dataType": "short",
"dataVariable": {"data": 0.0, "secondvalue": 1, "value": 9, "varname": "GS[GI001]"},
"firstAddress": {"data": 0.0, "secondvalue": 1, "value": 4, "varname": "GI[GI001]"},
"logout": false,
"modType": "Master",
"type": 213,
"userParamInt": 0,
"userParamString": ""
}MODBUS_WRITE - Modbus Write
Description
This instruction is used to write variables to the corresponding address in the slave register via Modbus
Address Type Description:
| Address Type | Description |
|---|---|
| 4x | Writes the value from the variable to the address code |
| 4x-bit | Composes the variable into 16-bit binary code and writes it to the address code |
| 0x | Writes the variable value to the address code, only "0" and "1" states, if the variable has a value it writes 1, if not it writes 0 |
Parameter List
| Parameter | Type | Required | Description |
|---|---|---|---|
| ID | int | Yes | Modbus master station process number, value range [1,9] |
| addressNumber | object | Yes | Slave address count to read. Manual or int type variable or bound variable, global or local. The number of addresses to read. If the slave address count is set to 3, after executing the read instruction, 3 addresses will be read from the Modbus first address (including the first address, reading 3 in total) |
| addressType | string | Yes | Address type. Available values: 4x, 4x-bit, 0x |
| dataVariable | object | Yes | First variable for data storage, the variable type to write. Manual or all variables or bound variables can be used |
| firstAddress | object | Yes | Slave register first address. Manual or int type variable or bound variable, global or local. The first address to start writing. If the first address is 5, after executing the write instruction, writing starts from the 5th Modbus address |
| logout | bool | No | Whether commented out. true: this instruction will not be executed in the job file; false: not commented, executable |
| modType | string | Yes | Master/Slave. "Master": master station; "Slave": slave station |
| type | int | Yes | MODBUS_WRITE is 214 in the enumeration sequence type |
| userParamInt | int | No | Customer custom in secondary development, currently no meaning |
| userParamString | string | No | Customer custom in secondary development, currently no meaning |
Example
{
"ID": 5,
"addressNumber": {"data": 0.0, "secondvalue": 0, "value": 1, "varname": "I001"},
"addressType": "0x",
"dataVariable": {"data": 0.0, "secondvalue": 1, "value": 4, "varname": "GI[GI001]"},
"firstAddress": {"data": 0.0, "secondvalue": 1, "value": 1, "varname": "I[GI001]"},
"logout": false,
"modType": "Master",
"type": 214,
"userParamInt": 0,
"userParamString": ""
}