Learn Automation with MINATA #74: Barcodes and Traceability — Turning a Scan Into Data With Context
Barcodes and Traceability: Turning a Scan Into Data With Context
A scan is only worth something when the system knows what the code is, where it was scanned, at what moment, and which decision it feeds. Fitting the scanner first and thinking about the data afterwards produces a stream of characters that nobody can safely use.
Design the data contract first
Before the scanner is mounted, design the data contract: the structure of the code, the master data it refers to, lot and serial numbers, length, permitted characters, valid states, the source of the data, and the response when nothing matches. That a scanner can read a string does not mean the PLC or the MES can safely act on it. Validate before it is allowed to influence the machine.
Tie the scan to a station and a state
Each scanning point must be tied to a station and to the state of the machine. When material is scanned into a machine, the system needs to know the current recipe, the order, the operator or role where required, and the validation result — is this the right material for this order? The same code scanned at two different points means two different things.
Error handling and audit
When a scan produces an invalid code, or one that does not match the order, the system must respond clearly and record it. Never allow endless rescanning to get past an error with no trace left behind. Traceability is only trustworthy when every scan — including the failed ones and the overrides — carries an audit record: who, when, where, and with what result.
A worked engineering situation
At the loading station, the operator scans the material lot code, and the system compares it against the recipe of the order currently running. If it matches, the machine permits loading and writes the lot into the batch history. If not, the HMI reports "material does not match the order", blocks the step, and records the failed scan. Later, tracing a finished lot yields exactly the materials that went into it.
The code structure, the validation rules and the storage all follow the traceability requirements and the MES or ERP systems involved.
Common mistakes
- Fitting the scanner before designing the data contract.
- Letting a scanned string influence the machine without validation.
- Not tying the scanning point to a station and a machine state.
- Allowing endless rescans to get past an error, with no audit.
- Not storing lot or serial against the batch, losing traceability.
Barcode and traceability checklist
- [ ] A data contract exists: code structure, master data, validity rules.
- [ ] Scanned strings are validated before they affect the machine.
- [ ] Each scanning point is tied to station, state, recipe and order.
- [ ] Scan errors produce a clear response and an audit record.
- [ ] Lot and serial are stored against the batch for later tracing.
A scan with context is what turns an action into traceable data. #75 turns to OPC UA: modelling the data before connecting the PLC to the systems above it.
Read more automation knowledge at MINATA: https://minatavn.com/en/blog/industrial-automation
Previous — #73: Process sensors: temperature, pressure and level: https://minatavn.com/en/blog/automation-73-process-sensors-temp-pressure-level
Next — #75: OPC UA for data integration: https://minatavn.com/en/blog/automation-75-opc-ua-data-integration
View all MINATA technical articles