Rung scanning - fundamental question

bobby1234

Member
Join Date
Jun 2006
Location
houston
Posts
12
Hello everyone,

I have a fundamental question about typical A/B PLC rung scans.

Consider the following:

A B
---][-------()---

From what I have understood it means the following:

IF A = true THEN
B = true;
ELSE IF A = false THEN
B = false;
END IF;

So that means that each rung actually implies two statements:
one when A will be true and the other when A is false.

So if B is true above this rung somewhere and when the processor reaches this rung and A is false, IT WILL SET B TO FALSE.

Please tell me if I am wrong because this is an important point. I have a background in higer level programming (C, VB.NET, C#) and in those languages, true and false conditions have to be explicitly defined. False conditions are not evaluated so if A is false then nothing will happen to B, if it set to 1 above this rung, B will remain 1. If B is 0, it will still be 0. It seems that this is a very big and fundamental difference between ladder language programming and higher level programming.

Please advise.

Thanking you all,
Bobby1234
 
You are correct in your thinking about the single rung you posted. The input bit condition you defined as A controls the on and off state of the output bit condition B. If A is true, then B will be true and if A is false, then B will be false. This is a universal truth and global as far as its effect in the PLC program and memory. PLCs and ladder logic programming are really very simple but powerful nonetheless.
 
Greetings bobby1234,



my distinguished colleague Randy has already given you the correct answer ... but if you’re looking for more detail, then “Step 2” in this post may help ...



and if you’re looking for the “just-turn-on-it-but-don’t-turn-it-off” equivalent in ladder logic, then take a careful look at the Latch instruction used in Rung 0003 of this post ...



hope this helps ... and yes, you’re right ... there are some big differences between “higher languages” and “ladder logic” ... and much debate about which is the “better” of the two ...

and a slightly more accurate way of phrasing your original “statement” would be:

IF A = 1 THEN 
LET B = 1
ELSE IF A = 0 THEN
LET B = 0
END IF





the distinction between “true” and “1” - and the distinction between “false” and “0” might seem to be minor issues - but they have MAJOR implications in many cases ...
 
Last edited:
Although I'm not familiar with A/B processing rules, I've commented here as bobby1234 has posted a step 7 related question.

Note that block containing that rung must be called and there must be no jumps around that rung of logic. If the rung is not executed then the coil would stay at the last state it was processed.

Edit: surely the high level statement would be:

b:=a;
 
Last edited:
Greetings Simon,

surely the high level statement would be:

b:=a;

certainly you're correct ... but many (most?) people who are just beginning to learn ladder logic programming don't instinctively recognize it that way ...

by stating it the way I did, I've set the stage for teaching a "latch" rung as:

IF A = 1 THEN 
LET B = 1
END IF



and also for teaching an "unlatch" rung as

IF A = 1
THEN LET B = 0
END IF



the “A = B” approach, while perfectly valid for the original rung, doesn’t lend itself very well at all to the upcoming lessons of latches and unlatches ...

my favorite approach to teaching this stuff is to (hopefully) give one cohesive line of explanation which will work for all (or at least for most) situations ...
 
Last edited:
bobby1234 - when you posted A/B in the original post, did you mean Allen Bradley or were you simply referring to the A and the B in your ladder logic ?
 
Thank you for your quick responses. This was one of the questions that was really bothering me. And it is good have gurus here that can show me the way :). I have read the posts in this forum and there are some very good responses. I especially like your "overkill" approach Ron Beaufort. It can really clear up a lot of issues.

Simon Goldsworthy, thank you for your post for the Siemens PLC. Currently I am working on Siemens but I am very familiar with A/B PLCs because I wrote HMI software before that interacted with A/B PLCs. I am doing PLC programming nowdays. As such I wanted to clear my basics. I have responded to the your post at the other thread.

Once again, thank you randylud, Ron Beaufort and Simon Goldsworthy! I really appreciate that.
 
Ron, I was swayed by bobby1234's background of C which was making me think of the short but sweet answers!

A latch or Set would be

B:=A OR B;

An unlatch or Reset would be

B:=B AND NOT A;
 
In terms of the original question...

"Normal" Ladder Outputs are "LOOKING" for a reason to BE ON!

If that reason exists, then the Output will be ON. If not, it will be OFF.

What that means is... if you have a rung where any number of branches indicates that the output should be off, and at the same time, you have at least one branch which indicates that the output should be on... the output WILL be ON!

In most PLCs the Output is indicated by a positive assertion, symbolically, ---(...). In some PLCs, the Output might also be indicated by a negative assertion, namely, ---( / ).

In the case of the negative assertion, the output is LOOKING for a reason to be OFF.

In that case, if you have a rung where any number of branches indicates that the output should be on, and at the same time, you have at least one branch which indicates that the output should be off... the output WILL be OFF!
 
Simon is actually the closest to the truth. If you program a S7 can convert the LAD to STL you will see. The condition is evaluated to a true or false and that result is store in the output(s).

A simple example as bobby1234 presents would not be converted to an if then else.

Simon is also right about how a latch and unlatch is done. The computers inside the PLC do not have latch and unlatch instrucitons. They do have AND, OR and NOT instructions.

So how does Phil do it on his PLC simulator?
 
bobby1234 said:
Hello everyone,
bobby1234 said:
I have a fundamental question about typical A/B PLC rung scans.

Consider the following:

A B
---][-------()---

From what I have understood it means the following:

IF A = true THEN
B = true;
ELSE IF A = false THEN
B = false;
END IF;

So that means that each rung actually implies two statements:
one when A will be true and the other when A is false.

No. For coil output it will be:
IF A = true THEN
B = true;
ELSE B = false;
END IF;

So if B is true above this rung somewhere and when the processor reaches this rung and A is false, IT WILL SET B TO FALSE.
Correct.

Please tell me if I am wrong because this is an important point. I have a background in higer level programming (C, VB.NET, C#) and in those languages, true and false conditions have to be explicitly defined. False conditions are not evaluated so if A is false then nothing will happen to B, if it set to 1 above this rung, B will remain 1. If B is 0, it will still be 0. It seems that this is a very big and fundamental difference between ladder language programming and higher level programming.
Not always. For coils and many instructions false conditions ARE evaluated.

Bobby1234

..
 
if this is the ANSWER, what the heck does the QUESTION look like? ...

Greetings to one and all ...



first a note to my former (and even future) students who might be reading this thread ...



relax, ladies and gentlemen ... all is well ... nothing has changed ... the same rules that I taught you are still fully in effect ... the methods of rung and program analysis that we covered in the class still work flawlessly for all of the Allen-Bradley PLC processors that we covered ... again I say, relax ... now think back to the first morning of class ... remember how I fully explained a foolproof step-by-step method of analyzing and interpreting each of these basic ladder instructions: XIC, XIO, OTE ... and I showed you how to work out the “one/zero” status for any (I repeat ANY rung) regardless of how convoluted and complicated the branching structure of that rung might appear on the screen ... remember how we covered “double-coils”, and other points of confusion, and how each of those issues would affect the operation of the program ... now remember a day or two later when I covered the same type of foolproof step-by-step analysis for the OTL and OTU instructions ... and you learned about the safety implications of those “retentive” instructions ... all of that knowledge remains unchanged ... do not fear ... just think back and convince yourself ... remember the first morning of the class and how I gave you the “Golden Nugget of Truth” ... remember how I led you on the “Path of Enlightenment” ... and then remember what happened next ... I (the good instructor) suddenly became the EVIL instructor ... (shades of Socratic irony) ... I began “explaining” these very same basic concepts in the “old” ways that you (the students) had been hearing around the plant for years ... I began using the same incorrect terminology that you had “learned” from other sources before the class began ... and I put one “curveball” program after another - after another - after another - on the board for you to consider and discuss... and I “explained” the operation of these rungs to you using the fundamentally FLAWED methods that others before me had used in their ill-fated attempts to educate you in the mysteries of PLCs ... in short, I did everything within my diabolical power to confuse you ... and so - the stage was finally set ... I then sent you (the students) up to the whiteboard armed only with a marker - and with the knowledge that I had given you ... I forced you to analyze each of those convoluted, twisted, complicated, sadistic, devil-spawned rungs ... I watched closely as you worked step-by-step through the method of analysis that I had taught you ... and I cheered inwardly (and at times outwardly) when you knocked my “meant-to-be-confusing-curveball” questions right out of the proverbial ballpark ... I proved to myself - and (more importantly) to you - that you actually KNEW and fully UNDERSTOOD, at long last, the knowledge that had been eluding you throughout all of those many weary years of PLC confusion ... yes ... you (the good students) where able to CORRECT me (the evil instructor) when I tried to contradict the “Golden Nugget of Truth” ... you (the good students) were able to LEAD me (the evil instructor) when I tried to stray from the “Path of Enlightenment” ... remember ... you (each and every one of you) plucked the pebble from my hand - and, in so doing, you claimed at last the awesome potential that had always dwelt within you ... remember ... and rest assured, none of that has changed ...



as I said, that was for my students ... now for the rest of you guys ...



stop it ... you’re scaring the children ...



this would be a good place for a cute little smiley-face - but somehow I just can’t force myself to use those things ... but, of course, I’m just joking with you ...



yes, all of the things that are being said in this thread are basically correct ... and yes, the methods that you’re using to explain the operation of the PLC are fundamentally sound and valid ... but personally, I don’t use these particular methods of explaining the basic operation of the PLC in the technician-level classes that I teach ... remember that most of my students don’t sit in front of a computer and work on PLCs every day ... instead, most of these people have screwdrivers in their back pockets and they only touch the software once or twice a month - and in some cases, only once or twice a year ... what I teach them in a one-week class HAS to be something that they’ll fully understand, and will be able to remember, and will feel CONFIDENT in applying once they’re back on the job ... and what I teach them has to WORK every time they use it ... and we’ve only got one single solitary week to start with XIC, XIO, and OTE - and go all the way through BTR and BTW for analog signals ... “intense” and “demanding” are the most polite ways that most students describe this five-day period - so please don’t get the impression that the material is somehow “watered down” in any way ... in many (most?) cases we go much deeper into the “nuts-and-bolts” than this thread has been going ... consider this: the original rung (in the first post) only had TWO very simple instructions ... what happens when you take a confused beginner and try to teach him/her anything much beyond that basic rung - using some of the “teaching” techniques that have been offered in this thread? ... most of us know the answer to that question from bitter personal experience ... basically you get a student who has “learned” a lot of perfectly valid knowledge - but has absolutely no systematic method of applying that knowledge to the "get-the-machine-fixed" problems that occur out in the field ... I’ve got to send my students back to their bosses with something useful to “hang-their-hats-on” ... so let’s continue the discussion - but rest assured, there are other ways of explaining the same fundamental concepts that we’re dealing with here ... personally I like variety ... but keep in mind that not all students respond to the same material in the same way ... one size does NOT fit all ... and my method of explanation may vary ...

PS Edit: just in case I failed to make my primary point ... no, I do NOT use the IF...THEN...ELSE method of explanation in my classes ... but I certainly have no problems with discussing it ...

party on ...
 
Last edited:

Similar Topics

Hi folks, I am having a little trouble with a rung of code which appears at the bottom of the msg (Sorry, don't know how to paste it in here :(...
Replies
2
Views
3,813
See picture. I want to add a rung (magenta) into the existing code. Can't figure out how to do this. I select a -||- , right? When I drag/drop...
Replies
21
Views
1,697
Basic question: I don't understand why Network 4 is split over two lines. I want it to appear like for Network 3, i.e. all on one line. Does...
Replies
1
Views
739
Is it possible to add Rung Comments or Tag Descriptions when creating rungs with a text file? I think not but just checking.
Replies
5
Views
1,583
Back
Top Bottom