Skip to content

Modbus TCP ​

About 6 min read

The Modbus TCP connection type lets 2WinScada communicate over Ethernet with PLCs, energy analyzers, drives and gateways that support Modbus TCP. 2WinScada acts as the client (master).

  • The channel has no connection parameters; it only groups devices.
  • Each device opens its own TCP connection to its IP address and port. Timeout and retry settings are defined per device.
  • A connection problem on one device does not affect reading of the other devices on the same channel.

The Connection Type list shows only the protocols that the license allows (see License).

Channel Definition ​

The new channel window opens with the “+” button in the channel list. The General tab contains these fields:

FieldDescriptionRule
NameUnique name of the channelRequired; 3–50 characters; cannot start with a digit
Connection TypeSelect ModbusTcpCannot be changed after the channel is saved

Modbus TCP channels do not show the Connection Parameters and Advanced Parameters tabs; the IP address, port, timeout and retry settings are entered separately on each device.

Device Definition ​

With the channel selected, the new device window opens with the “+” button in the device list. On the General tab, enter the Name (required, 3–100 characters, unique) and set Active. No connection is opened to inactive devices.

Parameters tab:

FieldDescriptionDefaultRule
IpIPv4 address of the device (e.g. 192.168.1.10)255.255.255.255Required; a valid IPv4 address. DNS names are not accepted. The default value is only a placeholder.
PortModbus TCP port of the device502Required; 1–65535
Slave IdModbus unit identifier (Unit Id)1Required; 0–255

Most directly connected Modbus TCP devices ignore the Slave Id value or expect 1 or 255. If you reach a serial device behind a Modbus TCP → RTU gateway, enter the slave address of the serial device; however, for many serial devices on the same gateway, the Modbus Serial over Ethernet connection type is a better fit because it uses a single TCP connection.

Settings tab:

FieldDescriptionDefault
Zero BasedIf selected, 1 is subtracted from the register number in the address before it is sent to the device (400001 → protocol address 0). If not selected, the number is sent as is.Selected
First Word Low 32 BitIndicates that the first register of 32-bit and 64-bit values is the low word. If the device sends the high word first, clear this option.Selected
First DWord Low 64 BitIndicates that the first two registers of 64-bit values are the low DWord.Selected (if you use 64-bit tags, set it deliberately according to the device documentation)
Block SizeMaximum number of registers (bits for coils/discrete inputs) read in a single read request32

Details of these settings and the word order tables are on the Modbus Addressing page.

Advanced Parameters tab:

FieldDescriptionDefaultRange
Idle Time To Reinit Device [s]If no successful read is made from the device for this long, the TCP connection is closed and reopened about 10 seconds later. 0 turns the feature off.00–86400
Write Timeout [ms]Time to wait for the request to be sent1000Integer
Read Timeout [ms]Time to wait for a response. When it expires, the request counts as failed and the quality of the affected tags becomes Bad.1000Integer
RetriesHow many times a request is repeated after a timeout or communication error. A value of 1 means at most two attempts.1Integer
Wait to retry [ms]Time to wait before a retry250Integer
Retry on old response thresholdIf the transaction number of an incoming response is behind the number of the sent request by less than this value, the response is treated as a late, old response and the correct response is awaited again.3Integer
Slave busy uses retry countIf selected, "busy" (Slave Device Busy) responses from the device also count toward the Retries limit. If not selected, the request is repeated indefinitely as long as busy responses arrive.Selected—

Connection behavior ​

  • If the connection cannot be established, 2WinScada tries to reconnect after 30 seconds. After three failed attempts, the wait time increases to 60 seconds and then to 120 seconds; once the connection is established, it returns to 30 seconds.
  • When the connection cannot be established or is lost, the device's connection state shows as bad; the quality of tags that cannot be read becomes Bad.
  • Error details are written to the service log.

Tag Definition ​

Tags are defined in the device's tag table in the same way as for other protocols (see Tag Management). Modbus-specific rules:

FieldModbus rule
Address6-digit Modbus address; the first digit is the area type (0 coil, 1 discrete input, 3 input register, 4 holding register). For register bits, use the suffix .0–.15 (e.g. 400010.3).
Data TypeOnly Bool for coil and discrete input addresses. For register addresses, Bool (with a bit suffix) or numeric types.
LengthAlways 1; the String type and arrays are not supported (see Modbus Addressing)
Update Interval[s]0.5–86400 seconds. Tags with the same interval are read together.
Read OnlySelect it for addresses that start with 1 and 3

Details of the address format, data types, word order and read groups are on the Modbus Addressing page. For reusable register lists, see the Device Profiles page.

Troubleshooting ​

SymptomChecks
The device does not connectCheck the Ip and Port values, network access (ping, firewall, VLAN) and that the Modbus TCP server is enabled on the device. Reconnection is attempted at 30–120 second intervals; after changing a setting, wait to see the result.
Connected, but tags are BadCheck the Slave Id value, the addresses and the Read Timeout [ms] value. If the device returns an "Illegal Data Address" error, lower the Block Size value.
The connection drops frequentlyCheck the number of TCP connections the device accepts at the same time; reduce the other systems connecting to the same device. If the Idle Time To Reinit Device [s] value is too short, increase it.
Values are shifted or meaninglessCheck the Zero Based, First Word Low 32 Bit, First DWord Low 64 Bit and Data Type values (see Modbus Addressing).
Write failsCheck that the address starts with 0 or 4, the Read Only setting, the user's permission and that the device allows writing.

2WinScada 2.10