The Secret to a 20% Increase in Production Capacity—Practical Design of Siemens PLC Cleaning Agent Production Control System
The intelligent liquid mixing system for cleaning agents achieves high-precision automation control through Siemens PLC, increasing production capacity by 20% and reducing raw material waste by 15%, suitable for various detergent production lines.
1. Hardware Configuration
PLC and Expansion Module Selection
For small to medium-sized cleaning agent production lines, it is recommended to use the S7-1200 series PLC as the main control unit, specifically the CPU 1214C DC/DC/DC model, which has 14 digital input points, 10 digital output points, and 2 analog input points, meeting the basic requirements for simple liquid mixing control.
For large systems that require control of multiple raw material ratios, it is advisable to use the S7-1500 series, model CPU 1516-3 PN/DP, which has stronger data processing capabilities and larger program storage space.
Expansion module configuration:
-
Digital Input Module SM 1221 (16DI): Used to receive various switch signals
-
Digital Output Module SM 1222 (16DO): Controls various solenoid valves, motors, and other actuators
-
Analog Input Module SM 1231 (8AI): Receives signals from various sensors (temperature, liquid level, pH, etc.)
-
Analog Output Module SM 1232 (4AO): Controls frequency converters, regulating valves, and other proportional actuators
I/O Point Allocation Table
| Address | Description | Type | Remarks |
|———|————————|———–|—————————-|
| I0.0 | Start Button | Digital Input | System Start Signal |
| I0.1 | Stop Button | Digital Input | System Stop Signal |
| I0.2 | Raw Material A Upper Level | Digital Input | Float Switch |
| I0.3 | Raw Material A Lower Level | Digital Input | Float Switch |
| I0.4-7 | Raw Material B-E Level Switches | Digital Input | Similar to A Material Configuration |
| I1.0 | Mixing Tank Upper Level | Digital Input | Overflow Protection |
| I1.1 | Mixing Tank Lower Level | Digital Input | Dry Run Protection |
| I1.2 | Safety Door Status | Digital Input | Interlock Protection |
| IW64 | Mixing Tank Temperature | Analog Input | PT100, 0-100℃ |
| IW66 | pH Value | Analog Input | 0-14pH |
| IW68 | Raw Material A Flow Rate | Analog Input | 0-500L/h |
| Q0.0 | Raw Material A Feed Valve | Digital Output | Solenoid Valve Control |
| Q0.1-4 | Raw Material B-E Feed Valves | Digital Output | Solenoid Valve Control |
| Q0.5 | Mixing Motor | Digital Output | Stirring Control |
| Q0.6 | Finished Product Discharge Valve | Digital Output | Solenoid Valve Control |
| Q0.7 | Buzzer | Digital Output | Alarm Prompt |
| Q1.0 | Indicator Light – Running | Digital Output | Green LED |
| Q1.1 | Indicator Light – Fault | Digital Output | Red LED |
| QW80 | Heating Control | Analog Output | 0-10V, Control Heating Power |
| QW82 | Regulating Valve A | Analog Output | 0-10V, Control Flow |
2. Control Program Design
Program Architecture Design
The control system program architecture for cleaning agent production adopts a hierarchical structure design, mainly including the following organizational blocks and functional blocks:
-
OB1: Main loop program, responsible for overall process scheduling
-
OB100: Startup organizational block, system initialization and parameter loading
-
OB82: Diagnostic interrupt block, handling hardware errors
-
FB10: Raw Material Control Function Block, handling the ratio control of various raw materials
-
FB20: Mixing Control Function Block, handling stirring and temperature control
-
FB30: pH Value Adjustment Function Block, controlling acid-base balance
-
FB40: Safety Monitoring Function Block, handling various abnormal states
-
FB50: Data Recording Function Block, recording production process data
-
DB10: Raw Material Parameter Data Block, storing formula parameters
-
DB20: Operating Status Data Block, storing system status
-
DB30: Alarm Data Block, storing alarm information
Function Block Design
Taking the Raw Material Control Function Block (FB10) as an example, this block is responsible for accurately controlling the amount of various raw materials according to the formula requirements:
1FUNCTION_BLOCK "Raw Material Control"// FB10
2
3{ S7_Optimized_Access := 'TRUE' }
4
5VERSION : 0.1
6
7 VAR_INPUT
8
9 Start_Signal : Bool; // Start raw material control
10
11 Formula_ID : Int; // Current formula number
12
13 Tank_Level : Real; // Current mixing tank level
14
15 END_VAR
16
17
18
19 VAR_OUTPUT
20
21 Control_Complete : Bool; // Raw material addition complete signal
22
23 Raw_Material_A_Valve : Bool; // Control raw material A solenoid valve
24
25 Raw_Material_B_Valve : Bool; // Control raw material B solenoid valve
26
27 Regulating_Valve_A_Value : Int; // Control regulating valve A opening
28
29 Current_Status : Int; // Control status indication
30
31 END_VAR
32
33
34
35 VAR
36
37 Target_A_Amount : Real; // Current target amount of raw material A in the formula
38
39 Target_B_Amount : Real; // Current target amount of raw material B in the formula
40
41 Current_A_Amount : Real; // Current added amount of A
42
43 Current_B_Amount : Real; // Current added amount of B
44
45 State_Machine : Int := 0; // Internal state machine variable
46
47 END_VAR
48
49
50
51 VAR_TEMP
52
53 Difference_A : Real; // A amount difference
54
55 END_VAR
56
57
58
59BEGIN
60
61 // Load target values from formula data block
62
63 "Formula Data Block".Raw_Material_A[#Formula_ID] := #Target_A_Amount;
64
65 "Formula Data Block".Raw_Material_B[#Formula_ID] := #Target_B_Amount;
66
67
68
69 // State machine control
70
71 CASE#State_Machine OF
72
73 0: // Idle state
74
75 IF#Start_Signal THEN
76
77 #State_Machine := 10;
78
79 #Current_A_Amount := 0.0;
80
81 #Current_B_Amount := 0.0;
82
83 #Control_Complete := FALSE;
84
85 END_IF;
86
87
88
89 10: // Add Raw Material A
90
91 #Raw_Material_A_Valve := TRUE;
92
93
94
95 // Calculate opening: the less remaining amount, the smaller the valve opening, achieving precise control
96
97 #Difference_A := #Target_A_Amount - #Current_A_Amount;
98
99 IF#Difference_A < 10.0 THEN
100
101 #Regulating_Valve_A_Value := REAL_TO_INT(#Difference_A * 100.0);
102
103 ELSE
104
105 #Regulating_Valve_A_Value := 1000; // Fully open
106
107 END_IF;
108
109
110
111 // Accumulate current value (flow meter integration)
112
113 #Current_A_Amount := #Current_A_Amount + "Flow Integration"(Flow_Value:="Raw Material A Flow");
114
115
116
117 // Check if completed
118
119 IF#Current_A_Amount >= #Target_A_Amount THEN
120
121 #Raw_Material_A_Valve := FALSE;
122
123 #Regulating_Valve_A_Value := 0;
124
125 #State_Machine := 20;
126
127 END_IF;
128
129
130
131 20: // Add Raw Material B (code omitted, similar to Raw Material A)
132
133
134
135 100: // Completion state
136
137 #Control_Complete := TRUE;
138
139 #Current_Status := 100;
140
141
142
143 IF NOT #Start_Signal THEN
144
145 #State_Machine := 0; // Reset
146
147 END_IF;
148
149
150
151 END_CASE;
152
153
154
155 // Output current status
156
157 #Current_Status := #State_Machine;
158
159END_FUNCTION_BLOCK
Status Control Design
The cleaning agent production system uses a state machine to manage the process flow, mainly including the following states:
-
Standby State (0): System is ready, waiting for start command
-
Raw Material Addition (10-50): Add various raw materials in the order of the formula
-
Mixing and Stirring (60): Control stirring speed and time
-
Temperature Control (70): Control mixing temperature according to process requirements
-
pH Value Adjustment (80): Adjust product acidity
-
Quality Inspection (90): Check various indicators of the product
-
Discharge State (100): Discharge qualified products
-
Cleaning State (110): System cleaning
-
Alarm State (200): Handle various exceptions
State transitions are controlled by the main state machine in OB1, with each state corresponding to different function blocks, as shown in the following example:
1// State control code snippet in OB1
2
3CASE"DB20".SystemState OF
4
5 0: // Standby state
6
7 // Check system readiness
8
9 IF"Start Button"AND"DB20".SystemReady THEN
10
11 "DB20".SystemState := 10;
12
13 END_IF;
14
15
16
17 10: // Add Raw Material A
18
19 "FB10"(Start_Signal:=TRUE,
20
21 Formula_ID:="DB20".CurrentRecipe,
22
23 Tank_Level:="Mixing Tank Level");
24
25
26
27 IF"FB10".Control_Complete THEN
28
29 "DB20".SystemState := 20;
30
31 END_IF;
32
33
34
35 // Other state handling...
36
37
38
39 200: // Alarm state
40
41 "FB40"(Alarm_Reset:="Reset Button");
42
43 IF NOT "FB40".Valid_Alarm AND"Reset Button" THEN
44
45 "DB20".SystemState := 0; // Reset to standby state
46
47 END_IF;
48
49END_CASE;
3. Data Management and Storage
Parameter Configuration Table
The cleaning agent production control system needs to manage various formula parameters, using data blocks for storage:
1DATA_BLOCK "Formula Parameters"// DB10
2
3{ S7_Optimized_Access := 'TRUE' }
4
5VERSION : 0.1
6
7 STRUCT
8
9 Formula_Count : Int := 10; // Number of formulas supported by the system
10
11 Current_Formula : Int := 1; // Current formula ID in use
12
13
14
15 // Raw material ratio arrays [Formula ID, 1-10]
16
17 Raw_Material_A : Array[1..10] of Real; // Unit: kg
18
19 Raw_Material_B : Array[1..10] of Real;
20
21 Raw_Material_C : Array[1..10] of Real;
22
23 Raw_Material_D : Array[1..10] of Real;
24
25 Raw_Material_E : Array[1..10] of Real;
26
27
28
29 // Process parameter arrays [Formula ID, 1-10]
30
31 Target_Temperature : Array[1..10] of Real; // Unit: ℃
32
33 Stirring_Time : Array[1..10] of Time; // Unit: s
34
35 Target_pH_Value : Array[1..10] of Real; // pH value
36
37
38
39 // Formula name arrays
40
41 Formula_Name : Array[1..10] ofString[20];
42
43 END_STRUCT;
44
45BEGIN
46
47 // Predefined Formula 1 - Standard Laundry Detergent
48
49 Formula_Name[1] := 'Standard Laundry Detergent';
50
51 Raw_Material_A[1] := 100.0; // Basic surfactant
52
53 Raw_Material_B[1] := 50.0; // Additive
54
55 Raw_Material_C[1] := 10.0; // Fragrance
56
57 Raw_Material_D[1] := 5.0; // Preservative
58
59 Raw_Material_E[1] := 200.0; // Softened Water
60
61 Target_Temperature[1] := 45.0;
62
63 Target_pH_Value[1] := 7.2;
64
65
66
67 // Predefined Formula 2 - Concentrated Laundry Detergent
68 Formula_Name[2] := 'Concentrated Laundry Detergent';
69 Raw_Material_A[2] := 150.0;
70 Raw_Material_B[2] := 60.0;
71 Raw_Material_C[2] := 8.0;
72 Raw_Material_D[2] := 6.0;
73 Raw_Material_E[2] := 150.0;
74 Target_Temperature[2] := 50.0;
75 Target_pH_Value[2] := 7.5;
76
77
78
79 // Other formula presets...
80
81END_DATA_BLOCK
Alarm Information Management
Alarm information is stored using a dedicated data block, including alarm codes, descriptions, and handling methods:
1DATA_BLOCK "Alarm Data"// DB30
2
3{ S7_Optimized_Access := 'TRUE' }
4
5VERSION : 0.1
6
7 STRUCT
8
9 Current_Alarm : Array[1..10] of Int; // Current active alarms
10
11 Alarm_Count : Int; // Number of active alarms
12
13 Historical_Alarm : Array[1..100] of Struct // Historical alarm records
14
15 Alarm_Code : Int; // Alarm code
16
17 Alarm_Time : DTL; // Alarm occurrence time
18
19 Alarm_Description : String[50]; // Alarm description
20
21 Handling_Status : Bool; // Whether it has been handled
22
23 END_STRUCT;
24
25 Historical_Pointer : Int := 0; // Historical record pointer
26
27 END_STRUCT;
28
29
30
31 // Alarm handling function
32 METHOD Add_Alarm : Void
33
34 VAR_INPUT
35
36 Alarm_Code : Int;
37
38 END_VAR
39
40
41
42 VAR_TEMP
43
44 i : Int;
45
46 Exists : Bool;
47
48 END_VAR
49
50
51
52 BEGIN
53
54 // Check if the same alarm already exists
55
56 Exists := FALSE;
57
58 FOR i := 1 TO 10 DO
59
60 IF THIS.Current_Alarm[i] = Alarm_Code THEN
61
62 Exists := TRUE;
63
64 EXIT;
65
66 END_IF;
67
68 END_FOR;
69
70
71 // Add to current alarms
72 IF NOT Exists AND THIS.Alarm_Count < 10 THEN
73
74 THIS.Alarm_Count := THIS.Alarm_Count + 1;
75
76 THIS.Current_Alarm[THIS.Alarm_Count] := Alarm_Code;
77
78
79
80 // Add to historical records
81 THIS.Historical_Pointer := (THIS.Historical_Pointer MOD 100) + 1;
82 THIS.Historical_Alarm[THIS.Historical_Pointer].Alarm_Code := Alarm_Code;
83 THIS.Historical_Alarm[THIS.Historical_Pointer].Alarm_Time := Current_Time;
84 THIS.Historical_Alarm[THIS.Historical_Pointer].Handling_Status := FALSE;
85
86 // Set description based on alarm code
87 CASE Alarm_Code OF
88
89 1: THIS.Historical_Alarm[THIS.Historical_Pointer].Alarm_Description := 'Raw Material A Level Too Low';
90
91 2: THIS.Historical_Alarm[THIS.Historical_Pointer].Alarm_Description := 'Mixing Tank Level Too High';
92
93 3: THIS.Historical_Alarm[THIS.Historical_Pointer].Alarm_Description := 'Temperature Out of Range';
94
95 // Other alarm codes...
96
97 END_CASE;
98 END_IF;
99 END_METHOD
100
101END_DATA_BLOCK
4. System Debugging Methods
Step-by-Step Debugging Method
The debugging of the cleaning agent production system adopts a bottom-up step-by-step debugging method to ensure that each module is stable and reliable:
- Hardware Wiring Test
-
Check each I/O point for correct wiring
-
Use forced value function to verify each input and output point
-
Check sensor calibration and signal range
- Unit Function Test
-
Raw Material Control Module: Verify valve actions and flow control
-
Temperature Control Module: Test PID parameters and control stability
-
pH Value Adjustment Module: Verify acid-base addition control accuracy
- Interlocking Function Test
-
Complete process flow operation test
-
State machine transition test
-
Abnormal condition simulation test
- System Performance Test
-
Continuous production testing of multiple batches
-
Formula switching test
-
Control accuracy statistical analysis
Parameter Tuning Steps
Taking temperature PID control as an example, the parameter tuning steps are as follows:
-
Add an appropriate amount of test liquid to the mixing tank and start stirring
-
Set the P parameter to an initial value (e.g., 5.0), and I and D parameters to 0
-
Issue a step command for the target temperature and record the temperature response curve
-
Adjust the P value based on the response curve until the system has slight oscillation
-
Record the critical period Tc and critical gain Kc
-
Calculate according to the Ziegler-Nichols method:
-
Proportional Coefficient Kp = 0.6Kc
-
Integral Time Ti = 0.5Tc
-
Derivative Time Td = 0.125Tc
-
Input calculated parameters and retest the response
-
Fine-tune parameters based on response until optimal control effect is achieved
Abnormal Simulation Testing
Conduct comprehensive abnormal simulation testing on the cleaning agent production system to ensure system safety and reliability:
- Sensor Fault Simulation
-
Disconnect the temperature sensor, verify alarm and safety shutdown
-
Liquid level sensor false alarm, check system response
- Actuator Abnormal Simulation
-
Solenoid valve cannot close, verify overflow protection
-
Stirring motor overload, verify protection mechanism
- Process Abnormal Simulation
-
pH value out of range, verify adjustment mechanism
-
Temperature control deviation, verify alarm function
- Communication Abnormal Simulation
-
HMI communication interruption, verify local control function
-
Remote control failure, verify local takeover capability
5. User Interface Design
Interface Layout Description
The HMI design of the cleaning agent production system uses WinCC Advanced in TIA Portal, and the interface layout includes the following main screens:
- System Overview Screen
-
Displays the entire system flow chart
-
Dynamic display of the operating status of each device
-
Real-time display of key parameters
-
System status indication and alarm prompts
- Formula Management Screen
-
Display and selection of formula list
-
Display and editing of formula parameters
-
Formula import and export functions
-
New formula creation and deletion functions
- Production Control Screen
-
Start/Stop control buttons
-
Dynamic display of process flow
-
Real-time monitoring of operating parameters
-
Manual/Automatic mode switching
- Alarm Screen
-
Current alarm list
-
Historical alarm query
-
Alarm confirmation and reset
-
Fault diagnosis guidance
- Trend Record Screen
-
Curves of parameters such as temperature and pH value
-
Historical data query
-
Data export function
-
Curve comparison analysis
Parameter Setting Description
System parameter settings are divided into the following categories, each with different access permissions:
- Process Parameters: Only allowed to be modified by personnel at the engineer level or above
-
Temperature control PID parameters
-
pH value control parameters
-
Flow control parameters
- Production Parameters: Allowed to be modified by operators
-
Current production batch number
-
Production target amount
-
Operating speed adjustment
- Formula Parameters: Allowed to be modified by formula administrators
-
Ratios of various raw materials
-
Process temperature settings
-
Quality control parameters
The parameter setting page design includes input validity checks to avoid erroneous settings that could lead to production anomalies.
Experience Summary of Cleaning Agent Production Control System Integration
Through Siemens S7 technology, the cleaning agent production achieves efficient automation. The key lies in precise formula management, stable process control, and comprehensive abnormal handling. Feel free to consult and exchange more technical details!