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.)
plcwater_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
varI0.0General_Switch,
Q0.7Choose_Pump,
Q0.1Pump1,
Q0.2Pump2,
T0Time_Pump1,
T1Time_Pump2,
AIW0Water_Level,
AIW1TimeFuncPump1,
AIW2TimeFuncPump2;
network 1 // Controls turn pumps on based in the turning general switch of the system on and in low level of the water
if (immediateGeneral_SwitchandWater_Level<= 300) {
turn_onimmediateChoose_Pump;
}
if (Choose_Pumpandno_raisedTime_Pump1andnon_onPump2) {
turn_onimmediatePump1;
resetTime_Pump2;
}
if (Choose_Pumpandno_raisedTime_Pump2andnon_onPump1) {
turn_onimmediatePump2;
resetTime_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_accumulateTime_Pump1TimeFuncPump1s;
when (Pump2) temporize_accumulateTime_Pump2TimeFuncPump2s;
network 3 // Verifies functioning times of the pumps, filling of the tank and switch turning system on
if (Time_Pump1) { turn_offPump1; }
if (Time_Pump2) { turn_offPump2; }
if (notGeneral_SwitchorWater_Level> 800) {
turn_offimmediateChoose_Pump;
turn_offimmediatePump1;
turn_offimmediatePump2;
}
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