Difference between revisions of "Blocks MODBUS RTU"
(→Back to Libraries) |
|||
| Line 1: | Line 1: | ||
| − | == | + | == Modbus library == |
| − | ==== MODBUS_RTU_CFG ==== | + | === Master MODE === |
| + | |||
| + | ==== RTU ==== | ||
| + | |||
| + | ===== MODBUS_RTU_CFG ===== | ||
Set bus parameters | Set bus parameters | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 9: | Line 13: | ||
|string | |string | ||
| | | | ||
| − | |path to bus device (/dev/ | + | |path to bus device (BUS1 = "/dev/ttyS3" or BUS2 = "/dev/ttyS2") |
|- | |- | ||
|in | |in | ||
| Line 15: | Line 19: | ||
|int | |int | ||
| | | | ||
| − | |standard baudrates from 150 to 115200 | + | |standard baudrates from 150 to 115200 (allowed speeds: 150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 38400, 57600, 115200, 1000000) |
|- | |- | ||
|in | |in | ||
| Line 47: | Line 51: | ||
|identifies occured error by unique code | |identifies occured error by unique code | ||
|} | |} | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | ==== MODBUS_RTU_R_COIL ==== | + | ===== MODBUS_RTU_STATS ===== |
| + | The block provides statistical information on the responses from the slave that do not arrive on time. This is useful when debugging timeouts. | ||
| + | {| class="wikitable" | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | |path to bus device (BUS1 = "/dev/ttyS3" or BUS2 = "/dev/ttyS2") | ||
| + | |- | ||
| + | |out | ||
| + | |TIMEOUT_CNT | ||
| + | |UDINT | ||
| + | |A counter of responses that do not arrive within the time limit. | ||
| + | |- | ||
| + | |out | ||
| + | |FLUSH_CNT | ||
| + | |UDINT | ||
| + | |A counter of responses that arrive after a timeout. | ||
| + | |- | ||
| + | |out | ||
| + | |DBG_TEXT | ||
| + | |string[255] | ||
| + | |String of the last flushed data. | ||
| + | |} | ||
| + | Example of usage: | ||
| + | |||
| + | [[File:Modbus rtu stats usage.jpg]] | ||
| + | |||
| + | ===== MODBUS_RTU_R_COIL ===== | ||
Reads one coil register | Reads one coil register | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" | [[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 80: | Line 106: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
|- | |- | ||
|out | |out | ||
| Line 89: | Line 115: | ||
|} | |} | ||
| − | ==== | + | ===== MODBUS_RTU_R_COIL_8 ===== |
| − | + | Reads up to 8 coil registers | |
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" | [[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 111: | Line 137: | ||
| | | | ||
|register address (1-9999) | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to read (1-8) | ||
|- | |- | ||
|in | |in | ||
| Line 116: | Line 148: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
| + | |- | ||
| + | |out | ||
| + | |Q1 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 1st register | ||
| + | |- | ||
| + | |out | ||
| + | |Q2 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 2nd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q3 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 3rd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q4 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 4th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q5 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 5th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q6 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 6th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q7 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 7th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q8 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_R_DISCRETE ===== | ||
| + | Read one discrete input register | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
|- | |- | ||
|out | |out | ||
| Line 125: | Line 235: | ||
|} | |} | ||
| − | ==== MODBUS_RTU_R_HOLDING ==== | + | ===== MODBUS_RTU_R_DISCRETE_8 ===== |
| + | Read up to 8 discrete input registers | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to read (1-8) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |out | ||
| + | |Q1 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 1st register | ||
| + | |- | ||
| + | |out | ||
| + | |Q2 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 2nd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q3 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 3rd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q4 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 4th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q5 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 5th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q6 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 6th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q7 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 7th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q8 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_R_HOLDING ===== | ||
Reads one holding register | Reads one holding register | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" |[[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 152: | Line 346: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
|- | |- | ||
|out | |out | ||
| Line 161: | Line 355: | ||
|} | |} | ||
| − | ==== MODBUS_RTU_R_INPUT ==== | + | ===== MODBUS_RTU_R_HOLDING_8 ===== |
| + | Reads up to 8 holding registers | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to read (1-8) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |out | ||
| + | |Q1 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 1st register | ||
| + | |- | ||
| + | |out | ||
| + | |Q2 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 2nd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q3 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 3rd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q4 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 4th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q5 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 5th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q6 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 6th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q7 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 7th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q8 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_R2_HOLDING ===== | ||
| + | Reads two holding registers as 32bit number (lower register with higher weight) | ||
| + | |||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |out | ||
| + | |Q | ||
| + | |dword | ||
| + | | | ||
| + | |readed value | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_R_INPUT ===== | ||
Reads one input register | Reads one input register | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" |[[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 188: | Line 503: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
|- | |- | ||
|out | |out | ||
| Line 197: | Line 512: | ||
|} | |} | ||
| − | ==== MODBUS_RTU_W_COIL ==== | + | ===== MODBUS_RTU_R_INPUT_8 ===== |
| + | Reads up to 8 input registers | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to read (1-8) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |out | ||
| + | |Q1 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 1st register | ||
| + | |- | ||
| + | |out | ||
| + | |Q2 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 2nd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q3 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 3rd register | ||
| + | |- | ||
| + | |out | ||
| + | |Q4 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 4th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q5 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 5th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q6 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 6th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q7 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 7th register | ||
| + | |- | ||
| + | |out | ||
| + | |Q8 | ||
| + | |bool | ||
| + | | | ||
| + | |readed value of 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_R2_INPUT ===== | ||
| + | Reads two input registers as 32bit number (lower register with higher weight) | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |out | ||
| + | |Q | ||
| + | |dword | ||
| + | | | ||
| + | |readed value | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_W_COIL ===== | ||
Writes value to one coil register | Writes value to one coil register | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" |[[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 224: | Line 659: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
|- | |- | ||
|in | |in | ||
| Line 232: | Line 667: | ||
|value to write | |value to write | ||
|} | |} | ||
| − | |||
| − | |||
| − | ==== MODBUS_RTU_W_HOLDING ==== | + | ===== MODBUS_RTU_W_COIL_8 ===== |
| + | Writes value to up to 8 coil registers | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to write (1-8) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |in | ||
| + | |VAL1 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 1st register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL2 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 2nd register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL3 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 3rd register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL4 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 4th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL5 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 5th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL6 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 6th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL7 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 7th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL8 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_W_HOLDING ===== | ||
Writes value to one holding register | Writes value to one holding register | ||
{| class="wikitable" | {| class="wikitable" | ||
| − | | colspan="5" |[[ | + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation |
|- | |- | ||
|in | |in | ||
| Line 262: | Line 779: | ||
|byte | |byte | ||
| | | | ||
| − | |timeout in seconds | + | |timeout in seconds (default: 250ms) |
|- | |- | ||
|in | |in | ||
|VAL | |VAL | ||
|word | |word | ||
| + | | | ||
| + | |value to write | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_W_HOLDING_8 ===== | ||
| + | Writes value to up to 8 holding registers | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Count | ||
| + | |byte | ||
| + | | | ||
| + | |number of registers to write (1-8) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |in | ||
| + | |VAL1 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 1st register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL2 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 2nd register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL3 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 3rd register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL4 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 4th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL5 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 5th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL6 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 6th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL7 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 7th register | ||
| + | |- | ||
| + | |in | ||
| + | |VAL8 | ||
| + | |bool | ||
| + | | | ||
| + | |value to write to 8th register | ||
| + | |} | ||
| + | |||
| + | ===== MODBUS_RTU_W2_HOLDING ===== | ||
| + | Writes value to two holding registers (lower register with higher weight) | ||
| + | {| class="wikitable" | ||
| + | | colspan="5" |[[#Asynchronous operations|Asynchronous interface]] - internal implementation | ||
| + | |- | ||
| + | |in | ||
| + | |Bus | ||
| + | |string | ||
| + | | | ||
| + | |path to bus device (/dev/ttyS0) | ||
| + | |- | ||
| + | |in | ||
| + | |UnitID | ||
| + | |byte | ||
| + | | | ||
| + | |device bus address (0-247) | ||
| + | |- | ||
| + | |in | ||
| + | |OfsAdr | ||
| + | |word | ||
| + | | | ||
| + | |register address (1-9999) | ||
| + | |- | ||
| + | |in | ||
| + | |Timeout | ||
| + | |byte | ||
| + | | | ||
| + | |timeout in seconds (default: 250ms) | ||
| + | |- | ||
| + | |in | ||
| + | |VAL | ||
| + | |dword | ||
| | | | ||
|value to write | |value to write | ||
|} | |} | ||
Revision as of 04:39, 16 July 2025
Contents
- 1 Modbus library
- 1.1 Master MODE
- 1.1.1 RTU
- 1.1.1.1 MODBUS_RTU_CFG
- 1.1.1.2 MODBUS_RTU_STATS
- 1.1.1.3 MODBUS_RTU_R_COIL
- 1.1.1.4 MODBUS_RTU_R_COIL_8
- 1.1.1.5 MODBUS_RTU_R_DISCRETE
- 1.1.1.6 MODBUS_RTU_R_DISCRETE_8
- 1.1.1.7 MODBUS_RTU_R_HOLDING
- 1.1.1.8 MODBUS_RTU_R_HOLDING_8
- 1.1.1.9 MODBUS_RTU_R2_HOLDING
- 1.1.1.10 MODBUS_RTU_R_INPUT
- 1.1.1.11 MODBUS_RTU_R_INPUT_8
- 1.1.1.12 MODBUS_RTU_R2_INPUT
- 1.1.1.13 MODBUS_RTU_W_COIL
- 1.1.1.14 MODBUS_RTU_W_COIL_8
- 1.1.1.15 MODBUS_RTU_W_HOLDING
- 1.1.1.16 MODBUS_RTU_W_HOLDING_8
- 1.1.1.17 MODBUS_RTU_W2_HOLDING
- 1.1.1 RTU
- 1.1 Master MODE
Modbus library
Master MODE
RTU
MODBUS_RTU_CFG
Set bus parameters
| in | Bus | string | path to bus device (BUS1 = "/dev/ttyS3" or BUS2 = "/dev/ttyS2") | |
| in | Baud | int | standard baudrates from 150 to 115200 (allowed speeds: 150, 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 38400, 57600, 115200, 1000000) | |
| in | Parity | string[1] | "N" = none, "E" = even, "O" = odd | |
| in | Databit | USINT | Databits (5,6,7,8) | |
| in | Stopbit | USINT | Stopbits (1,2) | |
| out | ERR | bool | indicates some error occurs (0 = OK) | |
| out | ERR_ID | WORD | identifies occured error by unique code |
MODBUS_RTU_STATS
The block provides statistical information on the responses from the slave that do not arrive on time. This is useful when debugging timeouts.
| in | Bus | string | path to bus device (BUS1 = "/dev/ttyS3" or BUS2 = "/dev/ttyS2") |
| out | TIMEOUT_CNT | UDINT | A counter of responses that do not arrive within the time limit. |
| out | FLUSH_CNT | UDINT | A counter of responses that arrive after a timeout. |
| out | DBG_TEXT | string[255] | String of the last flushed data. |
Example of usage:
MODBUS_RTU_R_COIL
Reads one coil register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | bool | readed value | |
MODBUS_RTU_R_COIL_8
Reads up to 8 coil registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to read (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q1 | bool | readed value of 1st register | |
| out | Q2 | bool | readed value of 2nd register | |
| out | Q3 | bool | readed value of 3rd register | |
| out | Q4 | bool | readed value of 4th register | |
| out | Q5 | bool | readed value of 5th register | |
| out | Q6 | bool | readed value of 6th register | |
| out | Q7 | bool | readed value of 7th register | |
| out | Q8 | bool | readed value of 8th register | |
MODBUS_RTU_R_DISCRETE
Read one discrete input register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | bool | readed value | |
MODBUS_RTU_R_DISCRETE_8
Read up to 8 discrete input registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to read (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q1 | bool | readed value of 1st register | |
| out | Q2 | bool | readed value of 2nd register | |
| out | Q3 | bool | readed value of 3rd register | |
| out | Q4 | bool | readed value of 4th register | |
| out | Q5 | bool | readed value of 5th register | |
| out | Q6 | bool | readed value of 6th register | |
| out | Q7 | bool | readed value of 7th register | |
| out | Q8 | bool | readed value of 8th register | |
MODBUS_RTU_R_HOLDING
Reads one holding register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | word | readed value | |
MODBUS_RTU_R_HOLDING_8
Reads up to 8 holding registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to read (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q1 | bool | readed value of 1st register | |
| out | Q2 | bool | readed value of 2nd register | |
| out | Q3 | bool | readed value of 3rd register | |
| out | Q4 | bool | readed value of 4th register | |
| out | Q5 | bool | readed value of 5th register | |
| out | Q6 | bool | readed value of 6th register | |
| out | Q7 | bool | readed value of 7th register | |
| out | Q8 | bool | readed value of 8th register | |
MODBUS_RTU_R2_HOLDING
Reads two holding registers as 32bit number (lower register with higher weight)
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | dword | readed value | |
MODBUS_RTU_R_INPUT
Reads one input register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | word | readed value | |
MODBUS_RTU_R_INPUT_8
Reads up to 8 input registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to read (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q1 | bool | readed value of 1st register | |
| out | Q2 | bool | readed value of 2nd register | |
| out | Q3 | bool | readed value of 3rd register | |
| out | Q4 | bool | readed value of 4th register | |
| out | Q5 | bool | readed value of 5th register | |
| out | Q6 | bool | readed value of 6th register | |
| out | Q7 | bool | readed value of 7th register | |
| out | Q8 | bool | readed value of 8th register | |
MODBUS_RTU_R2_INPUT
Reads two input registers as 32bit number (lower register with higher weight)
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| out | Q | dword | readed value | |
MODBUS_RTU_W_COIL
Writes value to one coil register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| in | VAL | bool | value to write | |
MODBUS_RTU_W_COIL_8
Writes value to up to 8 coil registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to write (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| in | VAL1 | bool | value to write to 1st register | |
| in | VAL2 | bool | value to write to 2nd register | |
| in | VAL3 | bool | value to write to 3rd register | |
| in | VAL4 | bool | value to write to 4th register | |
| in | VAL5 | bool | value to write to 5th register | |
| in | VAL6 | bool | value to write to 6th register | |
| in | VAL7 | bool | value to write to 7th register | |
| in | VAL8 | bool | value to write to 8th register | |
MODBUS_RTU_W_HOLDING
Writes value to one holding register
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| in | VAL | word | value to write | |
MODBUS_RTU_W_HOLDING_8
Writes value to up to 8 holding registers
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Count | byte | number of registers to write (1-8) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| in | VAL1 | bool | value to write to 1st register | |
| in | VAL2 | bool | value to write to 2nd register | |
| in | VAL3 | bool | value to write to 3rd register | |
| in | VAL4 | bool | value to write to 4th register | |
| in | VAL5 | bool | value to write to 5th register | |
| in | VAL6 | bool | value to write to 6th register | |
| in | VAL7 | bool | value to write to 7th register | |
| in | VAL8 | bool | value to write to 8th register | |
MODBUS_RTU_W2_HOLDING
Writes value to two holding registers (lower register with higher weight)
| Asynchronous interface - internal implementation | ||||
| in | Bus | string | path to bus device (/dev/ttyS0) | |
| in | UnitID | byte | device bus address (0-247) | |
| in | OfsAdr | word | register address (1-9999) | |
| in | Timeout | byte | timeout in seconds (default: 250ms) | |
| in | VAL | dword | value to write | |
