PLC Programming & Industrial Automation | CODESYS V3.5
This project implements a fully automated bottling line simulation in CODESYS V3.5, designed as a Digital Twin that replicates realistic production variance and quality control logic. The goal was to bridge industrial PLC programming with data science thinking — introducing statistical noise into the simulation to generate a realistic dataset for process diagnostics.
Design a modular, scalable PLC architecture that:
- Synchronizes product metadata (ID, size, fill volume) across conveyor stations using a shift register
- Detects and rejects out-of-tolerance bottles automatically
- Persists production KPIs across power cycles using non-volatile memory
- Provides real-time HMI visualization of process state and diagnostics
- CODESYS V3.5 — PLC development platform
- Structured Text (ST) — Core logic: shift register, Function Block internals, randomization, CASE statements
- Ladder Logic (LD) — High-level sequence triggers, conveyor movement
- HMI / Visualization — Visibility-based animations, combo-box controls, real-time data readouts
- Trend & Trace Manager — Volume consistency monitoring, high-resolution signal capture
A Global Variable List (GVL) stores an array of STR_BottleRecord
structures. A FOR loop shifts records between array indices each cycle,
simulating physical conveyor movement while preserving bottle metadata
(ID, size enum, fill volume) across stations.
FB_FillingStation encapsulates all filling logic:
- Edge detection prevents double-filling via name-change tracking
- Dynamic timing via
CASEstatement adjusts fill duration by bottle size (Small vs. Large enum) - Noise injection uses PLC system time as a seed to generate ±1% volume variance — simulating real pump behavior
FB_QualityCheck at the end of the line:
- Flags bottles as
_REJECTif volume falls outside 99.7 ml – 100.3 ml tolerance band (3-sigma equivalent) - Triggers a Pusher actuator to clear rejected records from the array before final output
RETAINvariables preserve production counts and reject totals across system reboots- Trend Graph visualizes the sawtooth fill pattern and statistical variance of the pump
- Trace Manager captures high-resolution signals for process analysis
| KPI | Value |
|---|---|
| Fill volume tolerance | 99.7 ml – 100.3 ml (±0.3%) |
| Simulated pump variance | ±1% (noise injected via system time seed) |
| Data persistence | RETAIN variables — survives power cycle |
| Architecture pattern | Modular Function Blocks (FB) |
| Languages used | Structured Text (ST) + Ladder Logic (LD) |
This project demonstrates the OT/IT integration principle central to Industry 4.0: the PLC generates structured, variance-aware data that feeds directly into process diagnostics — creating the data foundation a predictive maintenance or quality analytics system would consume upstream.
PLC-CODESYS-BottlingLine/
│
├── README.md ← Project documentation
├── /src ← CODESYS project files (.project)
├── /docs ← Architecture notes and HMI screenshots
└── /images ← HMI screenshots, Trend graphs, simulation GIFs
