Water Tank (Reservoir) Filling Control - Program-Example in LCE

Top 



In the control program below, when the general switch (linked to I0.0) is turned on and the water level of the tank (reservoir) is below 300 liters, two pumps are turned on in alternate way, now one, now other, until the tank to remain with, in the minimum, 800 liters. The quantity water sensor is linked to input analogical variable AIW0. The pump #1 initiates turned on, but after the time, entered in the variable AIW1, it is turned off, taking its turn the pump #2, with time of turning on given in AIW2, and so on. This control uses the two available pumps, without to let anyone idle, but it does not turn on the two ones at same time, for purposes of saving electrical energy.

(Obs.: the pattern times are exceedingly short only for purposes of simulation. To real economy, these times shoud have to be newly dimensioned to values too much bigger, in the order of minutes or hours, because the proper process of turning on the motor consumes, in general, large quantity of energy.)




plc
water_tank // Demonstrative control to turn on two water pumps that fill the tank by alternated way, based on the time of functioning of each pump.

// After compilation, ascertain the virtual functioning selecting on menu: Virtual Plants -> Simulated Tanks of Liquids -> Turn SimuPLC On


var
   I0.0    General_Switch,
   
Q0.7
    Choose_Pump,

   
Q0.1
    Pump1,
   
Q0.2
    Pump2,

   
T0
    Time_Pump1,
   
T1
    Time_Pump2,

   
AIW0
Water_Level,

   
AIW1
    TimeFuncPump1,
   
AIW2
    TimeFuncPump2;

network
1 // Controls turn pumps on based in the turning general switch of the system on and in low level of the water

if
(immediate General_Switch and Water_Level <= 300) {
turn_on
immediate Choose_Pump;
}

if
(Choose_Pump and no_raised Time_Pump1 and non_on Pump2) {
turn_on
immediate Pump1;
reset
Time_Pump2;
}

if
(Choose_Pump and no_raised Time_Pump2 and non_on Pump1) {
turn_on
immediate Pump2;
reset
Time_Pump1;
}

network
2 // Controls time of functioning of the pumps

if
(TimeFuncPump1 <= 0) { // If time isn't supplied ...
TimeFuncPump1
:= 10; // ... it accepts default value for pump 1, in seconds
}

if
(TimeFuncPump2 <= 0) { // If time isn't supplied ...
TimeFuncPump2
:= 15; // ... it accepts default value for pump 1, in seconds
}

when
(Pump1) temporize_accumulate Time_Pump1 TimeFuncPump1 s;

when
(Pump2) temporize_accumulate Time_Pump2 TimeFuncPump2 s;

network
3 // Verifies functioning times of the pumps, filling of the tank and switch turning system on

if
(Time_Pump1) { turn_off Pump1; }

if
(Time_Pump2) { turn_off Pump2; }

if
(not General_Switch or Water_Level > 800) {
turn_off
immediate Choose_Pump;
turn_off
immediate Pump1;
turn_off
immediate Pump2;
}

end




As result of the compilation of the
Water_Tank program above, the SimuPLC 4.1.0 has generated, exactly, the following code, in Instruction List - IL:



// PLC    water_tank
// Demonstrative control to turn on two water pumps that fill the tank by alternated way, based on the time of functioning of each pump.
// After compilation, ascertain the virtual functioning selecting on menu: Virtual Plants -> Simulated Tanks of Liquids -> Turn SimuPLC On

//
=VAR   I0.0   General_Switch
//
=VAR   Q0.7   Choose_Pump
//
=VAR   Q0.1   Pump1
//
=VAR   Q0.2   Pump2
//
=VAR   T0   Time_Pump1
//
=VAR   T1   Time_Pump2
//
=VAR   AIW0   Water_Level
//
=VAR   AIW1   TimeFuncPump1
//
=VAR   AIW2   TimeFuncPump2

NETWORK    1 // Controls turn pumps on based in the turning general switch of the system on and in low level of the water

LDI   I0.0
AD<=   AIW0,   300
SI    Q0.7,   1

LD   Q0.7
AN   T0
AN   Q0.2
SI    Q0.1,   1
R   T1,   1

LD   Q0.7
AN   T1
AN   Q0.1
SI    Q0.2,   1
R   T0,   1

NETWORK    2 // Controls time of functioning of the pumps

LDD<=   AIW1,   0
// If time isn't supplied ...
MOVD   10,   AIW1
// ... it accepts default value for pump 1, in seconds

LDD<=   AIW2,   0
// If time isn't supplied ...
MOVD   15,   AIW2
// ... it accepts default value for pump 1, in seconds

LD   Q0.1
*
D   1000,   AIW1
TONR   T0,   AIW1

LD   Q0.2
*
D   1000,   AIW2
TONR   T1,   AIW2

NETWORK    3 // Verifies functioning times of the pumps, filling of the tank and switch turning system on

LD   T0
R   Q0.1,   1

LD   T1
R   Q0.2,   1

LDN   I0.0
OD>   AIW0,   800
RI    Q0.7,   1
RI    Q0.1,   1
RI    Q0.2,   1