Click the blue text to follow usThe laboratory environment monitoring system ensures the stability of precision experimental environments, relying on multi-parameter real-time monitoring and intelligent linkage control to improve the reliability of experimental data.
01 Hardware Configuration
The laboratory environment monitoring system requires a precise and reliable hardware foundation. To ensure stable operation of the system, the hardware configuration is as follows:
PLC and Expansion Module Selection
For small to medium-sized laboratories, it is recommended to use the S7-1200 series PLC (such as CPU 1214C) as the main controller, which has the following advantages:
- Built-in 14 digital inputs / 10 digital outputs
- 2 analog inputs to meet basic monitoring needs
- Supports Profinet communication for easy system expansion
- Cost-effective, suitable for laboratories with limited budgets
For laboratories with many parameter monitoring points, it is advisable to add the following expansion modules:
- SM 1231 TC (8-channel thermocouple module): for precise multi-point temperature measurement
- SM 1231 AI (8-channel analog input): for collecting signals from humidity, air pressure, gas concentration sensors
- SM 1222 DQ (16 digital outputs): for controlling fans, solenoid valves, alarms, and other actuators
I/O Point Allocation Table
| Address | Description | Signal Type | Range |
|---|---|---|---|
| %I0.0 | System Start Button | Digital Input | 0/1 |
| %I0.1 | System Stop Button | Digital Input | 0/1 |
| %I0.2 | Emergency Stop Button | Digital Input | 0/1 |
| %I0.3 | Fresh Air System Feedback | Digital Input | 0/1 |
| %IW64 | Temperature Sensor 1 | Analog Input | 0-27648(0-100℃) |
| %IW66 | Humidity Sensor 1 | Analog Input | 0-27648(0-100%) |
| %IW68 | CO2 Concentration Sensor | Analog Input | 0-27648(0-5000ppm) |
| %Q0.0 | Fresh Air System Start | Digital Output | 0/1 |
| %Q0.1 | Humidifier Control | Digital Output | 0/1 |
| %Q0.2 | Dehumidifier Control | Digital Output | 0/1 |
| %Q0.3 | Sound and Light Alarm | Digital Output | 0/1 |
| %QW64 | Temperature Control Valve Control | Analog Output | 0-27648(0-100%) |
System Wiring Points
- Analog sensors should use shielded twisted pairs, grounded at one end to reduce electromagnetic interference
- Sensor power supply should be separate from the PLC power supply to avoid interference
- Important control circuits should use relay isolation to improve system reliability
- All terminal connections should use spring-loaded terminals to reduce the risk of loosening
02 Control Program Design
Variable Definition Standards
Good variable naming is the foundation of program maintainability. The following standards are recommended:
// Global variable naming conventions
g_ // Global variable prefix
b_ // Boolean variable prefix
i_ // Integer variable prefix
r_ // Real variable prefix
s_ // String variable prefix
t_ // Time variable prefix
// Example
g_bSysRunning // System running status
g_rTempSetPoint // Temperature setpoint
g_iTempAlarmHigh // High temperature alarm value
Program Architecture Design
The program adopts the following hierarchical structure:
-
OB1: Main program loop, calling various function blocks
-
- System initialization
- Data acquisition FB call
- Control logic processing
- Communication processing
- Alarm processing
-
OB100: Power-on initialization, loading default parameters
-
OB82: Diagnostic interrupt, handling module faults
-
Function Block Design:
-
- FB1: Data acquisition and processing
- FB2: Temperature and humidity control
- FB3: Gas concentration control
- FB4: Alarm management
- FB5: Data logging
Status Control Design
The laboratory environment monitoring system includes multiple operating states, managed using a state machine:
// System state definitions
#define SYS_INIT 0 // Initialization state
#define SYS_STANDBY 1 // Standby state
#define SYS_RUNNING 2 // Running state
#define SYS_ALARM 3 // Alarm state
#define SYS_EMERGENCY 4 // Emergency state
#define SYS_MAINTAIN 5 // Maintenance state
State transition logic example (SCL language):
CASE g_iSysState OF
SYS_INIT:
// Initialization tasks
IF Init_Done THEN
g_iSysState := SYS_STANDBY;
END_IF;
SYS_STANDBY:
// Standby tasks
IF Start_Command THEN
g_iSysState := SYS_RUNNING;
END_IF;
SYS_RUNNING:
// Running tasks
IF Stop_Command THEN
g_iSysState := SYS_STANDBY;
ELSIF Alarm_Active THEN
g_iSysState := SYS_ALARM;
END_IF;
SYS_ALARM:
// Alarm handling tasks
IF Emergency_Button THEN
g_iSysState := SYS_EMERGENCY;
ELSIF Alarm_Reset AND NOT Alarm_Active THEN
g_iSysState := SYS_RUNNING;
END_IF;
SYS_EMERGENCY:
// Emergency state handling
IF Emergency_Reset THEN
g_iSysState := SYS_STANDBY;
END_IF;
SYS_MAINTAIN:
// Maintenance state handling
IF Maintain_Done THEN
g_iSysState := SYS_STANDBY;
END_IF;
END_CASE;
03 Data Management and Storage
Parameter Configuration Table
Parameter configuration information is stored in a global data block for unified management:
// Create parameter configuration data block
DATA_BLOCK "DB_Parameters"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
NON_RETAIN
STRUCT
// Temperature control parameters
TempSetPoint : Real := 23.0; // Temperature setpoint (℃)
TempHighLimit : Real := 25.0; // Temperature upper limit (℃)
TempLowLimit : Real := 21.0; // Temperature lower limit (℃)
TempAlarmHigh : Real := 28.0; // High temperature alarm (℃)
TempAlarmLow : Real := 18.0; // Low temperature alarm (℃)
// Humidity control parameters
HumidSetPoint : Real := 50.0; // Humidity setpoint (%)
HumidHighLimit : Real := 55.0; // Humidity upper limit (%)
HumidLowLimit : Real := 45.0; // Humidity lower limit (%)
HumidAlarmHigh : Real := 60.0; // High humidity alarm (%)
HumidAlarmLow : Real := 40.0; // Low humidity alarm (%)
// CO2 concentration control parameters
CO2SetPoint : Real := 800.0; // CO2 setpoint (ppm)
CO2AlarmHigh : Real := 1200.0; // High CO2 alarm (ppm)
// PID control parameters
TempPID_P : Real := 1.0; // Temperature PID-P
TempPID_I : Real := 120.0; // Temperature PID-I (s)
TempPID_D : Real := 0.0; // Temperature PID-D (s)
HumidPID_P : Real := 0.8; // Humidity PID-P
HumidPID_I : Real := 180.0; // Humidity PID-I (s)
HumidPID_D : Real := 0.0; // Humidity PID-D (s)
END_STRUCT;
END_DATA_BLOCK
Runtime Data Logging
System runtime data is stored in a circular buffer data block, overwriting the oldest data:
DATA_BLOCK "DB_RunData"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
NON_RETAIN
STRUCT
// Record management
CurrentIndex : Int := 0; // Current record index
MaxRecords : Int := 1000; // Maximum number of records
// Data record arrays
TimeStamp : Array[0..999] of Date_And_Time; // Timestamps
Temp : Array[0..999] of Real; // Temperature values
Humid : Array[0..999] of Real; // Humidity values
CO2 : Array[0..999] of Real; // CO2 concentrations
AlarmBits : Array[0..999] of Word; // Alarm bits
END_STRUCT;
END_DATA_BLOCK
Alarm Information Management
Alarm information is managed using bits, with each bit representing a type of alarm:
// Alarm bit definitions
#define ALARM_TEMP_HIGH 16#0001 // High temperature alarm
#define ALARM_TEMP_LOW 16#0002 // Low temperature alarm
#define ALARM_HUMID_HIGH 16#0004 // High humidity alarm
#define ALARM_HUMID_LOW 16#0008 // Low humidity alarm
#define ALARM_CO2_HIGH 16#0010 // High CO2 concentration alarm
#define ALARM_SENSOR_FAULT 16#0020 // Sensor fault alarm
#define ALARM_SYSTEM_FAULT 16#0040 // System fault alarm
Example of alarm handling function block:
FUNCTION_BLOCK "FB_AlarmManagement"
VAR_INPUT
Temp : Real; // Current temperature
Humid : Real; // Current humidity
CO2 : Real; // Current CO2 concentration
SensorStatus : Word; // Sensor status
END_VAR
VAR_OUTPUT
AlarmWord : Word; // Alarm word
AlarmActive : Bool; // Alarm active
AlarmSound : Bool; // Sound alarm
END_VAR
VAR
OldAlarmWord : Word; // Previous alarm word
AlarmChangeTrigger : Bool; // Alarm change trigger
END_VAR
BEGIN
// Initialize alarm word
AlarmWord := 16#0000;
// Check temperature alarm
IF Temp > "DB_Parameters".TempAlarmHigh THEN
AlarmWord := AlarmWord OR ALARM_TEMP_HIGH;
END_IF;
IF Temp < "DB_Parameters".TempAlarmLow THEN
AlarmWord := AlarmWord OR ALARM_TEMP_LOW;
END_IF;
// Check humidity alarm
IF Humid > "DB_Parameters".HumidAlarmHigh THEN
AlarmWord := AlarmWord OR ALARM_HUMID_HIGH;
END_IF;
IF Humid < "DB_Parameters".HumidAlarmLow THEN
AlarmWord := AlarmWord OR ALARM_HUMID_LOW;
END_IF;
// Check CO2 alarm
IF CO2 > "DB_Parameters".CO2AlarmHigh THEN
AlarmWord := AlarmWord OR ALARM_CO2_HIGH;
END_IF;
// Check sensor fault
IF SensorStatus <> 16#0000 THEN
AlarmWord := AlarmWord OR ALARM_SENSOR_FAULT;
END_IF;
// Detect alarm change
IF AlarmWord <> OldAlarmWord THEN
AlarmChangeTrigger := TRUE;
ELSE
AlarmChangeTrigger := FALSE;
END_IF;
// Update alarm output
AlarmActive := (AlarmWord <> 16#0000);
AlarmSound := AlarmChangeTrigger AND AlarmActive;
// Save current alarm state
OldAlarmWord := AlarmWord;
END_FUNCTION_BLOCK
04 User Interface Design
Interface Layout Description
The HMI interface configured using Siemens WinCC has a reasonable and intuitive layout:
-
Main Screen: Displays the overall laboratory floor plan and key parameters
-
- Left side: Laboratory floor plan, graphically displaying the status of each area
- Right side: Real-time values and set values of key parameters displayed side by side
- Bottom: System status bar and scrolling alarm information
-
Parameter Setting Screen:
-
- Setting parameters such as temperature, humidity, and CO2 concentration
- PID parameter tuning interface
- Alarm limit settings
-
Trend Curve Screen:
-
- Multi-parameter trend curves, supporting zoom and historical queries
- Data export function
-
Alarm Screen:
-
- Current alarms displayed
- Historical alarm records
- Alarm confirmation function
Parameter Setting Description
To ensure operational safety, parameter settings adopt a hierarchical permission management system:
-
Operator Level:
-
- Can only view operating parameters
- Can confirm alarms
- Can export historical data
-
Engineer Level:
-
- Can modify control set values
- Can adjust alarm limits
- Can switch system operating modes
-
Administrator Level:
-
- Can modify PID parameters
- Can set system configuration parameters
- Can manage user permissions
Parameter modifications require a double confirmation mechanism to avoid misoperation:
- Input target value
- Confirmation dialog
- Actual write to PLC
- Parameter change record
05 System Debugging Methods
Step-by-Step Debugging Method
The debugging of the laboratory environment monitoring system adopts a bottom-up approach:
-
I/O Point Testing:
-
- Test digital input points one by one
- Calibrate analog input points
- Test digital and analog output points
-
Function Module Testing:
-
- Temperature control loop testing
- Humidity control loop testing
- CO2 concentration control loop testing
- Alarm function testing
-
Joint Debugging:
-
- Cooperative operation testing of each control loop
- Simulate system response under various working conditions
- HMI and PLC communication testing
-
System Testing:
-
- Long-term stability testing (over 24 hours)
- Power recovery testing
- Abnormal handling testing
Abnormal Simulation Testing
To verify the system’s handling capability under abnormal conditions, the following tests need to be conducted:
-
Sensor Fault Testing:
-
- Temperature sensor disconnection/short circuit testing
- Humidity sensor signal anomaly testing
- CO2 sensor failure testing
-
Actuator Fault Testing:
-
- Fan startup failure testing
- Temperature control valve jamming testing
- Humidifier/dehumidifier failure testing
-
Communication Abnormality Testing:
-
- HMI communication interruption testing
- Network communication disconnection testing
- Remote access failure testing
-
Power Abnormality Testing:
-
- Short-term power recovery testing
- Long-term power recovery testing
- Power fluctuation testing
Each test must record the system’s response and verify whether the fault safety mechanisms are effective.
06 Summary and Reflections
The laboratory environment monitoring system is a typical application of precision environmental control, achieved through Siemens PLC for multi-parameter monitoring and control, ensuring the stability and reliability of the experimental environment. Feel free to share your project experiences in the comments!
ENDIf you see this, please give me a thumbs up!