Master Mode

From IPLOG
Revision as of 04:53, 16 July 2025 by Z033 (talk | contribs) (Created page with "=== Master MODE === ==== RTU ==== ===== MODBUS_RTU_CFG ===== Set bus parameters {| class="wikitable" |- |in |Bus |string | |path to bus device (BUS1 = "/dev/ttyS3" or BUS2 =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 stats usage.jpg

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

TCP

MODBUS_TCP_R_COIL

Reads one coil register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q bool readed value
MODBUS_TCP_R_COIL_8

Reads up to 8 coil registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to read (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_R_DISCRETE

Read one discrete input register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q bool readed value
MODBUS_TCP_R_DISCRETE_8

Read up to 8 discrete input registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to read (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_R_HOLDING

Reads one holding register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q word readed value
MODBUS_TCP_R_HOLDING_8

Reads up to 8 holding registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to read (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_R2_HOLDING

Reads two holding registers (lower register with higher weight)

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q dword readed value
MODBUS_TCP_R_INPUT

Reads one input register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q word readed value
MODBUS_TCP_R_INPUT_8

Reads up to 8 input registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to read (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_R2_INPUT

Reads two input registers (lower register with higher weight)

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
out Q dword readed value
MODBUS_TCP_W_COIL

Writes value to one coil register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
in VAL bool value to write
MODBUS_TCP_W_COIL_8

Writes value to up to 8 coil registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to write (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_W_HOLDING

Writes value to one holding register

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
in VAL word value to write
MODBUS_TCP_W_HOLDING_8

Writes value to up to 8 holding registers

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Count byte number of registers to write (1-8)
in Timeout byte timeout in seconds (default: 1s)
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_TCP_W2_HOLDING

Writes value to two holding registers (lower register with higher weight)

Asynchronous interface - internal implementation
in IP string IP address of slave device (syntax: "aaa.bbb.ccc.ddd")
in Port int TCP port of slave device (default: 502)
in UnitID byte Device bus address (default: 1)
in OfsAdr word register address (1-9999)
in Timeout byte timeout in seconds (default: 1s)
in VAL dword value to write