Manufacturing specialty | PLC & DAQ data collection

PLC and Industrial Data Acquisition for SQL Server and Production Reporting

A tag value is not a production record. Turning machine signals into useful history requires decisions about sampling, state detection, timestamps, buffering, and what happens when the database is not there.

Data collection is treated as a read-only integration. Changes to control logic, safety systems, or equipment commissioning are scoped separately with qualified controls engineering.

Questions and answers

A blue operator control console with illuminated pushbuttons and selector switches.
A controller exposes signals and state; the collector has to turn them into events a production record can use.

Expert Tech Pilot provides PLC data collection and industrial data acquisition for plants that need production records from equipment they already run. Most plants can collect data. Fewer can answer a production question from it. The difference is usually not the driver or the database. It is whether the collection design preserved the event, the identifier, and the time — and whether it kept working when a switch rebooted or a query locked a table.

Automated manufacturing data collection and PLC data logging

PLC data collection is usually bought for a production reason before anyone asks about a database schema. A plant wants to know how many parts ran, how long a machine was down, why it stopped, and whether the cycle met the standard. The collector turns controller signals into records that answer those questions. A machine data integration project starts with those questions, not with the software.

A useful collection design captures the following.

  • Counts and cycles. Part counts, cycle starts and completions, and the difference between planned and actual output.
  • Machine states. Running, idle, blocked, starved, faulted, and setup, with the transition time recorded.
  • Downtime and reason codes. Stop events paired with an operator-entered reason where the process supports it.
  • Alarms and faults. The fault word or alarm state that explains an abnormal cycle or stoppage.
  • Quality flags. Reject, rework, or hold status, and the measurement context when one exists.
  • Timestamps and identity. Source time, equipment identifier, work order, and lot or batch where available.

Two records come out of this. Raw samples preserve the process at the collection interval. Derived business events describe what happened in production terms, such as a completed cycle, a downtime interval, or a rejected part. Reporting reads the business events and troubleshooting reads the raw samples. The mixer example and the equipment-state model below show how the second record is built from the first.

Collection is not control

Reading a PLC tag is an observation. Writing one is a control action. The two carry different risk, different change control, and different engineering ownership. A data collection project should start with the narrowest read-only access that answers the question, even when the platform makes writes technically easy.

This matters in practice. A collector that polls a controller adds network traffic and connection load. A subscription that requests a fast update rate can change the controller's communication behavior. Neither is automatically harmful, but both should be sized and tested rather than assumed. The control system's scan time and safety functions belong to the controls engineer; the data path should not compete with them.

Ways to read a PLC

PLC data access options and their constraints
Path Typical environment Constraint
Native driverSiemens S7, Rockwell CIP, Mitsubishi, OmronVendor or third-party driver licensing; version coupling; security depends on the protocol
OPC UA serverModern PLCs and gatewaysServer must be licensed and configured; browse structure and security policy matter
Modbus TCPSimple devices, legacy controllersRegister map only; no tag semantics, no quality status, byte order must be confirmed
Edge gatewayMixed vendor environmentsAdds a device to maintain; local buffering and protocol translation happen there
Direct DAQAnalog sensors not connected to a PLCBypasses the control system; scaling and isolation become the software's responsibility
Historian APIData already in SCADA or a historianDepends on what the historian recorded; missing tags cannot be recovered later

Tags, data types, and quality

A tag is not a number. It has a data type, an address, an engineering unit, a quality status, and a time. The collector needs all five or it will produce records that look complete and are not.

  • Integer scaling. A PLC may store 4–20 mA as 0–27,648 counts, or a temperature as tenths of a degree. The engineering conversion belongs in a documented configuration, not a magic number in code.
  • Byte order. Modbus registers are big-endian, and a 32-bit value spans two registers. A float built from the wrong word order produces a plausible but wrong number; it does not throw an error.
  • Structures and arrays. A recipe or a batch record may be an array of values. Reading element 0 without reading the associated length or sequence can associate the wrong value with the wrong item.
  • Quality. OPC UA exposes a status code — good, uncertain, bad, stale. A bad-quality read is not a zero. Store the quality flag and reject or mark the record rather than writing a value that downstream reports will average.
  • Staleness. A subscription can stop updating while the last value remains in memory. The collector needs a freshness check, not just a successful read.

Polling versus event-driven collection

Polling reads every tag at a fixed interval. It is simple, predictable, and easy to reason about. Its weakness is that the interval defines what can be seen: a three-second transition between two one-second polls may never appear, and a totalizer that increments between polls yields only the difference, not the sequence.

Event-driven collection reads on change or on a trigger. It reduces traffic and catches short transitions, but it introduces ordering, duplicate suppression, and reconnection problems. A subscription that drops and reconnects may deliver the current value without the changes that occurred while it was gone.

Choosing between polling and event-driven acquisition
Question Polling is better when Events are better when
What is being measured?Slow process values: temperature, level, pressureDiscrete transitions: cycle start, fault, part present
What is the cost of a missed value?Low; the next sample is representativeHigh; the event may not repeat
What is the network budget?Sufficient for a fixed request rateConstrained; only changes should cross the link
What can the PLC support?Read requests without custom logicSubscription, message, or change-detection support

Many useful designs use both. Poll slow analog values on a fixed interval, subscribe to state and fault bits, and derive production events from the combination. The event record stores the transition; the analog history explains what the process was doing around it.

Time synchronization and timestamps

A PLC clock can drift by minutes over months, and not every controller supports NTP. If the collector timestamps on arrival, a network delay becomes a process delay. If it trusts the PLC clock, a drift becomes a data-quality problem that is invisible until someone compares two systems.

Use a defined time source and record it. Common patterns:

  • Source timestamp from the PLC or OPC UA server, with the collector's ingest time stored separately for latency analysis.
  • Collector timestamp when the source has no usable clock, with the limitation documented and the collector synchronized to NTP.
  • Sequence number from the PLC when ordering matters more than wall-clock precision. A monotonic counter survives a clock correction.

Store UTC. Derive shift, day, and plant-local reporting time from a configured time zone. Storing local time makes the daylight-saving transitions ambiguous and makes a plant that runs three shifts harder to report on, not easier.

Data volume arithmetic

Data volume is easy to underestimate because the per-sample number looks small. The following calculation is illustrative and shows the arithmetic, not a storage recommendation.

Worked example — 10 measurements per second

10 samples/s × 86,400 s/day = 864,000 samples/day 864,000 × 30 days = 25,920,000 samples/month

That is a sample count, not a database size. A row with a timestamp, tag identifier, value, quality, and key might carry 60 bytes of payload, but the clustered index, a nonclustered index, page overhead, and transaction log activity add substantially more. At an illustrative 150–300 bytes of effective storage per row, the same month is roughly 3.9–7.8 GB before compression. The real figure depends on schema, indexing, data types, and retention.

Now compare event-based collection for the same equipment. Forty batches a day with eight recorded events and ten summary values produces about 3,200 event rows per day — roughly 96,000 per month. The two designs answer different questions, and the second is two orders of magnitude smaller.

Neither number is inherently right. A trend needs raw samples; a production report needs events and summaries. Collecting both is common: a high-resolution series for a bounded window, and durable event records for the production history. What should be avoided is collecting every raw sample forever because nobody decided what the data was for.

A mixer cycle, from bits to a production record

Consider an illustrative batch mixer with a run state, a discharge totalizer, and a temperature transmitter. The control system knows when the mixer is running. The data collector's job is to turn that state into a cycle record that production and quality can use.

Illustrative mixer signals and their use
Signal Type Use in the record
Run stateInteger or bitCycle boundary and equipment state
Mixer temperatureAnalog, 1 HzAverage and maximum during the cycle
Discharge totalizerAccumulating integer or realBatch quantity from the difference, with reset handling
Batch identifierString or integerAssociation with the work order and lot
Fault wordBit arrayCycle validity and investigation context
Worked example — one cycle

cycle start: 2026-11-14 08:14:02.310 UTC cycle end: 2026-11-14 08:32:44.310 UTC duration: 1,122 s = 18 min 42 s

totalizer start: 12,480.0 kg totalizer end: 13,742.5 kg batch mass: 13,742.5 − 12,480.0 = 1,262.5 kg

average discharge rate = 1,262.5 kg / 1,122 s = 1.125 kg/s ≈ 67.5 kg/min

At a 1 Hz temperature sample, the same cycle produces 1,122 temperature readings. If the average is 148.6 °F, that is 64.8 °C. The summary record can store the average, minimum, and maximum; the raw series can remain in a historian or a bounded detail table.

The totalizer is a good example of a signal that looks simpler than it is. Some controllers reset it on batch completion; some roll over at a maximum value; some continue accumulating across batches. The collector must know which behavior applies. Taking a difference without handling a reset produces a negative or absurd batch mass.

Equipment-state detection

A production-cycle boundary is a decision, not a raw tag. The controller may expose an explicit state, or the state may have to be inferred from a combination of run bits, totalizer movement, and valve positions. If it is inferred, document the inference and its failure cases.

A defensible state model uses named states and explicit transitions:

IDLE       → FILLING     when fill valve is open and totalizer is increasing
FILLING    → MIXING      when fill valve closes and agitator run bit is true
MIXING     → DISCHARGING when discharge valve opens
DISCHARGING→ IDLE        when discharge valve closes and totalizer is stable for 30 s

Cycle start  = transition into FILLING with a valid batch identifier
Cycle end    = transition into IDLE after DISCHARGING
Invalid cycle = any transition to IDLE from MIXING or FILLING

Illustrative pseudocode. The actual state names and transitions must match the equipment's control logic.

  • Debounce. A single scan of a fluttering bit should not create a cycle. Require the state to hold for a minimum duration or a minimum number of samples.
  • Hysteresis. A totalizer hovering at a threshold should not produce repeated start events. Use a deadband and a stable-duration condition.
  • Minimum and maximum cycle duration. A 4-second "cycle" is probably a transition artifact; a 36-hour cycle is probably a missed end event. Flag both instead of storing them as normal production.
  • Invalid completion. If the cycle ends without a discharge, record the cycle as incomplete rather than silently omitting it. The omission is the data quality problem.

Machine signals for OEE and downtime analysis

Overall equipment effectiveness (OEE) is a reporting calculation, not a PLC tag. It combines availability, performance, and quality, and each one depends on signals and definitions that have to be agreed before the dashboard means anything.

  • Availability. Depends on run state, stop events, and planned production time. Decide which stops count as downtime and which planned stops are excluded.
  • Performance. Depends on counts, cycle time, and the ideal rate for each product. Decide how changeover time is treated.
  • Quality. Depends on good count and reject or rework flags. Decide whether rework counts as good and where the quality result comes from.

The human-entered reason code is often the weakest link. A stop event is reliable because the controller produces it. The reason depends on an operator choosing from a list at the end of a shift, and the list is usually too long, too vague, or both. A short, stable reason list with an unknown option produces more usable data than a detailed list that gets a default value.

This page covers the collection layer. The reporting schema, validated calculations, and dashboard work are described on the manufacturing data integration page. No OEE improvement is claimed here, because the calculation only reflects what the plant already does.

Buffering, retry, and recovery

The collector is the part of the system that sees the plant. It is also the part most likely to face a network interruption, a database maintenance window, or a gateway restart. A production event recorded only in memory is lost on restart.

  • Durable local queue. Write events to a local store before acknowledging them to the source. SQLite, a local file with a defined format, or a message broker's persistent store can serve; the choice depends on volume and operational familiarity.
  • Bounded storage. Decide what happens when the buffer fills: stop accepting, drop oldest, or raise an alarm. An unbounded buffer eventually fills the disk and takes the collector down.
  • Idempotent delivery. Assign a stable business key to each event and enforce it in the destination. Replay after an outage must not duplicate production completions.
  • Ordered replay. If order matters, replay in source sequence and let the destination reject or reconcile an out-of-order record. If order does not matter, say so explicitly.
  • Visible state. Expose queue depth, oldest pending item age, and last successful write. These are the metrics that tell an operator the integration is unhealthy before the report is wrong.

Talk it through

Trying to collect reliable data from industrial equipment?

Bring the tags, the machine, or the report that is missing cycles. You can walk the signal path with the architect who would design the collection and logging layer, without a handoff to a separate implementation team. Start with a free 40-minute session.

Discuss Data Acquisition

SQL Server schema, indexing, and retention

Separate raw samples from production events. They have different volumes, retention rules, and query patterns, and mixing them produces a table that is expensive to query and hard to explain.

CREATE TABLE dbo.CycleEvent (
  CycleId          uniqueidentifier NOT NULL PRIMARY KEY,
  EquipmentId      nvarchar(32)     NOT NULL,
  JobId            nvarchar(32)     NULL,
  BatchId          nvarchar(32)     NULL,
  CycleStartUtc    datetime2(3)     NOT NULL,
  CycleEndUtc      datetime2(3)     NULL,
  StartTotalizerKg decimal(18,3)    NULL,
  EndTotalizerKg   decimal(18,3)    NULL,
  AvgTempF         decimal(9,3)     NULL,
  MaxTempF         decimal(9,3)     NULL,
  CompletionStatus tinyint          NOT NULL,
  EventSource      nvarchar(32)     NOT NULL,
  CONSTRAINT UQ_CycleEvent UNIQUE (EquipmentId, CycleStartUtc)
);

CREATE INDEX IX_CycleEvent_Start ON dbo.CycleEvent (CycleStartUtc)
  INCLUDE (EquipmentId, CycleEndUtc);

Illustrative schema. Add operator, recipe, and fault columns as the process requires. CompletionStatus distinguishes a normal end from an inferred or invalid one.

SELECT EquipmentId,
       CAST(CycleStartUtc AS date) AS ProductionDate,
       COUNT(*) AS Cycles,
       SUM(EndTotalizerKg - StartTotalizerKg) AS TotalKg,
       AVG(DATEDIFF(second, CycleStartUtc, CycleEndUtc)) AS AvgCycleSeconds
FROM dbo.CycleEvent
WHERE CycleEndUtc IS NOT NULL
  AND CycleStartUtc >= @FromUtc
  AND CycleStartUtc <  @ToUtc
GROUP BY EquipmentId, CAST(CycleStartUtc AS date)
ORDER BY ProductionDate, EquipmentId;

A report query that uses the event table, not the raw sample table. The filter is on the clustered time range so the index is useful.

Retention is a design decision, not an afterthought. Raw samples may be kept for 30–90 days and summarized into hourly or shift aggregates. Event records usually need to live as long as the production traceability requirement, which may be years. Partitioning by month or by year makes archival and deletion practical; deleting millions of rows from a live table is not.

OT network security for a collector

  • Place the collector in a defined zone. An edge device that talks to PLCs and to the enterprise should sit in a DMZ or a segmented industrial zone, not on a flat plant network.
  • Initiate outbound. The collector should connect to the database and the enterprise service. Inbound connections from the enterprise to the plant should be the exception.
  • Use read-only accounts. Where the PLC or OPC UA server supports it, grant read-only access to the exact tags required. Do not reuse an engineering account.
  • Protect credentials. Store them in a protected configuration store, not in a script or a plaintext file on a shared drive. Rotate them on a schedule.
  • Patch with a plan. An edge device runs an operating system. It needs patching, antivirus exclusions for the data directory, and a tested recovery image.

Failure modes and what to do about them

PLC data collection failure modes and mitigations
Condition Symptom Mitigation
PLC unreachableNo new samples; last value persistsFreshness check, reconnect with backoff, alarm on stale data
Bad tag qualityValue arrives with bad or uncertain statusStore quality; quarantine or flag; never substitute zero
Database outageWrites fail; queue growsDurable buffer, bounded size, retry, dead-letter, visible depth
Duplicate replaySame cycle counted twiceUnique business key and idempotent insert
Clock driftEvents out of order or shiftedNTP, source sequence, ingest timestamp, drift alarm
Counter resetNegative or absurd batch massDetect reset, store both readings and the reset flag
Missed transitionCycle missing or mergedFaster subscription, state-change logging in the PLC, or a documented sampling limit

Start with the signal

What production question can the current data not answer?

Bring the machine, the tag list, or the report that is missing cycles. A free session is enough to decide whether the answer is a better collector, a better event model, or a small change to the control system.

Or email Gene.Farber@ExpertTechPilot.com
Call (216) 236-3987