In the control program below, two groups of lamps, each in the two-times traffic light set, are alight alternately according to the standard activation sequence, with possibility of the alight times to be altered, by the analogical inputs AIW0, AIW1 and AIW2; and also it's possible to deactivate the traffic light, by turning on of bit input I0.0, when then the yellow lights will be blink all time.
plcTraffic_Light// Control of traffic light with two sets of signaler lights (simple crossing) and signaling of deactivated state: yellow lights blinking
varQ0.0Green1, // Red Light of the first set ... Q0.1Yellow1,
Q0.2Red1,
Q1.0Green2,
Q1.1Yellow2,
Q1.2Red2,
AIW0TimeGreen1, // Time in that the green light remains alight in the set 1 AIW1TimeYellow1,
AIW2TimeRed1,
T0GetTimeGreen, // Var. of time that indicates that time of the light green was reached T1GetTimeYellow1,
T2GetTimeYellow2,
T3GetTimeRed,
T4TimeOn, // Time (500 ms) that the yellow lights are alight in the blink when the traffic light is deactivated T5TimeOff, // ... idem for time (500 ms) they are turned off I0.0BlinkYellows; // Indicates traffic light inactive, with the yellow lights blinking
network 0 // Begins the control in the sequence Green1Red2 and set temporization pattern if times of operation are not supplied in the variables AIW0, AIW1 and AIW2
if ( notVarAux){
operateInitiate; // Generates the pulse in Initiate when of the beginning of the operation (1º cycle) or (VarAux){
operateVarAux;
}
}
if (Initiate){
turn_onGreen1Red2; // Activates the initial sequence when of the beginning of the operation
}
if (TimeGreen1<= 0) { // If time is not supplied ... TimeGreen1 := 10; // ... receive pattern value
}
if (TimeYellow1<= 0) {
TimeYellow1 := 3; // Idem
}
network 1 // In the sequence Green1Red2 below the lights Green1 and Green2 remain alight sequenceGreen1Red2
network 2 // Control of turn on, turn off and temporization if ( notimmediateGreen1ornotimmediateRed2 ) {
turn_onimmediateGreen1;
turn_onimmediateRed2;
turn_offimmediateRed1;
turn_offimmediateYellow1;
turn_offimmediateYellow2;
turn_offimmediateGreen2;
resetGetTimeGreen;
}
when ( Green1 ) temporizeGetTimeGreenTimeGreen1s;
end_circuit_sequence
network 3 // Transfers running to the sequence "Yellow1Yellow2" if is deactived the traffic light if (immediateBlinkYellows) {
turn_offimmediateGreen1;
turn_offimmediateRed2;
turn_onimmediateYellow1;
turn_onimmediateYellow2;
transfer_sequenceYellow1Yellow2;
}
if ( GetTimeGreenandnotimmediateBlinkYellows) { transfer_sequenceYellow1Red2;}
network 4 // End of the sequence Green1Red2 end_sequence;
network 5 // In the sequence Yellow1Red2 the lights Yellow1 and Green2 remain blinking sequenceYellow1Red2
network 6 // Control of turn on, turn off and temporization if ( notimmediateYellow1ornotimmediateRed2 ) {
turn_onimmediateYellow1;
turn_onimmediateRed2;
turn_offimmediateGreen1;
turn_offimmediateYellow2;
turn_offimmediateRed1;
turn_offimmediateGreen2;
resetGetTimeYellow1;
}
when ( Yellow1 ) temporizeGetTimeYellow1TimeYellow1s;
end_circuit_sequence
network 7 // Transfers running to the next sequence if (immediateBlinkYellows) {
turn_offimmediateRed2;
turn_onimmediateYellow2;
transfer_sequenceYellow1Yellow2;
}
if ( GetTimeYellow1andnotimmediateBlinkYellows ) { transfer_sequenceRed1Green2; }
network 8 // End of the sequence Yellow1Red2 end_sequence;
network 9 // In the sequence Red1Green2 the lights Green1 and Green2 remain alight sequenceRed1Green2
network 10 // Control of turn on, turn off and temporization if ( notimmediateRed1ornotimmediateGreen2 ) {
turn_onimmediateRed1;
turn_onimmediateGreen2;
turn_offimmediateYellow1;
turn_offimmediateYellow2;
turn_offimmediateGreen1;
turn_offimmediateRed2;
resetGetTimeRed;
}
when ( Red1 ) temporizeGetTimeRedTimeRed1s;
end_circuit_sequence
network 11 // Transfers running to the next sequence if (immediateBlinkYellows) {
turn_offimmediateGreen2;
turn_offimmediateRed1;
turn_onimmediateYellow1;
turn_onimmediateYellow2;
transfer_sequenceYellow1Yellow2;
}
if ( GetTimeRedandnotimmediateBlinkYellows ) { transfer_sequenceRed1Yellow2; }
network 12 // End of the sequence Yellow1Red2 end_sequence;
network 13 // In the sequence Red1Yellow2 the lights Green1 and Yellow2 remain alight sequenceRed1Yellow2
network 14 // // Control of turn on, turn off and temporization if ( notimmediateYellow2ornotimmediateRed1 ) {
turn_onimmediateRed1;
turn_onimmediateYellow2;
turn_offimmediateYellow1;
turn_offimmediateGreen1;
turn_offimmediateGreen2;
turn_offimmediateRed2;
resetGetTimeYellow2;
}
when ( Yellow2 ) temporizeGetTimeYellow2TimeYellow1s;
end_circuit_sequence
network 15 // Transfers running to the next sequence if (immediateBlinkYellows) {
turn_offimmediateRed1;
turn_onimmediateYellow1;
transfer_sequenceYellow1Yellow2;
}
if ( GetTimeYellow2andnotimmediateBlinkYellows ) { transfer_sequenceGreen1Red2; }
network 16 // End of the sequence Red1Yellow2 end_sequence;
network 18 // In the sequence Yellow1Yellow2, the yellow lights blinking in the two sets indicate deactivated traffic light sequenceYellow1Yellow2
network 19 // Control of turn on, turn off and temporization if (BlinkYellows){
turn_offimmediateGreen1;
turn_offimmediateGreen2;
turn_offimmediateRed1;
turn_offimmediateRed2;
}
when ( notimmediateYellow1 ) temporizeTimeOff 500 ms;
if ( TimeOff ) {
turn_onimmediateYellow1;
turn_onimmediateYellow2;
}
when ( immediateYellow1 ) temporizeTimeOn 500 ms;
if ( TimeOn ) {
turn_offimmediateYellow1;
turn_offimmediateYellow2;
}
end_circuit_sequence
network 20 // Transfers running to the next sequence if ( notimmediateBlinkYellows ) {
turn_offimmediateYellow1;
turn_offimmediateYellow2;
transfer_sequenceGreen1Red2;
}
network 21 // End of the sequence Yellow1Yellow2 end_sequence;
end
As result of the compilation of the Traffic_Light program above, the SimuPLC 4.1.0 has generated, exactly, the following code, into Instruction List - IL:
// PLC Traffic_Light // Control of traffic light with two sets of signaler lights (simple crossing) and signaling of deactivated state: yellow lights blinking
NETWORK0// Begins the control in the sequence Green1Red2 and set temporization pattern if times of operation are not supplied in the variables AIW0, AIW1 and AIW2
LDNVarAux =Initiate // Generates the pulse in Initiate when of the beginning of the operation (1º cycle) OVarAux =VarAux
LDInitiate SGreen1Red2, 1 // Activates the initial sequence when of the beginning of the operation
LDD<=AIW0, 0 // If time is not supplied ... MOVD10, AIW0 // ... receive pattern value
LDD<=AIW1, 0 MOVD3, AIW1 // Idem
LDD<=AIW2, 0 MOVD10, AIW2 // Idem //**************************************************
NETWORK1// In the sequence Green1Red2 below the lights Green1 and Green2 remain alight
LSCRGreen1Red2
NETWORK2// Control of turn on, turn off and temporization