If/Else in Ladder programming

Dennis0Bauer

Member
Join Date
Dec 2012
Location
Kobe Japan
Posts
6
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.:confused:
 
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.
 
Actually Ladder dont have the statement as IF/Else, but you have to make the conditon using normal NO /NC contact according to ur structural reqiurement.
 
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.

This is defenetly not IF/ELSE

Conditional jump must be used
 
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!

image.jpg
 
Nice beer :)

Or one of variant


|input 1|---------------------(Conditional call function 1 for IF)
|
----|not|-----(Conditional call function 2 for THEN)

 
Last edited:
....in the case of normal IF/THEN, part of code (IF or THEN ) should not be executed at all
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]".

Instead, the "IF-THEN" function only looks at ONE condition and does ONE thing if the condition is true. If not true, then it does nothing. Wait! That is exactly what the typical PLC rung logic does.

"IF-THEN" function in PLC relay logic:

| IF TRUE DO THIS |
|----| |---------( )----|
| |
|Otherwise, do nothing! |
| |


"IF-THEN-ELSE" function in PLC relay logic:

| IF TRUE DO THIS |
|----| |---------( )----|
| |
| ELSE DO INSTEAD |
|----|/|---------( )----|


The "DO" output coils can instead be JUMPS to a PLC subroutine where anything possible can be done.
 
Last edited:
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.
 
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.

Yeah, that's a pretty non-standard instruction in the AB world. Especially that the PLC5 is a waning platform.
 

Similar Topics

Hello, I simply want to turn on & off a output relay by a single push-to-make momentary switch (i.e. when once switch is pressed, relay...
Replies
4
Views
3,457
11 months ago I ordered a 10" Redlion HMI. I was given an April delivery date. April came and went. I waited, and in June I asked our vendor...
Replies
7
Views
2,370
Hi I'm starting a new job (so i'm a newbie in ftview programming ) and i have the following problem : I must update some pages in a supervision...
Replies
3
Views
5,204
I'm about to have a guy onsite (I'm trying to help troubleshoot remotely) and he doesn't have the proper software. Usually I have the guys install...
Replies
4
Views
1,739
Back
Top Bottom