PLC data logging without touching the PLC program means reading values the controller already holds, over a protocol it already serves, from a separate gateway or computer. Production reporting rests on three signals per machine: its state, a good-part counter and a reject counter, read every few seconds and stored with time stamps.
I build dashboards for plants, and every OEE or shift report depends on numbers that already sit inside the controller. I want to read them without anyone opening the PLC program, because every change to logic that runs a machine has to be tested and owned by someone.
How do you read data from a PLC to a database?
Put a gateway or a small computer on the machine network, let it poll the PLC with a protocol the PLC already serves, and have it write named, time-stamped values to a database. If the PLC serves Modbus, over TCP or a serial RS-485 line, the program stays untouched as long as the values are already mapped to Modbus addresses.
The Modbus application protocol specification defines four tables, and the logger only needs to read them:
| Table | Size | Access | Read with |
|---|---|---|---|
| Coils | 1 bit | Read-write | Function code 01 |
| Discrete inputs | 1 bit | Read-only | Function code 02 |
| Holding registers | 16-bit word | Read-write | Function code 03 |
| Input registers | 16-bit word | Read-only | Function code 04 |
One read request returns up to 125 contiguous registers, so values that sit in one block come back in a single request. A logger that sends only function codes 01 to 04 cannot change anything in the controller. Register addresses, offsets and 32-bit values are covered in Modbus register addressing.
Which PLC tags do you need for production reporting?
Start with three per machine: a state, a good-part counter and a reject counter. If the PLC already holds a stop reason code, read it too. Most of a production board, from downtime minutes to output per shift, can be worked out from those three and the clock.
- Machine state: often one integer such as 0 stopped, 1 running, 2 fault; ask the PLC programmer what each value means. It gives you run time and stop time.
- Good count: a counter that only goes up. Output per hour and per shift is the difference between two readings.
- Reject count: the same kind of counter for scrapped parts.
Hermetry connects field devices to live dashboards, rules and alerts: IoT telemetry and SCADA in one platform. Its Hermetry Edge software runs on licensed gateways and reads field devices such as Modbus RTU over RS485, Modbus TCP, OPC UA servers and BACnet/IP devices; which protocols are available depends on the gateway model. Each PLC appears as its own child device, and the gateway sends everything over one outbound TLS connection, so nothing on the shop floor needs to accept connections from the internet.
How often should you poll a PLC?
Counters can be read every 10 to 60 seconds without losing a part, because they keep their total between polls. Machine state is different: a stop shorter than the poll interval can fall between two reads and never appear.
So I would poll the state every second or two, and read a stop counter too if the PLC keeps one, since a missed short stop still shows in the count. Two more details matter:
- A 16-bit counter tops out at 65,535, or at 32,767 if the PLC treats it as signed, and then wraps or stops, depending on the PLC. If the PLC offers a 32-bit counter in two registers, prefer it and check its word order, which the Modbus specification leaves to the device maker.
- Treat a counter that goes down as a wrap or a reset, not as negative production. Store the raw counter and compute the differences afterwards.
Time-stamp each reading when the gateway reads it, in UTC. For what a full production setup tracks, see monitoring for manufacturing and production tracking with machine states and counters.
Frequently asked questions
Can data logging slow down or disturb the PLC?
Polling adds communication work, so keep it modest. Read contiguous blocks (up to 125 registers per request with function code 03) instead of one request per tag, poll no faster than the report needs, and check the controller’s limit on simultaneous connections before adding another client.
Should the logger ever write to the PLC?
Not for reporting. Modbus writes coils and registers with function codes 05, 06, 15 and 16, and codes 22 and 23 change registers too, so a logger that sends them can change how the machine behaves. Limit the logger to the read codes 01 to 04 and leave any write path to the people who own the machine.
Do you need the PLC programmer for data logging?
Yes, once. The Modbus specification leaves the mapping between its tables and the controller’s memory entirely to the device maker, so someone who knows the program has to tell you which addresses hold the state and the counters, and what each state value means. After that, nobody needs to open the program again.

