Skip to content

alexanderj-castillo/PLC-CODESYS-BottlingLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🏭 Automated Bottling Line — Digital Twin Simulation

PLC Programming & Industrial Automation | CODESYS V3.5

Automated Bottling Line


📌 Project Overview

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.

🎯 Engineering Challenge

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

🛠️ Tools & Technologies

  • 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

⚙️ System Architecture

Phase 1 — Shift Register (Conveyor Logic)

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.

Phase 2 — Modular Function Blocks

FB_FillingStation encapsulates all filling logic:

  • Edge detection prevents double-filling via name-change tracking
  • Dynamic timing via CASE statement 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

Phase 3 — Quality Control

FB_QualityCheck at the end of the line:

  • Flags bottles as _REJECT if 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

Phase 4 — Persistence & Diagnostics

  • RETAIN variables 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

📊 Key Results

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)

🔗 Industry 4.0 Connection

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.

📂 Repository Structure

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

About

Modular automated bottling line simulation in CODESYS using Structured Text and Ladder Logic · CODESYS · PLC · Industry 4.0

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors