Pump control with two pumps using Structured Text (ST)

This example describes a pump control with two pumps and three float switches in a well. The float switches are attached to cables and when the liquid rises in the well, the float switches will be activated and change their NC / NO position.

The two submersible pumps M1 and M2 have been set to alternate operation mode, which means that they take turns to start and run. With alternating operation, the length of time the pumps are operating is distributed across both pumps, and servicing of the pumps can be performed at the same time.

Signals from the float switces LS1LS2 and LS3 determine when the pumps should start or stop. If the level in the well is between LS1 and LS2, one pump must be running.

If the level is above LS3, both pumps must be running to pump at full capacity. LS3 is a Normally Closed (NC) switch to provide overflow protection when both pumps are operating, if the LS3 wire is disconnected or the flow switch is defect. If the level is below LS1, both pumps must be stopped to avoid dry run.


Pump control with two pumps
Float switches are connected to digital inputs and the pumps to digital outputs. The following variables are used:

VAR
 LS1: BOOL;	//Float Switch (NO), placed bottom
 LS2: BOOL;	//Float Switch (NO), placed middle
 LS3: BOOL;	//Float Switch (NC), placed top
 M1: BOOL	:= FALSE; //Pump 1
 M2: BOOL	:= FALSE; //Pump 2
 RunM: BOOL	:= FALSE; //Control the alternation
END_VAR

Pump control with two pumps

With alternating operation the pumps must take turns to start and run. To select which pump to start, the variable RunM is used. If RunM is TRUE, pump M1 will start and if RunM is FALSE, pump M2 will start. The variable RunM selects which of the two pumps that must be turned off when the level is below float switch LS3.

The pump variables M1 and M2 are by default set to FALSE when the PLC powers up, to ensure that the pumps are not running during startup.

The program code is split up into four states defined by the float switches, the number of pumps in operation, and an increased or decreased liquid level:

//Low level (1)
//Stops pumps if LS1 is not activated
IF NOT LS1 THEN
 M1:= FALSE;
 M2:= FALSE;
END_IF;
//LS2 is activated, start one pump (2)
IF LS2 AND NOT M1 AND NOT M2 THEN
 M1:= RunM;
 M2:= NOT RunM;
//Pump alternation
 RunM:= NOT RunM;
END_IF;
//Start both pumps, high level in tank (3)
//LS3 = NC
IF NOT LS3 THEN
 M1:= TRUE;
 M2:= TRUE;
END_IF;
//Stop one pump, because two are running (4)
//Level is below LS2, LS3=NC
IF NOT LS2 AND M1 AND M2 THEN
 M1:= RunM;
 M2:= NOT RunM;
 //Pump alternation
 RunM:= NOT RunM;
END_IF;

which of the two pumps that must be turned off when the level is below float switch LS3.

The pump variables M1 and M2 are by default set to FALSE when the PLC powers up, to ensure that the pumps are not running during startup.

The program code is split up into four states defined by the float switches, the number of pumps in operation, and an increased or decreased liquid level:

//Low level (1)
//Stops pumps if LS1 is not activated
IF NOT LS1 THEN
 M1:= FALSE;
 M2:= FALSE;
END_IF;
//LS2 is activated, start one pump (2)
IF LS2 AND NOT M1 AND NOT M2 THEN
 M1:= RunM;
 M2:= NOT RunM;
//Pump alternation
 RunM:= NOT RunM;
END_IF;
//Start both pumps, high level in tank (3)
//LS3 = NC
IF NOT LS3 THEN
 M1:= TRUE;
 M2:= TRUE;
END_IF;
//Stop one pump, because two are running (4)
//Level is below LS2, LS3=NC
IF NOT LS2 AND M1 AND M2 THEN
 M1:= RunM;
 M2:= NOT RunM;
//Pump alternation
 RunM:= NOT RunM;
END_IF;

 Pump control with two pumps

The state changes when a float switch is activated or deactivated.

The IF statements in state 2 and 4 ensures that the code is executed once only, because the number of running pumps prevents the code to be executed again.

Alarm monitoring for float switch errors:

This code can be implemented to monitor potential float switch errors:

//Defect LS2 or LS3 float switch: Because LS3 is activated and LS2 is not activated.
LS2_3_Alarm:= LS2 OR NOT LS3; //LS3 = NC, LS2 = NO
//Defect LS1 or LS2 float switch: Because LS2 is activated and LS1 is not activated.
LS1_2_Alarm:= NOT LS1 OR LS2; //LS1 = NO, LS2 = NO

Leave a Comment