 RsLogix 500 - Program Flow, Which Rung Wins Part 3

In this lesson we are going to go step by step in depth of how we ended up with the results of your last run wins scenario.

In your last lesson, RsLogix 500 - Program Flow, Which Rung Wins Part 2, you saw some surprising results to what can happen if you have a double coil.

This is where many of the "rules", such as only using an output coil twice, come from.  While we completely agree that you shouldn't use a double coil such as we did in this lesson series, it is important that you understand how the PLC executes these two rungs.  Often we've heard people say "Don't use a double coil because the PLC's were not designed to handle them and it confuses the PLC".  PLC's don't get confused, they execute code in a repetitive methodical manner.

You may also be asking yourself, "why would anyone put these two rungs into the same PLC program?".  These are two very common rungs for controlling outputs.  You might simply type the wrong address into one of the OTEs or there could be hundreds of rungs in between them and you forgot that you added the OTE early on in the program and insert a second rung to control it.

Here is a look at the your program when it was first downloaded with no buttons pressed, Switch 1 to the left, and the Green Light off. Here is the PLC scan for the above image.

1. The PLC updates its input data table values based off of the physical states of the inputs.  Since input 2 has current flow, it puts a "1" in the I:0/2 data box.  I:0/0 and I:0/4 get 0s in their data boxes.

2. The PLC begins executing the ladder logic with the very left instruction of rung 0. The XIC ask "Is there a "1" in the I:0/4 data box?".

3. The PLC looks in the I:0/4 data box and sees there is a "0" in the I:0/0 data box.

4. The instruction was looking for a "1" but found a "0". The instruction is evaluated as FALSE.

5 and 6.  The instructions leading up to our OTE were false, it writes a "0" to the O:0/0 data box.  Just as a reminder, the PLC has only written to a data box in this step, not the output.

7. This is the end of the rung, the processor now moves to the far left of the next rung.

8. The XIC ask "Is there a "1" in the I:0/0 data box?".

9. The PLC looks in the I:0/0 data box and sees there is a "0" in the I:0/0 data box.

10. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.  This is the end of the branch so it goes back to the beginning of the branch and goes down to the next path.

11. The XIC ask "Is there a "1" in the O:0/0 data box?".

12. The PLC looks in the O:0/0 data box and sees there is a "0" in the O:0/0 data box.  Remember, the PLC doesn't treat looking at an output's data box any different than an inputs data box, to the PLC it is just another box.

13. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.  There are no other branches for the PLC to execute so it continues to the next instruction to the right.

14. The XIC ask "Is there a "1" in the I:0/2 data box?".

15. The PLC looks in the I:0/2 data box and sees there is a "1" in the I:0/2 data box.

16. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

17 and 18. Neither of the branches at the beginning of the rung were true so we do not have a continuous path of trues from left to right so the OTE will be FALSE, it writes a "0" to the O:0/0 data box.

19. This is the end of the rung, the processor now moves to the far left of the next rung.  While the next rung was omitted for space, it contained the END instruction. It signals the PLC to proceed to update it's output instructions.

20. The PLC updates it's outputs based off of the output data table. If there is a "0" in an output data box then it turns the output off, if there is a "1" in an output data box then it turns the output on. Since O:0/0's data box has a "0" in it, O;0/0, the Green Light, is OFF.

21. The PLC does its overhead then returns to step 1.

What will happen when Switch 1 is turned to the right(on)?  That was a lot for you to take in, but let's do it again with the Switch 1 to the right position (on).  Looking at our program it doesn't look like there is a way for Rung 1 to be true without the Green Button being pressed. When you go through the program step by step it will begin to make sense.

1. The PLC updates its input data table values based off of the physical states of the inputs.  Since inputs 2 and 4 have current flow, it puts a "1" in the I:0/2 and I:0/4 data box.  I:0/0 gets a "0" in it's data box.

2. The PLC begins executing the ladder logic with the very left instruction of rung 0. The XIC ask "Is there a "1" in the I:0/4 data box?".

3. The PLC looks in the I:0/4 data box and sees there is a "1" in the I:0/0 data box.

4. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

5 and 6.  The instructions leading up to our OTE were true, it writes a "1" to the O:0/0 data box.

7. This is the end of the rung, the processor now moves to the far left of the next rung.

8. The XIC ask "Is there a "1" in the I:0/0 data box?".

9. The PLC looks in the I:0/0 data box and sees there is a "0" in the I:0/0 data box.

10. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.  This is the end of the branch so it goes back to the beginning of the branch and goes down to the next path.

11. The XIC ask "Is there a "1" in the O:0/0 data box?".

12. The PLC looks in the O:0/0 data box and sees there is a "1" in the O:0/0 data box.

13. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.  There are no other branches for the PLC to execute so it continues to the next instruction to the right.

14. The XIC ask "Is there a "1" in the I:0/2 data box?".

15. The PLC looks in the I:0/2 data box and sees there is a "1" in the I:0/2 data box.

16. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

17 and 18. The lower branch at the beginning of the rung was true so we do have a continuous path of trues from left to right so the OTE will be TRUE, it writes a "0" to the O:0/0 data box.

19. This is the end of the rung.  The processor now moves to the far left of the next rung.  While the next rung was omitted for space, it contained the END instruction. It signals the PLC to proceed to update it's output instructions.

20. The PLC updates it's outputs based off of the output data table.  Since O:0/0's data box has a "1" in it, O;0/0, the Green Light, is ON.

21. The PLC does its overhead then returns to step 1.

Once the scan is done, our PLC now looks like this. What will happen when Switch 1 is turned back to the left (off)?

1. The PLC updates its input data table values based off of the physical states of the inputs.  Since input 2 has current flow, it puts a "1" in the I:0/2 data box.  I:0/0 and I:0/4 gets 0s in their data boxes.

2. The PLC begins executing the ladder logic with the very left instruction of rung 0. The XIC ask "Is there a "1" in the I:0/4 data box?".

3. The PLC looks in the I:0/4 data box and sees there is a "0" in the I:0/0 data box.

4. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.

5 and 6.  The instructions leading up to our OTE were false, it writes a "0" to the O:0/0 data box.  Just as a reminder, the PLC has only written to a data box in this step, not the output.

7. This is the end of the rung, the processor now moves to the far left of the next rung.

8. The XIC ask "Is there a "1" in the I:0/0 data box?".

9. The PLC looks in the I:0/0 data box and sees there is a "0" in the I:0/0 data box.

10. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.  This is the end of the branch so it goes back to the beginning of the branch and goes down to the next path.

11. The XIC ask "Is there a "1" in the O:0/0 data box".

12. The PLC looks in the O:0/0 data box and sees there is a "0" in the O:0/0 data box.  Remember, the PLC doesn't treat looking at an output's data box any different than an inputs data box, to the PLC it is just another box.

13. The instruction was looking for a "1" but found a "0", the instruction is evaluated as FALSE.  There are no other branches for the PLC to execute so it continues to the next instruction to the right.

14. The XIC ask "Is there a "1" in the I:0/2 data box?".

15. The PLC looks in the I:0/2 data box and sees there is a "1" in the I:0/2 data box.

16. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

17 and 18. Neither of the branches at the beginning of the rung were true so we do not have a continuous path of trues from left to right so the OTE will be FALSE, it writes a "0" to the O:0/0 data box.

19. This is the end of the rung, the processor now moves to the far left of the next rung.  While the next rung was omitted for space, it contained the END instruction. It signals the PLC to proceed to update it's output instructions.

20. The PLC updates it's outputs based off of the output data table. If there is a "0" in an output data box then it turns the output off, if there is a "1" in an output data box then it turns the output on. Since O:0/0's data box has a "0" in it, O;0/0, the Green Light, is OFF.

21. The PLC does its overhead then returns to step 1.

Once the scan is done, our PLC now looks like this. What will happen when the Green Button is pressed?  While we have made it clear that the last rung obviously doesn't win, you may be thinking now that the first rung won up until the green button was pressed.  Go through the program scan below to understand how the Green Button also turns on the Green Light.

1. The PLC updates its input data table values based off of the physical states of the inputs.  Since inputs 0 and 2 have current flow, it puts a "1" in the I:0/0 and I:0/2 data box.  I:0/4 gets a 0 in it's data box.

2. The PLC begins executing the ladder logic with the very left instruction of rung 0. The XIC ask "Is there a "1" in the I:0/4 data box?".

3. The PLC looks in the I:0/4 data box and sees there is a "0" in the I:0/0 data box.

4. The instruction was looking for a "1" and found a "0", the instruction is evaluated as FALSE.

5 and 6.  The instructions leading up to our OTE were false, it writes a "0" to the O:0/0 data box.

7. This is the end of the rung, the processor now moves to the far left of the next rung.

8. The XIC ask "Is there a "1" in the I:0/0 data box?".

9. The PLC looks in the I:0/0 data box and sees there is a "1" in the I:0/0 data box.

10. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.  This is the end of the branch so it goes back to the beginning of the branch and goes down to the next path.

11. The XIC ask "Is there a "1" in the O:0/0 data box?".

12. The PLC looks in the O:0/0 data box and sees there is a "0" in the O:0/0 data box.

13. The instruction was looking for a "1" and found a "0", the instruction is evaluated as FALSE.  There are no other branches for the PLC to execute so it continues to the next instruction to the right.

14. The XIC ask "Is there a "1" in the I:0/2 data box?".

15. The PLC looks in the I:0/2 data box and sees there is a "1" in the I:0/2 data box.

16. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

17 and 18. The upper branch at the beginning of the rung was true so we do have a continuous path of trues from left to right so the OTE will be TRUE, it writes a "1" to the O:0/0 data box.

19. This is the end of the rung, the processor now moves to the far left of the next rung.  While the next rung was omitted for space, it contained the END instruction. It signals the PLC to proceed to update it's output instructions.

20. The PLC updates it's outputs based off of the output data table.  Since O:0/0's data box has a "1" in it, O;0/0, the Green Light, is ON.

21. The PLC does its overhead then returns to step 1.

Once the scan is done, our PLC now looks like this. What will happen when the Red Button is pressed while Switch 1 is to the right (on)?  Hopefully by now this is starting to sink in but this last example is worth going through because it helps clear up another misunderstanding in how PLCs "turn on and off" outputs.  In the example below, the data box associated with the Green Light, O:0/0, will start off with a "0", then change to a "1", then back to a "0" during the scan cycle.  Some people will say this causes the output to chatter or turn on and off very rapidly making the output state unpredictable.  Remember, the output's physical state is only updated after ALL the PLC's ladder logic is scanned so even if it changes 100 times in a program, only the value in the data box at the end of the scan affects the physical output.

1. The PLC updates its input data table values based off of the physical states of the inputs.  Since input 4 has current flow, it puts a "1" in the I:0/4 data box.  I:0/0 and I:0/4 gets 0s in their data boxes.

2. The PLC begins executing the ladder logic with the very left instruction of rung 0. The XIC ask "Is there a "1" in the I:0/4 data box?".

3. The PLC looks in the I:0/4 data box and sees there is a "1" in the I:0/0 data box.

4. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.

5 and 6.  The instructions leading up to our OTE were true, it writes a "1" to the O:0/0 data box.

7. This is the end of the rung, the processor now moves to the far left of the next rung.

8. The XIC ask "Is there a "1" in the I:0/0 data box?".

9. The PLC looks in the I:0/0 data box and sees there is a "0" in the I:0/0 data box.

10. The instruction was looking for a "1" and found a "0", the instruction is evaluated as FALSE.  This is the end of the branch so it goes back to the beginning of the branch and goes down to the next path.

11. The XIC ask "Is there a "1" in the O:0/0 data box?".

12. The PLC looks in the O:0/0 data box and sees there is a "1" in the O:0/0 data box.

13. The instruction was looking for a "1" and found a "1", the instruction is evaluated as TRUE.  There are no other branches for the PLC to execute so it continues to the next instruction to the right.

14. The XIC ask "Is there a "1" in the I:0/2 data box?".

15. The PLC looks in the I:0/2 data box and sees there is a "0" in the I:0/2 data box.

16. The instruction was looking for a "1" and found a "0", the instruction is evaluated as FALSE.

17 and 18. The lower branch at the beginning of the rung was true but the previous instruction was false so we do not have a continuous path of trues from left to right so the OTE will be FALSE, it writes a "0" to the O:0/0 data box.

19. This is the end of the rung, the processor now moves to the far left of the next rung.  While the next rung was omitted for space, it contained the END instruction. It signals the PLC to proceed to update it's output instructions.

20. The PLC updates it's outputs based off of the output data table.  Since O:0/0's data box has a "0" in it, O;0/0, the Green Light, is OFF.

21. The PLC does its overhead then returns to step 1.

Once the scan is done, our PLC now looks like this. Conclusion

This three part series is a lot to take in.  But if you fully understand these concepts then you will advance very quickly through the rest of the lessons.  Next you will go over some various way to program start stop funcations in the RsLogix 500 - Start Stop Motor Programming - Four Different Ways.