One-Stop Solution for Gas Separation Control: Detailed Explanation of Siemens PLC Technology

The gas separation system has significant application value in the chemical, medical, and energy fields. Automation control based on Siemens PLC can achieve high precision, stability, and safety.

1. Control Program Design

Variable Definition Standards

In the gas separation control system, good variable naming conventions can greatly enhance the readability and maintainability of the program. In Siemens PLC programming, we adopt the following naming rules:

Prefix Data Type Example

b_ BOOL b_ValveOpen

i_ INT i_Pressure

r_ REAL r_FlowRate

t_ TIME t_DelayStart

s_ STRING s_SystemStatus

All I/O points are categorized by function and annotated to ensure ease of maintenance in the future.

Program Architecture Design

The program architecture of the gas separation control system adopts a layered design:

OB1 (Main Loop)

├── FC10 (System Initialization)

├── FC20 (Mode Selection)

├── FB30 (Gas Pressure Control) – Multi-instance

├── FB40 (Temperature Control) – Multi-instance

├── FB50 (Flow Control) – Multi-instance

├── FC60 (Alarm Handling)

└── FC70 (Data Logging)

Each function block is responsible for a single function, reducing program complexity. Communication between blocks is improved through a unified data interface, enhancing system scalability.

Function Block Design

Taking the gas pressure control FB as an example:

FUNCTION_BLOCK “FB_PressureControl”

{ S7_Optimized_Access := ‘TRUE’ }

VERSION : 0.1

VAR_INPUT

i_ActualPressure : Real; // Actual pressure value (Bar)

i_SetPressure : Real; // Set pressure value (Bar)

i_AutoMode : Bool; // Automatic control mode

i_ManualValue : Real; // Manual control value (%)

END_VAR

VAR_OUTPUT

q_ValvePosition : Real; // Valve opening output (%)

q_AlarmHigh : Bool; // High pressure alarm

q_AlarmLow : Bool; // Low pressure alarm

q_Status : Int; // Status code

END_VAR

VAR

PID : “PID_Compact”; // PID controller instance

r_Deviation : Real; // Deviation value

r_DeadBand : Real := 0.1; // Deadband setting

r_AlarmHighLimit : Real := 10.0; // High alarm limit

r_AlarmLowLimit : Real := 0.5; // Low alarm limit

END_VAR

BEGIN

// 1. Check alarm conditions

q_AlarmHigh := i_ActualPressure >= r_AlarmHighLimit;

q_AlarmLow := i_ActualPressure <= r_AlarmLowLimit;

// 2. Calculate deviation

r_Deviation := i_SetPressure – i_ActualPressure;

// 3. Mode selection and control

IF i_AutoMode THEN

// Automatic PID control

“PID”(

Setpoint := i_SetPressure,

Input := i_ActualPressure,

Input_PER := W#16#0,

Output => q_ValvePosition);

// Status setting

q_Status := 1; // Automatic operation

ELSE

// Manual control

q_ValvePosition := i_ManualValue;

// Status setting

q_Status := 2; // Manual operation

END_IF;

// 4. Safety limits

q_ValvePosition := MIN(MAX(q_ValvePosition, 0.0), 100.0);

END_FUNCTION_BLOCK

Status Control Design

The operating status of the gas separation system is managed using a state machine to ensure safe and stable operation under various conditions:

// System state definitions

#define STATE_INIT 0 // Initialization

#define STATE_STANDBY 1 // Standby

#define STATE_STARTUP 2 // Startup

#define STATE_RUNNING 3 // Running

#define STATE_SHUTDOWN 4 // Shutdown

#define STATE_ERROR 5 // Error

// State transition logic

CASE #i_SystemState OF

STATE_INIT:

// Initialization operations

IF #b_InitComplete THEN

#i_SystemState := STATE_STANDBY;

END_IF;

STATE_STANDBY:

// Standby state handling

IF #b_StartCommand AND NOT #b_Error THEN

#i_SystemState := STATE_STARTUP;

END_IF;

STATE_STARTUP:

// Execute startup sequence

IF #b_StartupComplete THEN

#i_SystemState := STATE_RUNNING;

ELSIF #b_Error THEN

#i_SystemState := STATE_ERROR;

END_IF;

// Other state handling…

END_CASE;

2. Data Management and Storage

Parameter Configuration Table

Key parameters of the gas separation system need to be centrally managed, using a global DB block to store system parameters:

DATA_BLOCK “DB_Parameters”

{ S7_Optimized_Access := ‘TRUE’ }

VERSION : 0.1

NON_RETAIN

STRUCT

// System parameters

SystemParams : Struct

MaxPressure : Real := 9.0; // Maximum system pressure (Bar)

MinPressure : Real := 0.5; // Minimum system pressure (Bar)

MaxTemperature : Real := 85.0; // Maximum temperature (°C)

MinTemperature : Real := 5.0; // Minimum temperature (°C)

MaxFlowRate : Real := 150.0; // Maximum flow rate (m³/h)

StartupTime : Time := T#2m; // Startup time

ShutdownTime : Time := T#1m30s; // Shutdown time

END_STRUCT;

// PID control parameters

PIDParams : Struct

Pressure : Struct

Kp : Real := 0.8; // Proportional coefficient

Ti : Time := T#8s; // Integral time

Td : Time := T#2s; // Derivative time

DeadBand : Real := 0.05; // Deadband

END_STRUCT;

Temperature : Struct

Kp : Real := 1.2; // Proportional coefficient

Ti : Time := T#25s; // Integral time

Td : Time := T#5s; // Derivative time

DeadBand : Real := 0.2; // Deadband

END_STRUCT;

FlowRate : Struct

Kp : Real := 0.5; // Proportional coefficient

Ti : Time := T#3s; // Integral time

Td : Time := T#1s; // Derivative time

DeadBand : Real := 0.2; // Deadband

END_STRUCT;

END_STRUCT;

// Alarm thresholds

AlarmThresholds : Struct

PressureHigh : Real := 8.5; // High pressure alarm (Bar)

PressureLow : Real := 0.8; // Low pressure alarm (Bar)

TemperatureHigh : Real := 80.0; // High temperature alarm (°C)

TemperatureLow : Real := 8.0; // Low temperature alarm (°C)

FlowHigh : Real := 145.0; // High flow alarm (m³/h)

FlowLow : Real := 5.0; // Low flow alarm (m³/h)

END_STRUCT;

END_STRUCT;

BEGIN

// Default initial values for parameters have been set during definition

END_DATA_BLOCK

Operational Data Logging

System operational data needs to be recorded periodically for analysis and optimization:

// Data logging function block

FUNCTION “FC_DataLogging” : Void

VAR_INPUT

i_TriggerLog : Bool; // Trigger logging

i_Pressure : Real; // Pressure value

i_Temperature : Real; // Temperature value

i_FlowRate : Real; // Flow rate value

i_SystemState : Int; // System state

END_VAR

VAR_TEMP

DTVar : Date_And_Time; // Current time

END_VAR

BEGIN

// When the trigger log flag is set

IF i_TriggerLog THEN

// Get current time

DTVar := RD_SYS_T();

// Write data to DataLog

// Note: Actual use requires configuring DataLog functionality

// DataLogWrite(

// ReqID := W#16#1,

// Done => #bDone,

// Error => #bError,

// Status => #wStatus,

// Timestamp := DTVar,

// Pressure := i_Pressure,

// Temperature := i_Temperature,

// FlowRate := i_FlowRate,

// SystemState := i_SystemState

// );

// Example alternative: Use DB block to record the last 100 records

// Here, a circular buffer method is used to record historical data

#i_LogIndex := (#i_LogIndex + 1) MOD 100;

// Write data to DB block

“DB_DataLog”.Logs[#i_LogIndex].Timestamp := DTVar;

“DB_DataLog”.Logs[#i_LogIndex].Pressure := i_Pressure;

“DB_DataLog”.Logs[#i_LogIndex].Temperature := i_Temperature;

“DB_DataLog”.Logs[#i_LogIndex].FlowRate := i_FlowRate;

“DB_DataLog”.Logs[#i_LogIndex].SystemState := i_SystemState;

END_IF;

END_FUNCTION

3. Fault Diagnosis and Troubleshooting

Common Fault Analysis

Common faults in the gas separation system and corresponding measures:

Pressure Abnormal Fluctuation

Cause: Unstable valve response, inappropriate PID parameters

Resolution: Check the mechanical parts of the valve, optimize PID parameters

Key Code: Monitor pressure change rate to identify abnormal fluctuations

// Pressure fluctuation monitoring

r_PressureChangeRate := ABS(#r_CurrentPressure – #r_LastPressure) / #r_SampleTime;

IF r_PressureChangeRate > #r_MaxChangeRate THEN

#b_PressureUnstable := TRUE;

#i_AlarmCode := 102; // Pressure fluctuation abnormal code

END_IF;

Gas Purity Decrease

Cause: Aging of separation membrane, excessive flow rate

Resolution: Check the condition of the separation membrane, adjust flow parameters

Preventive Measures: Regularly monitor gas purity, establish early warning mechanisms

Control System Unresponsive

Cause: Communication interruption, CPU overload

Resolution: Implement watchdog mechanism to ensure the system can restart

// Watchdog implementation

#t_WatchdogTimer := #t_WatchdogTimer + #t_CycleTime;

IF #t_WatchdogTimer >= T#5s THEN

// Reset timer

#t_WatchdogTimer := T#0ms;

// Check system status

IF NOT #b_SystemResponding THEN

// Log error

#i_ErrorCode := 501;

// Execute safety operation

#b_EmergencyShutdown := TRUE;

END_IF;

// Send response signal

#b_SystemResponding := FALSE;

END_IF;

Diagnostic Tool Usage

Key applications of Siemens PLC system diagnostic functions:

ProDiag function configuration: Utilize the ProDiag function of the S7-1500 series PLC to configure monitoring conditions

Fault buffer analysis: Develop a dedicated diagnostic FB to periodically read the diagnostic buffer

// Diagnostic buffer reading example

#ret := DiagnosticBuffer(

REQ := TRUE,

DTYPE := 16#0008, // CPU diagnostic buffer

RECORDS := 10, // Read 10 records

DATA := #DiagBuffer);

Custom diagnostic panel: Develop a dedicated diagnostic interface on the HMI to visually display system status

4. User Interface Design

Interface Layout Description

The HMI interface of the gas separation control system adopts a layered design:

Main Page: System overview, key parameters, operating status

Control Page: Parameter adjustment, mode selection, manual control

Alarm Page: Real-time alarms, historical alarms, alarm confirmation

Trend Page: Key parameter trend graphs, data analysis

Diagnostic Page: System diagnostics, component status, communication status

Parameter Setting Description

To ensure the safety and reliability of parameter settings, the system is designed with multi-level access control:

// Access control example code

FUNCTION “FC_AccessControl” : Bool

VAR_INPUT

i_UserLevel : Int; // User level (1-Operator, 2-Engineer, 3-Administrator)

i_ParamType : Int; // Parameter type (1-Operating parameters, 2-Control parameters, 3-System parameters)

END_VAR

BEGIN

// Default result: Deny access

FC_AccessControl := FALSE;

// Permission control logic

CASE i_ParamType OF

1: // Operating parameters

FC_AccessControl := i_UserLevel >= 1; // All users can access

2: // Control parameters

FC_AccessControl := i_UserLevel >= 2; // Engineers and above can access

3: // System parameters

FC_AccessControl := i_UserLevel >= 3; // Only administrators can access

END_CASE;

END_FUNCTION

5. Communication Network Architecture

Fieldbus Selection

For the characteristics of the gas separation system, PROFINET is chosen as the main fieldbus:

Real-time performance: Class 2 level, can meet the rapid response requirements in the gas separation process

Topology flexibility: Star, tree, and line topologies are all applicable, adapting to different field environments

Diagnostic capability: Provides rich diagnostic functions for troubleshooting

Key configuration parameters:

Sending cycle: 1ms (high priority IO) / 4ms (standard IO)

Update cycle: 4ms

Monitoring cycle: 12ms (3 times the update cycle)

Remote Communication Scheme

The system uses OPC UA to achieve communication with the upper-level system:

// OPC UA server configuration example (configured in TIA Portal)

// 1. “Device Configuration” -> “OPC UA” -> “Server”

// 2. Enable OPC UA server functionality

// 3. Configure security settings:

// – Security policy: Basic256Sha256

// – Message security mode: SignAndEncrypt

// 4. Configure user authentication

// 5. Set access permissions

Summary and Outlook

The gas separation control system is an important application in process automation, achieving high precision control and comprehensive monitoring through Siemens PLC. A reasonable program architecture, a complete fault diagnosis mechanism, and a user-friendly operating interface are key to the system’s success. We welcome the exchange of practical experiences in gas separation control!

Leave a Comment