KMC
KMC

Reputation: 20036

Correct use of Condition Flags in PLC

A PLC documentation (Omron) shows a correct and incorrect use of Condition Flags (see image). But I do not see any difference between the two: if Instruction A is ON, then both Instruction B and the un-labeled instruction will be executed. Both ladder diagram implies achieve the same thing to me. Why one is incorrect and the other is correct?

enter image description here

Upvotes: 0

Views: 2407

Answers (1)

J...
J...

Reputation: 31453

This is similar to the differential instruction problem. Again, the condition flag (CF) is global and changes each time, in this case, a comparison operation is executed.

In the incorrect example, Instruction A will perform a comparison and the CF for equals (=) will be either true or false. The implied desired flow of operation is that if the instruction A returns true for equals then execute Instruction B, otherwise continue to the final rung.

In the case where Instruction A returns true for equals, however, then Instruction B will execute and, in this case, it is implied that it too is performing a comparison operation (presumably to be picked up in the next rung). If B returns false for equals, however, then the final branch of the current rung will still execute because it takes place after B's comparison - this even though the intention is to only execute the final branch if A returns false - not B!

The second example (correct) shows how to avoid leaking B's results into A's logic.

Upvotes: 2

Related Questions