An advanced, industrial-grade simulated PLC project designed for the textile industry, focusing on fabric dyeing automation and precise chemical dosing. Developed using Siemens TIA Portal, this project demonstrates high-level PLC programming techniques including complex State Machines, Cascade PID Control Loops, and Data Block-driven Recipe Management.
| Feature | Technology | Description |
|---|---|---|
| Recipe Management | UDT + Data Blocks | Manages 20+ fabric/dye recipes with structured arrays (water volume, target temp, dose times) |
| Cascade PID Control | PID_Compact (Master/Slave) |
Master PID controls temperature setpoint; Slave PID modulates the steam valve proportionally |
| Precision Timer Dosing | TON (Timer On Delay) |
Millisecond-accurate pump control for Chemical A & B based on active recipe parameters |
| State Machine | SET/RESET Interlock |
5-phase sequential logic: Intake → Heating → Dosing → Cooling → Draining |
| Analog Processing | NORM_X / SCALE_X |
Converts raw PT100 sensor input (0–27648) to engineering units (0.0°C – 150.0°C) |
| Alarm System | Set/Reset Latching | Motor overload detection with HMI-triggered alarm acknowledgment |
| HMI Integration | KTP700 Basic Panel | Real-time monitoring, recipe selection, trend curves, and alarm views |
The system follows a fully automated batch process controlled by a Finite State Machine (FSM):
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ PHASE 1 │───▶│ PHASE 2 │───▶│ PHASE 3 │───▶│ PHASE 4 │───▶│ PHASE 5 │
│ INTAKE │ │ HEATING │ │ DOSING │ │ COOLING │ │ DRAINING │
│ │ │ │ │ │ │ │ │ │
│Water Valve│ │Cascade │ │Chemical │ │Cold Water│ │Drain │
│Opens │ │PID Active│ │Pumps Run │ │Valve Open│ │Valve Open│
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘
Trigger: Trigger: Trigger: Trigger: Trigger:
START Button Water Level Temp >= Target Dose Timer Q Temp <= Safe
>= Recipe (PID Mode=3) (Pumps Stop) (e.g. 40°C)
- Preparation: The operator selects a recipe via the HMI (e.g., Recipe ID: 5) and presses LOAD. The PLC copies the recipe's parameters from
DB_RecipesintoDB_Active_Process. - Phase 1 – Water Intake: The START button activates
Step_1_Su_Alma. The water inlet valve (Q0.1) opens. When the flow meter reading reaches the recipe's target volume, the system transitions to Phase 2. - Phase 2 – Heating: The Cascade PID system engages (
Mode = 3). The Master PID reads the current water temperature and drives the Slave PID, which modulates the steam valve. OnceCurrent_Temp >= Target_Temp, the system advances. - Phase 3 – Chemical Dosing: PID loops are deactivated (
Mode = 0). Chemical pumps activate for the duration defined by the recipe'sTONtimer. When the timer expires (Q = TRUE), pumps stop and the system transitions. - Phase 4 – Cooling: The cooling water valve (
Q0.2) opens. The system monitors temperature until it drops below the safe threshold (e.g., 40°C). - Phase 5 – Draining: The drain valve (
Q0.3) opens. Level sensors confirm the tank is empty, triggering a Master Reset to return the machine to an Idle – Ready for New Batch state.
While this simulation focuses on textile dyeing, the underlying Ladder Logic / SCL architecture is highly transferable to various industrial sectors:
| Industry | Application |
|---|---|
| Textile & Garment | Industrial washing machines, bleaching systems, precision fabric dyeing |
| Food & Beverage | Batch pasteurization, CIP (Clean-In-Place) systems, ingredient mixing |
| Chemical Processing | Reactor tank temperature control, sequential blending, hazardous material dosing |
| Pharmaceuticals | Sterile batch processing with exact thermal curves and interlocked sequential steps |
| Water Treatment | Multi-stage filtration and chemical treatment with PID-controlled dosing |
| Plastics & Rubber | Extrusion temperature profiling and additive injection control |
- Open the project in TIA Portal (v16 or newer).
- Navigate to PLC_1 → Right-click → Properties → Protection & Security.
- Enable "Support simulation during block compilation".
- Right-click the project root → Compile → Hardware and Software (rebuild all).
- Click Start Simulation from the toolbar to launch PLCSIM.
- Open the HMI Runtime simulation to interact with the system (select recipe, press START, monitor phases).
1. Precise Chemical Dosing with Timers in SCL
- Challenge: Initially, using a standard
TON(Timer On Delay) for dosing caused synchronization issues. The pumps would theoretically activate after the timer finished, rather than remaining active precisely during the dosing window. - Solution: Refactored the SCL logic to utilize a
TP(Pulse Timer) and incorporated edge triggers (F_TRIG). This ensures the chemical pumps activate immediately upon entering the Dosing phase and halt exactly when the required pulse duration is reached, safely triggering the transition to the Cooling phase.
2. Reliable Cascade PID Activation
- Challenge: In SCL, simply assigning the integer
3to thePID_CompactModeparameter was insufficient to reliably switch the controllers into automatic mode during high-speed state transitions. - Solution: Implemented
R_TRIG(Positive Edge) instances within the state machine structure. When the system enters the Heating phase, the edge trigger pulses theModeActivatepin of both the Master and Slave PIDs. This guarantees a safe, instantaneous, and bumpless transfer to automatic control.
- IDE: Siemens TIA Portal V16+
- PLC: S7-1200 / S7-1500
- HMI: KTP700 Basic (PN)
- Simulation: PLCSIM Advanced + WinCC Runtime
- Languages: Ladder Logic (LAD), Structured Control Language (SCL)
- Key Blocks:
PID_Compact,MOVE,TON,NORM_X,SCALE_X,CMP