The automation control of food wastewater treatment is directly related to environmental compliance and production efficiency. A control system based on Siemens PLC can achieve stable operation and precise management.
1. Hardware Configuration
Selection of PLC and Expansion Modules
Considering the characteristics of food wastewater treatment, it is recommended to use the Siemens S7-1200 series PLC as the core controller. This series has strong processing capabilities and good anti-interference, making it particularly suitable for industrial environments.
Main Controller: S7-1214C DC/DC/DC (14 digital inputs, 10 digital outputs, 2 analog inputs)
Expansion Modules:
-
SM1231 Analog Input Module (4AI) × 1: Used for collecting analog values such as pH, dissolved oxygen, turbidity, etc.
-
SM1232 Analog Output Module (2AO) × 1: Used for control of valves and frequency converters
-
SM1222 Digital Output Module (8DO) × 1: Used for control of pumps, fans, and other equipment
I/O Point Allocation Table
**Digital Inputs (DI)**:
-
I0.0: Inlet pump running feedback
-
I0.1: Aeration fan running feedback
-
I0.2: Mixer running feedback
-
I0.3: Dosing pump running feedback
-
I0.4: Sludge pump running feedback
-
I0.5: High liquid level alarm
-
I0.6: Low liquid level alarm
-
I0.7: Emergency stop button
**Digital Outputs (DO)**:
-
Q0.0: Inlet pump start/stop
-
Q0.1: Aeration fan start/stop
-
Q0.2: Mixer start/stop
-
Q0.3: Dosing pump 1 start/stop
-
Q0.4: Dosing pump 2 start/stop
-
Q0.5: Sludge pump start/stop
-
Q0.6: Solenoid valve 1 control
-
Q0.7: Solenoid valve 2 control
**Analog Inputs (AI)**:
-
IW64: pH sensor (4-20mA)
-
IW66: Dissolved oxygen sensor (4-20mA)
-
IW68: Turbidity sensor (4-20mA)
-
IW70: Level sensor (4-20mA)
**Analog Outputs (AO)**:
-
QW80: Aeration fan frequency control (4-20mA)
-
QW82: Dosing pump frequency control (4-20mA)
2. Control Program Design
Variable Definition Specification
To ensure program readability and maintainability, a structured variable naming convention is adopted:
[Device Type]_[Function Description]_[I/O Type]
For example:
-
Pump_Inlet_Run (Inlet pump running status)
-
Valve_Chemical_Ctrl (Dosing valve control)
-
AI_pH_Value (pH analog input)
-
AO_Blower_Speed (Blower speed control output)
Program Architecture Design
The program adopts a modular structure design, clearly dividing functional areas:
OB1: Main cycle block, responsible for calling various function blocks
FB10: Data collection and processing (analog conversion and filtering)
FB20: Automatic control logic (control of various process segments)
FB30: Manual control logic
FB40: Alarm handling
FB50: Data recording
FB60: Communication processing
Corresponding data blocks:
DB10: Parameter configuration
DB20: Operating data
DB30: Alarm information
DB40: Historical records
Function Block Design Example
Taking the pH control function block as an example, automatic dosing control is implemented:
FUNCTION_BLOCK "FB_pH_Control"
VAR_INPUT
pH_Value : REAL; // Actual pH value
pH_SetPoint : REAL; // pH set point
pH_Deviation : REAL; // Allowable deviation
Auto_Mode : BOOL; // Automatic mode
END_VAR
VAR_OUTPUT
Pump_Acid_Start : BOOL; // Acid dosing pump start
Pump_Alkali_Start : BOOL; // Alkali dosing pump start
Pump_Speed : REAL; // Dosing pump speed (0-100%)
END_VAR
VAR
pH_Error : REAL; // Error value
PID_Controller : FB41; // PID controller instance
END_VAR
BEGIN
// Calculate pH error
pH_Error := pH_SetPoint - pH_Value;
// Determine dosing direction
IF Auto_Mode THEN
// Determine if dosing is needed
IF ABS(pH_Error) > pH_Deviation THEN
// Decide whether to add acid or alkali based on error direction
IF pH_Error < 0 THEN
Pump_Acid_Start := TRUE;
Pump_Alkali_Start := FALSE;
ELSE
Pump_Acid_Start := FALSE;
Pump_Alkali_Start := TRUE;
END_IF;
// Call PID to calculate dosing speed
"PID_Controller"(
Setpoint := pH_SetPoint,
Input := pH_Value,
Output => Pump_Speed
);
ELSE
// Stop dosing within allowable deviation range
Pump_Acid_Start := FALSE;
Pump_Alkali_Start := FALSE;
Pump_Speed := 0.0;
END_IF;
END_IF;
END_FUNCTION_BLOCK
3. Data Management and Storage
Parameter Configuration Table
Use global data blocks to store system parameters for centralized management and modification:
DATA_BLOCK "DB_Parameters"
{S7_Optimized_Access := 'TRUE'}
VERSION : 0.1
NON_RETAIN
STRUCT
// pH control parameters
pH_Control : STRUCT
SetPoint : REAL := 7.0; // pH set point
Deviation : REAL := 0.2; // Allowable deviation
P_Factor : REAL := 1.5; // Proportional factor
I_Factor : REAL := 0.8; // Integral factor
D_Factor : REAL := 0.1; // Derivative factor
END_STRUCT;
// Dissolved oxygen control parameters
DO_Control : STRUCT
SetPoint : REAL := 2.5; // DO set point (mg/L)
Deviation : REAL := 0.3; // Allowable deviation
P_Factor : REAL := 2.0; // Proportional factor
I_Factor : REAL := 0.5; // Integral factor
D_Factor : REAL := 0.2; // Derivative factor
END_STRUCT;
// Sludge return control parameters
Sludge_Control : STRUCT
Ratio : REAL := 0.4; // Return ratio
Timer_On : TIME := T#15M; // Running time
Timer_Off : TIME := T#5M; // Stopping time
END_STRUCT;
// System operating parameters
System : STRUCT
Auto_Start_Time : TIME_OF_DAY := TOD#6:00:00; // Automatic start time
Auto_Stop_Time : TIME_OF_DAY := TOD#22:00:00; // Automatic stop time
Data_Save_Interval : TIME := T#30M; // Data save interval
END_STRUCT;
END_STRUCT;
BEGIN
END_DATA_BLOCK
Runtime Data Recording
The system runtime data is recorded in a circular buffer data block, periodically saving key parameters:
DATA_BLOCK "DB_Runtime_Data"
{S7_Optimized_Access := 'TRUE'}
VERSION : 0.1
NON_RETAIN
STRUCT
// Current runtime data
Current : STRUCT
pH_Value : REAL; // Current pH value
DO_Value : REAL; // Current dissolved oxygen value
Turbidity : REAL; // Current turbidity
Inflow_Rate : REAL; // Inflow rate
Blower_Speed : REAL; // Blower speed
Chemical_Pump_Speed : REAL; // Dosing pump speed
END_STRUCT;
// Cumulative runtime data
Statistics : STRUCT
Total_Inflow : DINT; // Cumulative treated water volume (m³)
Energy_Consumption : REAL; // Cumulative energy consumption (kWh)
Chemical_Usage : REAL; // Chemical usage (L)
Runtime_Hours : DINT; // System runtime (h)
END_STRUCT;
// Historical data (circular buffer, 48 points, one every 30 minutes)
History : ARRAY[0..47] OF STRUCT
Timestamp : DATE_AND_TIME; // Timestamp
pH_Value : REAL; // pH value
DO_Value : REAL; // Dissolved oxygen value
Turbidity : REAL; // Turbidity
Inflow_Rate : REAL; // Inflow rate
END_STRUCT;
// Historical data pointer
History_Index : INT := 0; // Current record pointer
END_STRUCT;
BEGIN
END_DATA_BLOCK
4. Fault Diagnosis and Troubleshooting
Common Fault Analysis
Common faults and solutions for food wastewater treatment systems:
-
Abnormal pH Fluctuations
-
Cause: Sensor calibration errors, dosing system failures, sudden changes in influent water quality
-
Solution: Verify sensor calibration, check dosing system, set buffer to adjust influent pH
Low Dissolved Oxygen
-
Cause: Blower failure, aeration head blockage, excessive organic load
-
Solution: Check blower operation status, clean aeration system, adjust inflow rate
Abnormal Sludge Return
-
Cause: Pump failure, pipeline blockage, abnormal level sensor
-
Solution: Check pump motor, clear pipeline, calibrate level sensor
Diagnosis Program Design
Below is an example of a device status monitoring and diagnosis function block:
FUNCTION_BLOCK "FB_Equipment_Diagnosis"
VAR_INPUT
Enable : BOOL; // Enable diagnosis
Equipment_Running : BOOL; // Equipment running status
Current_Feedback : REAL; // Current feedback
Current_Normal_Min : REAL; // Normal current lower limit
Current_Normal_Max : REAL; // Normal current upper limit
Pressure_Feedback : REAL; // Pressure feedback
Pressure_Normal_Min : REAL; // Normal pressure lower limit
Pressure_Normal_Max : REAL; // Normal pressure upper limit
END_VAR
VAR_OUTPUT
Normal_Operation : BOOL; // Normal operation
Overload_Warning : BOOL; // Overload warning
Underload_Warning : BOOL; // Underload warning
Pressure_High_Warning : BOOL; // High pressure warning
Pressure_Low_Warning : BOOL; // Low pressure warning
Fault_Code : INT; // Fault code
END_VAR
VAR
Timer_Delay : TON; // Delay timer
END_VAR
BEGIN
// Reset outputs
Normal_Operation := FALSE;
Overload_Warning := FALSE;
Underload_Warning := FALSE;
Pressure_High_Warning := FALSE;
Pressure_Low_Warning := FALSE;
// Perform diagnosis only when equipment is running
IF Enable AND Equipment_Running THEN
// Current diagnosis
IF Current_Feedback > Current_Normal_Max THEN
Overload_Warning := TRUE;
Fault_Code := 1; // Overload fault
ELSIF Current_Feedback < Current_Normal_Min THEN
Underload_Warning := TRUE;
Fault_Code := 2; // Underload fault
END_IF;
// Pressure diagnosis
IF Pressure_Feedback > Pressure_Normal_Max THEN
Pressure_High_Warning := TRUE;
Fault_Code := 3; // Pressure too high
ELSIF Pressure_Feedback < Pressure_Normal_Min THEN
Pressure_Low_Warning := TRUE;
Fault_Code := 4; // Pressure too low
END_IF;
// Determine if normal operation
IF NOT (Overload_Warning OR Underload_Warning OR
Pressure_High_Warning OR Pressure_Low_Warning) THEN
Normal_Operation := TRUE;
Fault_Code := 0; // No fault
END_IF;
ELSE
Fault_Code := 0; // Not running state
END_IF;
END_FUNCTION_BLOCK
5. User Interface Design
Interface Layout Planning
The HMI interface for food wastewater treatment should include the following main pages:
-
Overview Page: Displays the overall system operating status, including the status of each treatment unit, main equipment, and key parameters
-
Process Flow Page: Shows detailed treatment processes, equipment status, and real-time data
-
Parameter Settings Page: Interface for viewing and modifying control parameters, requiring password protection
-
Alarm Page: Current active alarms and historical alarm records
-
Trend Curve Page: Historical trends of key parameters
-
Data Record Page: Function for recording and exporting operating data
Parameter Settings Interface
The parameter settings page should have tiered authorization to avoid misoperation:
-
Operator Level: Can only view parameters, cannot modify
-
Engineer Level: Can modify operating parameters, such as pH set point, DO set point, etc.
-
Administrator Level: Can modify core system parameters, such as PID parameters, system configuration, etc.
After parameter modification, a confirmation mechanism should be in place, and important parameter changes should record the operator and time.
Alarm Handling Design
The alarm system should be designed in tiers:
-
Prompt Information: Non-critical parameters deviating from normal range, displayed in yellow
-
Warning Alarm: Important parameters deviating but not reaching dangerous values, displayed in orange with sound prompts
-
Danger Alarm: Critical parameters reaching dangerous values, flashing red display with sound prompts, may trigger interlock protection
Alarm information should include: alarm time, alarm content, alarm level, confirmation status, and release time.
6. System Debugging Methods
Step-by-Step Debugging Program
System debugging should follow the principle of “single point – loop – system”:
-
Single Point Testing: Test each I/O point one by one to confirm correct hardware connections and address mapping
-
Digital Inputs: Simulate field signals to verify PLC reading status
-
Digital Outputs: Manually set positions to verify actuator actions
-
Analog Inputs: Simulate 4-20mA signals to verify PLC conversion values
-
Analog Outputs: Manually set output values to verify actuator response
Loop Testing: Test each control loop to verify control logic
-
pH Control Loop: Simulate pH changes to verify dosing logic
-
DO Control Loop: Simulate DO changes to verify blower control
-
Level Control Loop: Simulate level changes to verify inlet pump and drainage valve control
System Coordination Testing: Overall system operation testing
-
Automatic/Manual mode switching test
-
Process parameter setting and response test
-
Abnormal situation and alarm handling test
-
Long-term stability test
Parameter Tuning Steps
Taking pH control as an example, the PID parameter tuning steps are as follows:
-
Initialize parameters: Set I and D to 0, P to a small value
-
Gradually increase P value until the system shows slight oscillation
-
Introduce I value to reduce overshoot and eliminate steady-state error
-
Introduce D value as needed to improve system response speed
-
Fine-tune the three parameters until satisfactory control effect is achieved
-
Verify parameter adaptability under different working conditions
The PLC control scheme for food wastewater treatment can effectively improve wastewater treatment efficiency and stability. The technical solutions presented in this article have been validated in multiple projects, and discussions on further optimization solutions are welcome.