Skip to Content
On this page

Modbus master

The Modbus master plugin reads and writes Modbus TCP, RTU, and ASCII devices.

Compatible devices and models

Device series / model examplesConnection requirements
PLCs, instruments, drives and I/O modules supporting Modbus TCP, RTU or ASCIIEnable the corresponding Modbus slave/server. Match station, function code, register offset, data type and byte order to the device register map.
Inovance H5U, Easy320, Easy52X (Modbus TCP)Use the PLC Modbus TCP slave and numeric register addresses and function codes from its register map. Convert device names such as D/M first; FINS and EasyNet addresses do not apply unchanged.
Omron CP2E-S, CP2E-N (Modbus RTU)Enable Modbus RTU slave mode on an available serial port. W maps to coils and D to holding registers; use numeric addresses and supported function codes from the CP2E manual. The Ethernet FINS interface is a different service from Modbus TCP.
FATEK B1, B1z (Modbus interfaces)Select Modbus RTU/ASCII on a serial port supporting that mode. B1 with a B1-CM25E/B1-CM55E module can use Modbus TCP server, default port 502. Use numeric Modbus addresses. The FATEK standard protocol, default port 500, uses the Program plugin.
Delta DVP, AS300 (Modbus interfaces)Enable a Modbus slave on the actual CPU or communication module and use numeric addresses from the matching series register map. Select the Delta plugin and correct series mapping to use device names such as X/Y/M/D directly.

Open the plugin

Open Development Configuration → Collection Configuration, create a device, and select Modbus master as the collection plugin.

Create the channel and device through Collection Configuration. This page lists only Modbus-specific settings, addresses, and debug actions.

Configure the source service and register map

Enable a Modbus slave/server in the PLC engineering software or instrument settings. The gateway initiates requests; two client endpoints cannot communicate with each other. Record the actual IP/port or serial settings, station, and a safe readable test point. Download the settings and confirm that the source is running. TCP commonly uses port 502, but use the configured port.

The register map must identify area, protocol offset, type, width, byte order, and access permission. For FC03, offset 0, signed 16-bit, known value 1234, use F=3;0, Int16, array length 0 (scalar). A map using reference 40001 identifies the same register; do not send offset 40001. Names such as D0 or M0 require the specific PLC’s Modbus mapping before use here.

Prepare a known value in Modbus Slave

These screenshots use Modbus Slave 7.4.1 on the same computer as the gateway. This is a software test. For a physical PLC, use its server configuration and online monitor value. See the connection, slave-definition, and communication-monitor sections of the official tool manual .

  1. Press F8 / Slave Definition. Set Slave ID 1, Function 03 Holding Register (4x), address mode Dec, Address 0, and Quantity 10. Leave error simulation off. The dialog shows PLC address 40001 beside protocol Address 0.

    Modbus Slave: station 1, FC03, zero-based offset 0 and ten registers

  2. Confirm, double-click the first value cell, and enter 1234 using signed 16-bit display. In F3 / Connection Setup, select Modbus TCP/IP, clear Any Address, and bind 127.0.0.1, port 15020. Leave Ignore Unit ID clear so that a wrong station can be detected. Confirm and keep the server listening.

    Modbus Slave: TCP/IP bound to localhost port 15020

127.0.0.1 applies only when both processes share the same host network. From another computer or container, it identifies the gateway itself. Bind the tool to a reachable interface and use that interface address from the gateway.

Create the channel, device, and variable

  1. In Development Configuration → Collection Configuration, add enabled channel ModbusSlave_TCP, type TcpClient, endpoint 127.0.0.1:15020. For a physical TCP device, use its actual endpoint, such as 192.168.1.10:502. Channel connection timeout and plugin response timeout serve different purposes; see Channels and transport.

    Modbus master: TCP client channel to local Modbus Slave

  2. Add device ModbusSlave_Test, select Modbus master, associate the channel, and set the execution interval to 1000 ms.

    Modbus master: plugin, associated channel, and execution interval

  3. In Plugin Properties, select ModbusTcp, station 1, and default packing limits. Leave DTU ID and heartbeat empty for this direct connection. Save the device.

    Modbus master: protocol, packing, and DTU settings

    Scroll down in Plugin Properties for timeout, retries, scheduling and data format. This example keeps timeout 3000 ms, frame delay 0 ms, retries 3, write/read ratio 3, write priority off, string byte reversal off and ABCD. For multi-register values on other devices, select the byte order specified in their register map.

    Lower Modbus properties: runtime parameters and data format

  4. Add enabled variable Holding_40001, address 40001, type Int16, and array length 0 (scalar). The example allows read/write; choose read-only when only collecting. Gateway permission cannot make a read-only source register writable.

    Modbus master: Int16 scalar variable and access permission

  5. Open Field Editor beside the address. Confirm HoldingRegisters, offset 0, and no optional overrides. Confirm and fill back: the address becomes F=3;0. Save the outer variable dialog as well; filling back alone does not save it.

    Modbus master: 40001 parsed as holding-register offset 0

  6. Confirm an online device, an available runtime instance, value 1234, and advancing collection time. Compare with the source register; an online TCP connection alone does not validate the address map.

    Modbus master: periodic value 1234

For RTU or ASCII, select a serial channel and match port, baud rate, data bits, stop bits, and parity. Select ModbusRtu or ModbusAscii to match the source. Unicast serial stations normally use 1–247; broadcast 0 is unsuitable for a read test. Match RS-485 D+/D− or A/B using both device manuals because labels differ between vendors; follow their requirements for reference ground, shielding, and end termination. RS-232 cannot connect directly to RS-485 A/B. Release the port from other tasks or tools before enabling the gateway. An Ethernet converter transparently carrying RTU frames still requires ModbusRtu; a Modbus TCP server requires ModbusTcp.

Verify MBAP for Modbus TCP, CRC for RTU, and text framing/LRC for ASCII. Renaming a channel does not change framing. The gateway Messages panel can show connection/receive summaries without raw bytes; use the source communication monitor or packet capture when checking station and function bytes.

In device debugging, 40001 and F=3;0 should read the same register. Stop affected tasks before reconfiguring a serial link. Test coils and registers separately before adding arrays: array length counts elements, while packing limits count bits or registers. After a permitted write to a safe point, verify through an independent master and then a new gateway sample.

See Channels and transport and Batch configuration.

Supported channels and data types

Channel typeCheck before configuration
TCP clientConfirm the device IP, port, and network reachability from the gateway.
TCP serverConfirm the local listening address and port, and that the field device can connect to the gateway.
Serial portConfirm that the port is not in use and that baud rate, data bits, stop bits, and parity match the device.
UDPConfirm the bind address, port, firewall rules, and packet source.

Supported data types: Boolean, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float, Double, String, and Decimal.

Plugin properties

Configure channel type, endpoints, serial settings, TLS, connection timeout, and channel concurrency in the associated channel. Open its editor beside Associated Channel in the device editor. Retry count, read/write duty cycle, write priority, protocol timeout, data format, and string byte reversal are device plugin properties. See Collection Configuration for shared fields. The tables below list Modbus-specific settings.

Protocol

SettingDescription
Modbus typeSelect ModbusTcp, ModbusRtu, or ModbusAscii to match the field device and channel.
Default stationDefault 1, used unless the variable specifies S=. Serial unicast normally uses 1–247. TCP Unit ID follows the device or bridge requirement; it is not derived from the last part of the IP address.

Runtime and data format

SettingDescription
Read/write timeoutDefault 3000 ms for a protocol response; independent of the collection interval.
Failure retriesDefault 3. Error type and driver policy determine actual retries; include their requests and waiting time.
Pre-frame delayDefault 0 ms before sending. Multiple requests each incur the delay; this does not configure RTU frame boundaries.
Read/write duty cycleDefault 3. Under sustained read/write contention, counts writes before giving waiting reads an opportunity. It is not a percentage or a guaranteed 3:1 ratio in every observation window.
Write priorityDefault off. Affects supported scheduling under contention; verify write results and source feedback separately.
Data formatDefault ABCD; choose ABCD, BADC, CDAB, or DCBA to match the point table. Address option data= can override a single point.
String byte reversalDefault off. Swaps the two characters inside each word: the same ASCII source PLC001 becomes LP0C10. This is separate from numeric byte order and text encoding.

Request packing

These limits count bits or registers in each request; variable rows can occupy different widths. Keep the defaults unless the device manual specifies a smaller limit.

SettingRange / defaultDescription
FC1 maximum coils1–2000, default 1600Maximum coil bits read in one FC1 request.
FC2 maximum discrete inputs1–2000, default 1600Maximum discrete-input bits read in one FC2 request.
FC3 maximum holding registers1–125, default 100Maximum holding registers read in one FC3 request.
FC4 maximum input registers1–125, default 100Maximum input registers read in one FC4 request.
FC15 maximum multiple-coil write1–1968, default 1968Maximum coil bits written in one FC15 request.
FC16 maximum multiple-register write1–123, default 123Maximum registers written in one FC16 request.

DTU connection

SettingDescription
DTU IDEmpty by default. Identifies the inbound DTU connection assigned to this device in TCP server DTU mode. It is separate from the Modbus station. Leave empty for direct TCP, serial, or UDP connections.
Heartbeat contentEmpty inherits the channel heartbeat; a nonempty value overrides it. Applies only to the default TCP Server DTU mode, identifying and echoing that device’s heartbeat. Match the actual DTU payload; this is neither a Modbus read command nor a collection interval.
Heartbeat is HexDefault off: UTF-8 text matching. Enable for hexadecimal byte matching. Text PING and bytes 50 49 4E 47 require the corresponding input mode. This changes neither Modbus framing nor channel DTU ID encoding.

See DTU Service for TCP server identification rules. A connected socket can still fail to match this device when its identifier is wrong; a mismatched heartbeat can reach protocol parsing. Check those settings before changing the Modbus station.

Address rules

Use the address area that matches the Modbus function:

Address rangeArea
00001 onwardCoils
10001 onwardDiscrete inputs
30001 onwardInput registers
40001 onwardHolding registers

Examples:

  • 40001 is the first holding register.
  • 40001;s=2; reads station 2 instead of the default station.
  • 40001;w=16; uses function code 16 when writing the value.
  • F=3;100 explicitly uses function code 3 at protocol offset 100 for a holding-register read. With F=, the address is a zero-based offset rather than a 40001-style area address.
  • Combine options with semicolons, for example S=2;F=3;100. The options apply to this variable address only.

The address editor offers write functions 5 (single coil), 6 (single register), 15 (multiple coils), and 16 (multiple registers). Leave the override unset to use the area’s/type’s write defaults. Do not select a coil function for a holding register or a single-register function for a value spanning multiple registers. Override only when required by the source manual.

Address editor fields

Choose the variable type, array length, and permission before editing the address; they affect allowed areas and access width.

FieldPurpose and input
Read areaCoils/01, DiscreteInputs/02, HoldingRegisters/03, or InputRegisters/04. Read/write and write-only variables offer only coils and holding registers. Set read-only first for input areas. Bit areas use one bit per address; register areas use 16 bits per address.
Start offset0–65535, always zero-based within the area. Do not include the 4xxxx reference prefix: 40001 is holding offset 0, 40002 is 1. The entire array or multibyte value must fit the source map.
Bit offsetUnset adds no suffix. For a register Boolean, use 0–15; F=3;0.1 identifies bit 1 in the first register. Coil/input-bit areas reject bit suffixes. Periodic Byte handling is described below.
Station overrideUnset inherits the device station; a set value must be 1–247, for example F=3;0;S=2. A variable’s name does not select its station.
Write function overrideSelect supported function 5/6/15/16 only when required. Does not change the read area or offset.
Byte order overrideUnset inherits device data format; options are ABCD/BADC/CDAB/DCBA. F=3;0;data=CDAB exchanges 32-bit word order without moving the address.
Encoding overrideFor strings, use the actual storage encoding, such as ASCII or UTF-8; leave unset for ordinary numbers. The runtime must support the encoding name.
String byte lengthRequired for String access. The field permits 0–65535; use a positive valid storage length for ordinary reads. F=3;0;len=6;encoding=ASCII occupies six bytes/three registers. This is neither character count nor array element count.
BCD overrideC8421/C5421/C2421/C3/Gray, for String conversion when the source uses that encoding. Bytes 12 34 in two-byte 8421 BCD can use len=2;bcd=C8421. Ordinary binary integer 04 D2 needs no BCD override.
Variable string length overrideA shared conversion field; unset and explicit false are preserved separately. Ordinary Modbus registers have no S7 STRING header. This plugin still uses len= to determine access width; this option does not discover the PLC text length or reduce register reads.

Enable an override to specify a valid value; clear its checkbox to remove it. Manual options data/encoding/len/bcd/vsl correspond to these fields. Do not duplicate an option or overwrite manual syntax that the editor cannot fully represent.

See Common variable register options for data, len, bcd, encoding, and combined examples. Verify the address against the device point list before importing many variables.

Device debug

Open Development Configuration → Collection Configuration, select the Modbus device, open Protocol Debug at the top of the workspace.

Read and write

Modbus master: direct Int16 read at F=3;0 returns 1234

Read the same address F=3;0, type Int16, quantity 1; it should match the periodic value. Before writing, confirm the variable permission, station, function code, data type, and field safety conditions. In this isolated software slave, a write from 1234 to 2345 changed the source table to 2345. A subsequent write restored 1234, followed by a successful fresh read. Check the source and a new sample; an old result box is insufficient.

Modbus Slave: offset 0 changed to 2345 after the gateway write

Modbus master: restored 1234 and read it back successfully

Messages

Modbus master: connection and receive summaries for this device

Start temporary capture, reproduce the read, then stop capture. Inspect connection and protocol errors. In this example the gateway shows connection and Received summaries; inspect the raw bytes in Modbus Slave’s Display → Communication:

Modbus Slave: FC03 request at offset 0 for one register and response 04 D2

Rx means a request received from the gateway; Tx means a response sent to it. After the changing two-byte transaction ID, request … 00 00 00 06 01 03 00 00 00 01 has protocol ID 0, remaining length 6, Unit ID 1, FC03, offset 0, and quantity 1. Response … 00 00 00 05 01 03 02 04 D2 contains two data bytes, 0x04D2 = 1234. RTU uses CRC and ASCII uses LRC; neither uses this MBAP header.

Functions

FunctionPurpose
Read and writeRead a confirmed point and write only to an approved test point.
MessagesInspect connection/receive summaries and errors; use source monitoring or capture when raw protocol bytes are needed.

Register bits and Byte reads

For a holding-register Boolean, .0–.15 selects a bit. With known source bytes 04 D2 (1234), 40001.0 is false and 40001.1 is true. A nonzero whole register does not make every bit true.

Check periodic collection and single-Byte debugging separately. For the same 04 D2 source, a periodic Byte point at 40001.0 can return low byte 210. The debug Read/Write single-Byte operation returns the first response byte, 4; adding .1 there does not select the low byte. Compare the business point and raw frame when validating the point-table mapping.

Array length counts elements: three Int16 elements occupy three registers; three Float elements occupy six. If one array exceeds the slave request limit, shorten or split it instead of adjusting the number of variable rows.

One array write must also fit the FC15/FC16 limit; a smaller limit does not automatically split it. Writing three Int16 elements is rejected with FC16 set to 2; a limit of 4 allows it only if the slave supports that range. Inspect every address result in a batch rather than treating outer-request success as complete success.

Decimal uses a sixteen-byte representation occupying eight holding registers, not a universal PLC decimal format. Choose scaled integers, Float, or Double according to the device layout. For 64-bit counters, compare source bytes and the receiver’s complete integer representation; an approximate browser number is insufficient to confirm precision.

Verify the configuration

  1. Read one confirmed field address.
  2. Confirm that the returned value, data type, byte order, station, and function code match the point list.
  3. For a writable point, write a safe value and read it back according to the field procedure.
  4. Only after the single-point check passes should you import the complete point list.

Troubleshooting

SymptomCheck
Address read failsCheck the address area, station suffix, data type, and device point list.
Serial device does not respondCheck port ownership, baud rate, data bits, stop bits, parity, and channel type.
TCP device does not respondCheck the remote or bind address, firewall, station, and Modbus type.
Values are shifted or incorrectCheck data type, byte order, array length, and the address offset.
Batch read is rejectedReduce the corresponding FC1–FC4 limit and compare it with the device manual.
Batch write is rejectedKeep FC15 between 1–1968 and FC16 between 1–123, then compare the configured limit with the device manual.