This article describes the method to connect a SCADA to a PLC through the gateway, when the SCADA only speaks Modbus TCP and the PLC speaks another protocol (Beckhoff ADS, OPC UA…). The gateway emulates a Modbus slave for the SCADA, reads and writes the PLC with the matching driver, and routes connect the two. Most of the work is to agree on the conventions before generating the address table: a table generated on wrong conventions is shifted by one register, or reads 32-bit values in the wrong place.
Checked against: firmware r9347 and the AI assistant tools of the same date. Licences: the Modbus driver and the PLC driver may need a licence (contact support@weble.ch). Level: integrator.
| Part | Role |
|---|---|
| SCADA | Modbus TCP master. It reads and writes blocks of registers or bits ("frames"), each value identified by an index in the frame. |
| Modbus gateway | Modbus gateway of type tcpSlave, mode local slave, port 502. It holds one address per index of each frame. |
| PLC gateway | The driver of the PLC, for example ADS for a Beckhoff controller or OPC UA. It holds one address per PLC variable. |
| Routes | One route per value: PLC → Modbus for what the SCADA reads, Modbus → PLC for what the SCADA writes. |
| File | Where it comes from | Content used |
|---|---|---|
| One export per SCADA frame (CSV or TXT) | SCADA configuration tool | One line per value: the tag and its index in the frame (a description column is kept if present). |
| Export of the PLC gateway (JSON) | Address table of the PLC gateway on the device, export to file | The PLC variables already known by the device. |
| PLC project export (optional) | TwinCAT: PLCopen XML export of the project | All the variables of the PLC with their type, including those not yet on the device. |
| Export of the current Modbus slave gateway (JSON, optional) | If a Modbus slave already exists | Its parameters are kept. |
Write down the answer to each question with the SCADA integrator, frame by frame, before generating anything:
| Question | Possible answers | Effect |
|---|---|---|
| Direction of the frame | The SCADA reads it (PLC → SCADA) or writes it (SCADA → PLC) | Direction of the routes; the PLC addresses read by the SCADA need a refresh period (CycleTime for ADS). |
| Modbus zone | Coils, discrete inputs, input registers, holding registers | Address prefix: %MX, %QX, %Q, %M (see Modbus addresses). Input registers and discrete inputs are read-only for the SCADA. |
| Width of the values | 1 bit, or 32 bits on two registers | A 32-bit value takes two registers: index n starts at register 2·(n−1) of the frame. |
| First register of the frame | Usually the first register of its zone | A frame that does not start at the first register needs a start offset. |
| Addressing base of the SCADA | "Address 1" = register 0 (Modicon numbering 40001), or register 1 | Decides the Address offset of the Modbus gateway. |
| Type of each 32-bit value | Integer (DINT) or float (REAL) | int32BE or floatBE. Tell the SCADA integrator that a REAL is a 32-bit float on two registers, not a DWORD. |
| Word order | High word first (standard) or low word first | floatBE / int32BE, or the _sw variants (see Byte, word and bit order). |
Recommended Modbus gateway settings. Keep Address offset at -1 (the default of a new gateway): %M1 is then register 0, Modicon 40001, which matches "index 1 = address 1" in most SCADA documents. Tick FillWithZeros, so that the SCADA reads 0 instead of an error for a register that has no value yet.
Worked example — a measurement frame read by the SCADA, holding registers, 32 bits, starting at the first register, and a command frame written by the SCADA, coils:
| Frame | Index | Gateway address | Bus register | Modicon |
|---|---|---|---|---|
| Measurements (32 bits) | 1 | %M1 |
0–1 | 40001 |
| Measurements (32 bits) | 2 | %M3 |
2–3 | 40003 |
| Measurements (32 bits) | 3 | %M5 |
4–5 | 40005 |
| Commands (bits) | 1 | %MX1 |
coil 0 | 00001 |
| Commands (bits) | 2 | %MX2 |
coil 1 | 00002 |
Check the first and the last line of each frame with the SCADA integrator: if they match, the whole frame matches.
The tag names of the SCADA rarely equal the PLC variable names: PUMP1_RUN on one side, MAIN.Pumps.Pump1.Run on the other. Match them in this order:
., /, _, - or a space): Pump1_Run matches MAIN.Pumps.Pump1.Run on pump1 run._FB is Feedback in the PLC") are applied only when stated, never guessed.Keep three lists: matched tags, ambiguous tags with their candidates, and tags without any PLC variable. The last ones still get their Modbus address (the frame expects every index), without route: ask the PLC programmer for them.
The address table. One Modbus address per index of each frame, unmatched tags included, with:
bit, DINT or INT → int32BE, REAL → floatBE;The routes. For each matched tag, one route between the Modbus address and the PLC address, in the direction of the frame.
The missing PLC addresses. The matched PLC variables that do not exist yet on the PLC gateway, with a refresh period for those the SCADA reads.
Import in this order, from the address table of each gateway (Import file) and from the Routes table (Import):
Importing the addresses first lets each route find its two ends at once. On an ADS gateway, each imported address subscribes to the PLC: import gateway by gateway, and split the import in several batches above about a thousand addresses.
Check the result. In the routes table, no route should show an orange dot (No match found). Read a few values from the SCADA and compare them with the PLC, starting with the first and the last index of each frame, then write one command from the SCADA and check it in the PLC.
The AI assistant of the device applies this method with deterministic tools, so that the matching is reproducible:
The generation of the missing PLC addresses targets Beckhoff ADS. With another PLC driver, the assistant matches the tags against the addresses already on the PLC gateway; create the missing PLC addresses yourself.
| Symptom | Cause and fix |
|---|---|
| All values are shifted by one register | Address offset of the Modbus gateway does not match the addressing base of the SCADA (-1 versus 0). |
| 32-bit values are scrambled or huge | Word order: try the _sw variant of the datatype, or the frame is read with a different width. |
| Every second value is wrong | The SCADA reads the frame as 16-bit values while the table uses 32 bits (or the reverse). |
| The SCADA gets an exception on some registers | The register has no address or no value yet: tick FillWithZeros, check that the frame is complete. |
| A route shows No match found | One end of the route does not exist: import the PLC addresses and the Modbus table before the routes. |
| Values read by the SCADA never change | The PLC address has no refresh period (CycleTime empty on ADS). |