P2_Ctl

Return to top



(*************************)
(* Duty Rotation Logic  *)
(*************************)


(* Pump Stop Event*)
PumpStopEvent := (P1Running_prev OR P2Running_prev) AND NOT P1Running AND NOT P2Running;

(* On a pump stop event, rotate the duty pump *)
IF (PumpStopEvent AND DutyRotate AND NOT (Level > XferLvl) AND NOT XferActive) THEN 
    DutyPump := DutyPump + 1;
    IF (DutyPump > 2) THEN 
        DutyPump := 1;
    END_IF; 
END_IF; 

(* Ensure DutyPump has a sensible value (when the application is initialised it may have an unknown state) *)
IF (DutyPump < 1 OR DutyPump > 2) THEN 
    DutyPump := 1;
END_IF; 


(*************************)
(* Duty Transfer Logic  *)
(*************************)

(*
 * If the wet well level is greater than the transfer level, then run the alternate pump
 * otherwise run the normal duty pump
 *)

Transfer_Tmr(XferActive, t#100s);

IF (Level > XferLvl) AND NOT XferActive THEN 
    XferActive := TRUE;
END_IF;

IF XferActive AND Transfer_Tmr.ET > t#5s THEN
    PumpXfer := TRUE;
        IF (DutyPump = 1) THEN PumpToRun := 2;
        ELSE PumpToRun := 1;
        END_IF;
END_IF;

IF (Level <= StopLvl) THEN
    PumpXfer := FALSE;
    XferActive := FALSE;
    PumpToRun := DutyPump;
END_IF; 

XfDly:= XferActive;

(*****************************)
(* Pump Availability Logic *)
(*****************************)

(*
 * Use whichever pump is available if they are not both available
 *)
IF (P1Avail AND NOT P2Avail) THEN 
    PumpToRun := 1;
END_IF;     
IF (NOT P1Avail AND P2Avail) THEN 
    PumpToRun := 2;
END_IF;     
IF (NOT P1Avail AND NOT P2Avail) THEN 
    PumpToRun := 0;
END_IF;     
(* Ensure pump 1 is default after restart *)
IF (P1Avail AND P2Avail AND (PumpToRun = 0)) THEN 
    PumpToRun := 1;
END_IF;     



(**********************)
(* Pump Run Logic  *)
(**********************)

(*
 * Start a pump when the wet well level is greater than the start level;
 * and continue running while the level is greater than the stop level;
*  or until the remote stop is activated.
 *)
IF ((Level > StrtLvl) OR RunPump) AND (Level > StopLvl) AND NOT RemStop THEN 
    RunPump := TRUE;
ELSE 
    RunPump := FALSE;
END_IF; 

(* Run the designated pump *)
IF RunPump OR RemRun THEN 

    (* Start Pump 1 *)
    IF (PumpToRun = 1) THEN 
        P1Control := TRUE;
        P2Control := FALSE;
    END_IF; 
    
    (* Start Pump 2 *)
    IF (PumpToRun = 2) THEN 
        P2Control := TRUE;
        P1Control := FALSE;
    END_IF; 

(* Stop the pumps *)
ELSE 
    P1Control := FALSE;
    P2Control := FALSE;

END_IF; 

(********************************************)
(* Update previous values for next scan     *)
(********************************************)

P1Running_prev := P1Running;
P2Running_prev := P2Running;

(********************************************)
(* Update diagnostic values                 *)
(********************************************)

 Pmp2R := PumpToRun;
 DuPmp := DutyPump;


PumpStopEvent
P1Running_prev
P2Running_prev
P1Running
P2Running
DutyRotate
Level
XferLvl
XferActive
DutyPump
Transfer_Tmr
PumpXfer
PumpToRun
StopLvl
XfDly
P1Avail
P2Avail
StrtLvl
RunPump
RemStop
RemRun
P1Control
P2Control
Pmp2R
DuPmp

Return to top