Modbus
Scadora works with Modbus through three connection types:
| Connection | When |
|---|---|
| Modbus TCP | Devices and gateways with Ethernet: PLCs, drives, meters, I/O modules |
| Modbus RTU (COM port) | Devices on RS-485 or RS-232, including USB adapters |
| Modbus TCP — server (slave) | Scadora itself is a Modbus device: PLCs, panels and other systems connect to it |
Addresses
Section titled “Addresses”
An address uses one of two notations:
| Area | From zero | Modicon, from one | Functions | Tag type |
|---|---|---|---|---|
| Coils | CO0, CO5 |
00001, 00006 |
read 1, write 5 | Bool |
| Discrete inputs | DI0 |
10001 |
read 2 | Bool |
| Input registers | IR10 |
30011 |
read 4 | numbers |
| Holding registers | HR100 |
40101, 400101 |
read 3, write 6 and 16 | numbers |
| Register bit | HR100.3, IR10.0 |
40101.3 |
as the register | Bool |
| String | HR100:20, HR100:20L |
40101:20 |
as the register | String |
Device manuals give addresses from zero (0x0064, “register 100”) or from one (40101). If values are shifted by one register, try the other notation.
Value size. A register is 16 bits. Int16 and UInt16 take one register, Int32, UInt32 and Float32 take two, and Int64, UInt64 and Float64 take four. The next tag after a Float32 at HR10 starts at HR12.
Strings. Put the length in characters after a colon: HR100:20 is 20 characters in registers HR100 to HR109, two characters per register, the first one in the high byte. If the device puts the first character in the low byte (the string reads “UPPM” instead of “PUMP”), add L: HR100:20L. The string ends at the first zero byte; on writing it is padded with zeros, and a longer string is an error.
Register order. By default the high register comes first (ABCD), as in most PLCs. Many drives and meters send the low register first (CDAB): turn on Swapped register order (CDAB) for them. A sign of the wrong order: Float32 shows huge or tiny numbers, and Int32 jumps by 65536.
Modbus TCP
Section titled “Modbus TCP”| Setting | Default | Meaning |
|---|---|---|
| IP address, Port | —, 502 | Address of the device or gateway |
| Unit ID | 1 | Device address. Behind a Modbus TCP/RTU gateway, the address of the RTU device on the line |
| Connection | Permanent | Permanent, or Per poll: connect, read, disconnect |
| Timeout, ms | 3000 | Wait for a reply |
| Swapped register order (CDAB) | off | Low register first |
| Max. registers per request | 125 | Limit of one read |
| Max. bits per request | 2000 | Limit of one coil or input read |
| Max. gap | 4 | How many extra registers may be read to merge requests. If the device answers “illegal address”, set 0 |
Per poll suits devices and gateways that keep few connections or drop idle ones. The connection opens for every poll and every write, then closes.
Modbus RTU
Section titled “Modbus RTU”| Setting | Default | Meaning |
|---|---|---|
| COM port | — | COM1, COM3… The USB adapter number is in Device Manager, “Ports (COM & LPT)” |
| Baud rate, bit/s | 9600 | As set in the device |
| Parity, Data bits, Stop bits | none, 8, 1 | Most often 8N1, 8E1 is also common |
| Device address | 1 | Slave ID from 1 to 247 |
| Timeout, ms | 1000 | Wait for a reply |
| Swapped register order, Max. registers, Max. bits, Max. gap | As for Modbus TCP |
Several devices on one line. Create one connection per device with the same COM port and port settings but different addresses. They share the port and are polled in turn; each has its own connection state and “No connection” alarm. A device that does not answer spoils only its own tags. Connections on one port with different port settings are rejected with an error.
Scadora keeps a 3.5-character gap between frames and checks the CRC and device address in every reply. If a device does not answer long requests, lower Max. registers per request to 16–64.
Modbus TCP server (slave)
Section titled “Modbus TCP server (slave)”Scadora can itself be a Modbus TCP device: PLCs, panels, gateways and other systems connect to it and read or write registers. Tags of the connection are bound to registers with ordinary addresses (HR10, CO5, IR3, DI0, HR20.3).
| Setting | Default | Meaning |
|---|---|---|
| Port | 502 | TCP port on which Scadora waits for requests |
| Network interface | 0.0.0.0 | IP address of the network card; 0.0.0.0 — all |
| Unit ID | 1 | Address of this device, 1 to 247 |
| Devices may write | on | Allow masters to write coils and holding registers (functions 5, 6, 15, 16). Off — read only |
| Allowed IPs | empty | Master addresses, comma-separated; empty — any |
| No connection after, s | 30 | No requests to this Unit ID for longer — tags get “no connection” and the connection alarm fires. 0 — do not check |
Several Unit IDs on one port. Create one connection per Unit ID with the same port. They share one listening socket, and each request reaches its Unit ID’s table. Masters that send Unit ID 0 or 255 reach the only Unit ID on the port. An unknown Unit ID gets exception 11, as from a gateway.
Who writes what. Masters write coils and holding registers. Input registers and discrete inputs are written only by Scadora: from tags, scripts or the operator, and masters read them. Writing a tag in Scadora puts the value into the register table at once, including a single register bit.
Values are kept in memory: after a server restart registers are zero until written again. The port is opened in Windows Firewall automatically. Modbus has no authentication: in networks you do not fully control, restrict Allowed IPs or turn off Devices may write.
Device error codes
Section titled “Device error codes”| Code | Meaning | What to do |
|---|---|---|
| 1 | Illegal function | The device does not support this area: for example, it has no coils or input registers |
| 2 | Illegal data address | No such register. Set Max. gap to 0 and check the zero-based or one-based notation |
| 3 | Illegal data value | The value is outside the device range, or the request is too long |
| 4 | Device failure | Internal device error |
| 6 | Device busy | Try again later |
| 10, 11 | Gateway: no path, target did not respond | The device behind the gateway does not answer: check the Unit ID and the RS-485 line behind the gateway |
Testing and troubleshooting
Section titled “Testing and troubleshooting”| Symptom | Cause and what to do |
|---|---|
| “No connection”, timeout (TCP) | Wrong IP or port, or the device is busy with another client |
| Timeout (RTU) | Wrong COM port, speed, parity or address; A and B lines swapped; no terminator on a long line |
| Values shifted by one register | Zero-based notation instead of Modicon, or the other way round |
Float32 shows huge or tiny numbers |
Turn on Swapped register order (CDAB) |
| Some tags Bad with code 2 | Merging touches registers that do not exist: set Max. gap to 0 |
Limitations
Section titled “Limitations”- Writing a register bit (
HR10.3) is not supported: it would need a read-modify-write that can overwrite bits the device has just changed. Write the whole register or use coils. - Modbus ASCII and Modbus RTU over TCP are not supported.