In the control program below, four suction pumps are turned on by rotation caster mode to deflation of the drain sewer.
plcDrain_Pumps// Controls 4 pumps of the drain sewer, turned on by rotation caster mode, according to the level reached by the material in the drain, and in caster, to balanced depreciation of the ones by use in similar intensity. It permits detection of problems of operation or failures of start in the pumps, with consequent automatic adjust in the rotating of turning on of the pumps.
// Obs.: in the variables below, the cardinal 1, 2, 3 and 4 refer to pumps physically, but the ordinal 1ª (1st), 2ª (2nd), 3ª (3rd) and 4ª (4th) refer to pumps in the order in these ones will are turned on, which changes according to the cycle in that the system is operating (to implementation of the rotation caster), indicated by the value present in the variable Cycle:
network 1 // Logic of turning off of the pumps, if drain is empty or if is operated the switch of general turning off, and control of the cycle of operation in rotation caster.
if (Drain_Level<= 6400 orimmediateTurn_Off_Pumps)
{
turn_offimmediatePump1;
turn_offimmediatePump2;
turn_offimmediatePump3;
turn_offimmediatePump4;
incrementBCycle; // Does var Cycle to vary from 1 to 4 alternately, turning on in CycleB-:= (CycleB/ 4) B* 4; // rotation caster every one of the pumps, avoiding that their // operation times stay too much different along the time.
}
if (Cycle= 0) { // If var Cycle was not initialized, set it to first CycleB:= 1;
}
network 2 // Logic of rotation caster turning on of the pumps. Note that when the pump is turned on, this one only is turned off when the drain is completely empty (Drain_Level <= 6400).
if ( notimmediateTurn_Off_Pumpsand
(Drain_Level> 19200 or (Drain_Level> 6400 andFailure_B2ªandFailure_B3ªandFailure_B4ª)) )
{
if ( notFailure_B1ª) {
if (Cycle= 1) {
turn_onimmediatePump1;
}
if (Cycle= 2) {
turn_onimmediatePump2;
}
if (Cycle= 3) {
turn_onimmediatePump3;
}
if (Cycle= 4) {
turn_onimmediatePump4;
}
}
}
if ( notimmediateTurn_Off_Pumpsand
( (Drain_Level> 32000 andPump1ª_FinalStart)
or (Drain_Level> 19200 andFailure_B1ª)
or (Drain_Level> 6400 andFailure_B1ªandFailure_B3ªandFailure_B4ª) ) )
{
if ( notFailure_B2ª) {
if (Cycle= 1) {
turn_onimmediatePump2;
}
if (Cycle= 2) {
turn_onimmediatePump3;
}
if (Cycle= 3) {
turn_onimmediatePump4;
}
if (Cycle= 4) {
turn_onimmediatePump1;
}
}
}
if ( notimmediateTurn_Off_Pumpsand
( (Drain_Level> 44800 andPump2ª_FinalStart)
or (Drain_Level> 19200 andFailure_B1ªandFailure_B2ª)
or (Drain_Level> 32000 and (Failure_B1ªorFailure_B2ª))
or (Drain_Level> 6400 andFailure_B1ªandFailure_B2ªandFailure_B4ª) ) )
{
if ( notFailure_B3ª) {
if (Cycle= 1) {
turn_onimmediatePump3;
}
if (Cycle= 2) {
turn_onimmediatePump4;
}
if (Cycle= 3) {
turn_onimmediatePump1;
}
if (Cycle= 4) {
turn_onimmediatePump2;
}
}
}
if ( notimmediateTurn_Off_Pumpsand
( (Drain_Level> 51200 andPump3ª_FinalStart)
or (Drain_Level> 19200 andFailure_B1ªandFailure_B2ªandFailure_B3ª)
or (Drain_Level> 32000
and ( (Failure_B1ªandFailure_B2ª)
or (Failure_B1ªandFailure_B3ª)
or (Failure_B2ªandFailure_B3ª) ) )
or (Drain_Level> 44800 and (Failure_B1ªorFailure_B2ªorFailure_B3ª))
or (Drain_Level> 6400 andFailure_B1ªandFailure_B2ªandFailure_B3ª) ) )
{
if ( notFailure_B4ª) {
if (Cycle= 1) {
turn_onimmediatePump4;
}
if (Cycle= 2) {
turn_onimmediatePump1;
}
if (Cycle= 3) {
turn_onimmediatePump2;
}
if (Cycle= 4) {
turn_onimmediatePump3;
}
}
}
network 3 // Detects operating of the buoy security, when there is failure in the level sensor.
if ( Buoy_MaximumLevel ) {
Drain_Level := 64000;
}
if ( Buoy_MinimumLevel ) {
Drain_Level := 6400;
}
network 4 // Detects failures on anyone of the four pumps.
if ( notWithout_Failure1_B1ornotWithout_Failure2_B1ornotWithout_Failure3_B1ornotWithout_Failure4_B1 ) {
turn_offimmediatePump1;
turn_onimmediateB1_Failure;
if (Cycle= 1) {
turn_onFailure_B1ª;
}
if (Cycle= 2) {
turn_onFailure_B2ª;
}
if (Cycle= 3) {
turn_onFailure_B3ª;
}
if (Cycle= 4) {
turn_onFailure_B4ª;
}
}
if ( notWithout_Failure1_B2ornotWithout_Failure2_B2ornotWithout_Failure3_B2ornotWithout_Failure4_B2 ) {
turn_offimmediatePump2;
turn_onimmediateB2_Failure;
if (Cycle= 1) {
turn_onFailure_B4ª;
}
if (Cycle= 2) {
turn_onFailure_B1ª;
}
if (Cycle= 3) {
turn_onFailure_B2ª;
}
if (Cycle= 4) {
turn_onFailure_B3ª;
}
}
if ( notWithout_Failure1_B3ornotWithout_Failure2_B3ornotWithout_Failure3_B3ornotWithout_Failure4_B3 ) {
turn_offimmediatePump3;
turn_onimmediateB3_Failure;
if (Cycle= 1) {
turn_onFailure_B3ª;
}
if (Cycle= 2) {
turn_onFailure_B4ª;
}
if (Cycle= 3) {
turn_onFailure_B1ª;
}
if (Cycle= 4) {
turn_onFailure_B2ª;
}
}
if ( notimmediateWithout_Failure1_B4ornotimmediateWithout_Failure2_B4ornotimmediateWithout_Failure3_B4ornotimmediateWithout_Failure4_B4 ) {
turn_offimmediatePump4;
turn_onimmediateB4_Failure;
if (Cycle= 1) {
turn_onFailure_B2ª;
}
if (Cycle= 2) {
turn_onFailure_B3ª;
}
if (Cycle= 3) {
turn_onFailure_B4ª;
}
if (Cycle= 4) {
turn_onFailure_B1ª;
}
}
network 5 // Reset the failures after of corrective maintenances.
if (Reset_Failures) {
turn_offFailure_B1ª;
turn_offFailure_B2ª;
turn_offFailure_B3ª;
turn_offFailure_B4ª;
network 6 // Clocks time of operation of the pumps (550 hours is approximately the maximum time that can be accumulated into our timers; when any pump reaches to this time, all the functioning times are zeroed and is initiated new temporization).
when (immediatePump1) temporize_accumulateTimeFunc_B1 550 h;
when (immediatePump2) temporize_accumulateTimeFunc_B2 550 h;
when (immediatePump3) temporize_accumulateTimeFunc_B3 550 h;
when (immediatePump4) temporize_accumulateTimeFunc_B4 550 h;
if ( notimmediateTurn_Off_Pumps) {
// Converts times of operation of the pumps, from milliseconds to ... // ... minutes, and shows it for purposes of operational control:
network 7 // Reset all var times of operation of the pumps to zero, when the command reset clocks is issued or is exceeded maximum temporization of any pump (maximum time allowed by the utilized equipment CLP; in the our simulator, 550 h)
if (TimeFunc_B1orTimeFunc_B2orTimeFunc_B3orTimeFunc_B4orReset_Clocks) {
resetTimeFunc_B1;
resetTimeFunc_B2;
resetTimeFunc_B3;
resetTimeFunc_B4;
}
if (immediateFinalStart_B1) {
if (Cycle= 1) {
turn_onPump1ª_FinalStart;
}
if (Cycle= 2) {
turn_onPump2ª_FinalStart;
}
if (Cycle= 3) {
turn_onPump3ª_FinalStart;
}
if (Cycle= 4) {
turn_onPump4ª_FinalStart;
}
}
if (immediateFinalStart_B2) {
if (Cycle= 1) {
turn_onPump2ª_FinalStart;
}
if (Cycle= 2) {
turn_onPump1ª_FinalStart;
}
if (Cycle= 3) {
turn_onPump4ª_FinalStart;
}
if (Cycle= 4) {
turn_onPump3ª_FinalStart;
}
}
if (immediateFinalStart_B3) {
if (Cycle= 1) {
turn_onPump3ª_FinalStart;
}
if (Cycle= 2) {
turn_onPump2ª_FinalStart;
}
if (Cycle= 3) {
turn_onPump1ª_FinalStart;
}
if (Cycle= 4) {
turn_onPump4ª_FinalStart;
}
}
if (immediateFinalStart_B4) {
if (Cycle= 1) {
turn_onPump4ª_FinalStart;
}
if (Cycle= 2) {
turn_onPump3ª_FinalStart;
}
if (Cycle= 3) {
turn_onPump2ª_FinalStart;
}
if (Cycle= 4) {
turn_onPump1ª_FinalStart;
}
}
end
As result of the compilation of the Drain_Pumps program above, the SimuPLC 4.1.0 has generated, exactly, the following code, in Instruction List - IL:
// PLC Drain_Pumps // Controls 4 pumps of the drain sewer, turned on by rotation caster mode, according to the level reached by the material in the drain, and in caster, to balanced depreciation of the ones by use in similar intensity. It permits detection of problems of operation or failures of start in the pumps, with consequent automatic adjust in the rotating of turning on of the pumps. // Obs.: in the variables below, the cardinal 1, 2, 3 and 4 refer to pumps physically, but the ordinal 1ª (1st), 2ª (2nd), 3ª (3rd) and 4ª (4th) refer to pumps in the order in these ones will are turned on, which changes according to the cycle in that the system is operating (to implementation of the rotation caster), indicated by the value present in the variable Cycle: // Cycle = 1: B1 - 1ª, B2 - 2ª, B3 - 3ª, B4 - 4ª // Cycle = 2: B2 - 1ª, B3 - 2ª, B4 - 3ª, B1 - 4ª // Cycle = 3: B3 - 1ª, B4 - 2ª, B1 - 3ª, B2 - 4ª // Cycle = 4: B4 - 1ª, B1 - 2ª, B2 - 3ª, B3 - 4ª // Each time that the drain is empty, the variable Cycle is changed: 1, 2, 3, 4, 1, 2, 3, ... // After compilation, ascertain the virtual functioning selecting on menu: Virtual Plants -> Simulated Tanks of Liquids -> Turn SimuPLC On
NETWORK1// Logic of turning off of the pumps, if drain is empty or if is operated the switch of general turning off, and control of the cycle of operation in rotation caster.
LDD<=AIW0, 6400 OII0.0 RIQ0.1, 1 RIQ0.2, 1 RIQ0.3, 1 RIQ0.4, 1 RM0.1, 1 RM0.2, 1 RM0.3, 1 RM0.4, 1 INCBVB0 // Does var Cycle to vary from 1 to 4 alternately, turning on in MOVBVB0, Ve1
/I4, Ve1
*I4, Ve1 -IVe1, VB0 // rotation caster every one of the pumps, avoiding that their // operation times stay too much different along the time.
LDD=VB0, 0 // If var Cycle was not initialized, set it to first MOVB1, VB0
NETWORK2// Logic of rotation caster turning on of the pumps. Note that when the pump is turned on, this one only is turned off when the drain is completely empty (Drain_Level <= 6400).
LDNII0.0
LDD>AIW0, 19200
LDD>AIW0, 6400 AM1.2 AM1.3 AM1.4 OLD ALD
LDNM1.1 ALD LPS
LDD=VB0, 1 ALD SIQ0.1, 1 LRD
LDD=VB0, 2 ALD SIQ0.2, 1 LRD
LDD=VB0, 3 ALD SIQ0.3, 1 LPP
LDD=VB0, 4 ALD SIQ0.4, 1
LDNII0.0
LDD>AIW0, 32000 AM0.1
LDD>AIW0, 19200 AM1.1 OLD
LDD>AIW0, 6400 AM1.1 AM1.3 AM1.4 OLD ALD
LDNM1.2 ALD LPS
LDD=VB0, 1 ALD SIQ0.2, 1 LRD
LDD=VB0, 2 ALD SIQ0.3, 1 LRD
LDD=VB0, 3 ALD SIQ0.4, 1 LPP
LDD=VB0, 4 ALD SIQ0.1, 1
LDNII0.0
LDD>AIW0, 44800 AM0.2
LDD>AIW0, 19200 AM1.1 AM1.2 OLD
LDD>AIW0, 32000
LDM1.1 OM1.2 ALD OLD
LDD>AIW0, 6400 AM1.1 AM1.2 AM1.4 OLD ALD
LDNM1.3 ALD LPS
LDD=VB0, 1 ALD SIQ0.3, 1 LRD
LDD=VB0, 2 ALD SIQ0.4, 1 LRD
LDD=VB0, 3 ALD SIQ0.1, 1 LPP
LDD=VB0, 4 ALD SIQ0.2, 1
LDNII0.0
LDD>AIW0, 51200 AM0.3
LDD>AIW0, 19200 AM1.1 AM1.2 AM1.3 OLD
LDD>AIW0, 32000
LDM1.1 AM1.2
LDM1.1 AM1.3 OLD
LDM1.2 AM1.3 OLD ALD OLD
LDD>AIW0, 44800
LDM1.1 OM1.2 OM1.3 ALD OLD
LDD>AIW0, 6400 AM1.1 AM1.2 AM1.3 OLD ALD
LDNM1.4 ALD LPS
LDD=VB0, 1 ALD SIQ0.4, 1 LRD
LDD=VB0, 2 ALD SIQ0.1, 1 LRD
LDD=VB0, 3 ALD SIQ0.2, 1 LPP
LDD=VB0, 4 ALD SIQ0.3, 1
NETWORK3// Detects operating of the buoy security, when there is failure in the level sensor.
LDI0.3 MOVD64000, AIW0
LDI0.4 MOVD6400, AIW0
NETWORK4// Detects failures on anyone of the four pumps.
NETWORK6// Clocks time of operation of the pumps (550 hours is approximately the maximum time that can be accumulated into our timers; when any pump reaches to this time, all the functioning times are zeroed and is initiated new temporization).
LDIQ0.1 TONRT0, 1980000000
LDIQ0.2 TONRT1, 1980000000
LDIQ0.3 TONRT2, 1980000000
LDIQ0.4 TONRT3, 1980000000
LDNII0.0 // Converts times of operation of the pumps, from milliseconds to ... // ... minutes, and shows it for purposes of operational control: MOVDT0, Ve1
/D60000, Ve1 MOVDVe1, AQW1 MOVDT1, Ve1
/D60000, Ve1 MOVDVe1, AQW2 MOVDT2, Ve1
/D60000, Ve1 MOVDVe1, AQW3 MOVDT3, Ve1
/D60000, Ve1 MOVDVe1, AQW4
NETWORK7// Reset all var times of operation of the pumps to zero, when the command reset clocks is issued or is exceeded maximum temporization of any pump (maximum time allowed by the utilized equipment CLP; in the our simulator, 550 h)