Dennis0Bauer
Member
I want to do an If/Else like structure in ladder programming, does anyone know a link to a good tutorial? I tried to google it but all i get is C(++) in my search results.
I am not sure this is exactly what you are looking for. What PLC are you using?
A very basic IF/ELSE would look something like this:
I:1 O:1
------------[ ]-------------------------( )
I:1 O:2
------------(/)-------------------------( )
Basicly IF Input 1 is true set Output 1 coil.
Else set Output 2 coil.
See attachment, stupid ipad.
Yes, but in the PLC world most of the time, who cares? Unless each section of the code is huge and heavy with math, the differences in scan times would be negligeable.in the case of normal IF/THEN, part of code (IF or THEN ) should not be executed at all
I had 3 beers when i posted my initial apply, I've just cracked into my 6th and its 32 degrees C so lets see how this half drunken attempt is!
That is not the whole story. In the old original programming languages, the IF-THEN-ELSE function was a two-branched condition, "IF [first expression true] THEN [do this or jump here] ELSE instead [do this or jump there]".....in the case of normal IF/THEN, part of code (IF or THEN ) should not be executed at all
| IF TRUE DO THIS |
|----| |---------( )----|
| |
|Otherwise, do nothing! |
| |
| IF TRUE DO THIS |
|----| |---------( )----|
| |
| ELSE DO INSTEAD |
|----|/|---------( )----|
This varies by PLC brand/model.
An AB PLC/5 has the INV instructon which inverts the rung state, very hand for IF/THEN/ELSE rungs. However, it is the only AB PLC that has it.