How a Ladder is Scanned

Sarit

Member
Join Date
May 2003
Posts
11
Hi friends,

I am going through the section Learn PLC's on this site and trying to understand and learn the basics of PLC's

I have got a question while going through the sub-section How a Ladder is Scanned .As far I got ladder is scanned top to bottom. what I fail to understand in the diagram attached in word document(sorry again to attach a file since i am not aware how to cut and paste a ladder diagram on this page.

I would like to understand why the rung 2 on this ladder shows the contact as false tough the coil associated with the contact is energized as can be seen in rung 1 .

I am sure understanding this problem would help me moving further.

thanks in advance,
Sarit
 
Your confusion is valid. I don't think the diagram attached intended to associate the coils with the contacts. It simply shows the states of the coils as true or false, but doesn't give the addresses of the coils, which would then provide their association. I only work with A/B and Reliance PLCs. In an A/B PLC, the ladder is scanned from top to bottom, left to right. If a false contact is encountered, the scan moves on to the next branch or rung. If the entire rung is false, the output addresses (if coils) are turned off at the time they are scanned. In this case, if these addresses are referenced later in the program, they will contain zeros. The real world outputs associated with those addresses, however, do not change states until the end of the program. At that time, the output image is copied to the real world outputs (except with ControlLogix).
Hope this helps.
 
Only speaking for our controllers and software, we scan from left to right first, then top to bottom. Once at the end rung, everything is updated and the scan is complete. The controller will begin this process at the top of the ladder code each time.

If there has been a change during the scan, unless there is an interupt, it won't be updated until at the end when the program scan is complete.

Hope this helps.

God Bless,
 
Stephen's reply is valid for ladder logic in MOST PLCs. The only major brand that doesn't follow this convention, as far as I know anyway, is Modicons using 984 ladder logic. They scan each "page" by column top to bottom, and then shift right to the next column. They scan each page in sequence from first to last.

I am sure there are other exceptions in less popular brands.
 
Stephens reply may well be true for his PLC's, but in most cases the last line of his post does not hold true. For most PLC's any input changes (except interrupts)occurring once the scan has started will not be registered until the beginning of the next scan. They will not be actioned therefore until the end of the next scan.
 
You're rght of course, Nigel, but I think we may be getting too detailed for a beginner's needs. The difference between internal bits (coils and contacts) being updated during the scan and I/O updating is significant in the context of his question. The difference between ouputs updating at the end of a scan and inputs updating at the beginning of the next scan probably isn't.
 
Questions on Ron's post

Hi friends,

Thanks for the replies. Going throught Ron's post has helped me to divide the scan and try to understand it but has also raised several questions in my mind.

First of them is what exactly is meant by an instruction(I believe they are the different contacts and function that we write in the ladder diagram which governs the behaviour of output from PLC).

In the step 2 where it is mentioned that processore puts a 0 or a 1 in the bit depending on the command it sees while scanning the ladder. I have got myself confused here with the step 1 where the processor does the same thing I guess (or ladder scan is completely different from the way PLC works).

As my question is on how a ladder scan works I really want to know when a particular coil is turned on by the instructions before it, does the contact associated with the coil which is present in the following rung turns on too in the same scan of the ladder or is it reflected in the next scan as is explained in the examples given by Phil in his section in Learn PLC.

Also afer reading the post by Ron I have become interested in knowing how would a Jump instruction get executed? is it similar to what we see in normal programming languages or is it different.

Any replies would help me in going further.

cheers,
Sarit
 
Sarit,
Looking again at the example cited in your first post, It appears that Scan 1 shows a false contact in the first rung on the second branch. I think it should show that contact as true. Scan 1001 has the same issue. This looks like a mistake on the part of whoever created this document: http://www.plcs.net/chapters/scan13.htm
Instructions...There are input instructions and output instructions. Input instructions are evaluated to either true of false. Output instructions execute a command. When the processor evaluates a rung or branch to be true, it immediately executes the output instruction(s) at the end of the rung or branch. So, if the output instruction is a coil (OTE), it is "turned on" (at least in the output image table) right then. This happens even before the next branch is evaluated. Any references to that coil (address) that are used later in the program will contain a 1. This is true for A/B processors, but I can't say with certainty it's true for all PLCs.
JMP...A jump is the equivalent of the BASIC goto statement. The processor immediately JuMPs to the LaBeL in the JMP instruction. Any logic that is skipped is not executed at all as long as the rung containing the JMP is true. (These examples use A/B terminology)
LBL is like a line number or marker in your program that can be used by the JMP instruction.
JSR...The Jump to SubRoutine is equivalent to the BASIC gosub statement. The processor immediately moves to the corresponding SuBRoutine.
SBR is the first line of the subroutine. Just like a LBL, only it is for use with the JSR. With A/B processors, the SBR instruction is optional unless you're passing parameters. The JSR specifies a file number, so the processor will jump to the first line of the ladder file number whether or not it contains an SBR instruction.
RET is the instruction for RETurning from the subroutine. The processor will go back to the JSR from which the subroutine was called and pick up where it left off.
I hope this helps...Paul C.
 
Another way of looking at ladder logic that helps people with a background in higher level languages, is to think of it as a bunch of IF THEN statements.

Sample1.jpg


Would be the same as this in BASIC:

IF (ADRESS_0000=1 OR ADRESS 1000=1) AND ADDRESS_0001=1 THEN
LET ADRESS 1000=1

IF ADDRESS_1000=1 THEN LET ADDRESS 0500=1
 
Last edited:
disclaimer: what follows is intended for Allen-Bradley PLC-5 and SLC-500 platform processors ... other brands and types may differ ...



Greetings Sarit,



you asked:



what exactly is meant by an instruction (I believe they are the different contacts and function that we write in the ladder diagram which governs the behaviour of output from PLC).



your belief is correct ... specifically, ----] [---- is an instruction ... ------]/[------ is an instruction ... ---------( )--- is an instruction ... etc. ...

In the step 2 where it is mentioned that processore puts a 0 or a 1 in the bit depending on the command it sees while scanning the ladder. I have got myself confused here with the step 1 where the processor does the same thing ...



the difference is that in Step 1, the processor puts a 0 or a 1 into ONLY the bits which have “I:xxx” addresses ... specifically, in Step 1, the processor operates ONLY on the INPUT bits - not on any other type ... specifically, in Step 1, the processor does NOT affect the status of “Bxxx” or “Oxxx” or “Nxxx”, etc. type bits ... only the INput bits - which all begin with the letter “I” - are affected in Step 1 ...



I really want to know when a particular coil is turned on by the instructions before it, does the contact associated with the coil which is present in the following rung turns on too in the same scan of the ladder or is it reflected in the next scan as is explained in the examples given by Phil in his section in Learn PLC.



be careful with how you use the term “turned on” when talking about what happens to a “bit” ... personally, I refuse to let my beginning-level students use the words “turn on” or “turn off” when talking about a bit’s status ... it leads to too much confusion in their tender little minds ... instead they are required to say something along the lines of “the processor writes a 1 into the bit” or “the processor writes a 0 into the bit” ... note that this is NOT the same thing as “turning on the output” or “turning off the output” associated with that particular bit ... the actual “turning on” or “turning off” of the real-world output (the contact in the output module) is not done until Step 3 in the processors’ scan sequence ...



the following example might help you see what I’m talking about ...



question: in the following program, if we look at Lamp X (the actual field device) will the lamp be steady OFF? ... or will the lamp be steady ON? ... or will the lamp be flickering OFF and ON very rapidly? ...


 

False Lamp X
0000 ---] [----------( )--




True Lamp X
0001 ---] [----------( )--




False Lamp X
0002 ---] [----------( )--




True Lamp X
0003 ---] [----------( )--







discussion: a beginner might say: “I see that Rung 0000 turns the lamp OFF; and then Rung 0001 turns the lamp ON; and then Rung 0002 turns the lamp OFF; and then Rung 0003 turns the lamp ON ... so I think that the lamp will be flickering OFF and ON very rapidly” ...



but ... the beginner would be wrong ... the lamp (the real-world field device) will be steady ON in this example ...



now it is correct that the status of the BIT for Lamp X WILL INDEED be changing very rapidly from a 0 to a 1 to a 0 to a 1 as the processor executes the ladder rungs ... BUT ... the status of the BIT does not get sent to the contact in the output module until Step 3 in the scan sequence ... and at the end of each and every scan, the true condition of Rung 0003 (the last one executed) makes the status of the bit a 1 ... and so that value (1) is the ONLY condition that the contact in the output module ever sees ...



and again the same disclaimer: disclaimer: this description is intended for Allen-Bradley PLC-5 and SLC-500 platform processors ... other brands and types may differ ...



and incidentally, using the same output address more than once (as Lamp X in the example above) is USUALLY considered poor programming practice ... this is often called a “double-coil” setup and should be avoided ... it is, however, often extremely useful for educational purposes ...



Also afer reading the post by Ron I have become interested in knowing how would a Jump instruction get executed? is it similar to what we see in normal programming languages or is it different.




OkiePC has already done an excellent job of answering that one ...
 
Last edited:
Except for those that are "Total Bit-Weenies"...
(as in... "I doan need no stinkin' names!... I like 1s and 0s!")

These examples show just how important it is to develop proper names for the various input conditions.

Certainly you need a string of "true"s to turn on an output... but what does it mean if a particular condition is true?

If the particular element is... ---| |---, and it is true, then the only thing that can be said is that the particular condition is "ON".

If the particular element is... ---|/|---, and it is true, then the only thing that can be said is that the particular condition is "OFF".

Neither case includes a "name". Each case is true, but... what is it that is true? What does being "true" represent?

The Classic Example: This is the PLC version of a hardwired Start/Stop.

START STOP MTR
---| |---+---| |-------( )
|
MTR |
---| |---+


If START is true and STOP is true then turn ON the Motor.

So... let's back off a bit and look at common language...

If it is true that you see a START signal and it is true that you see a STOP signal... then, Start the Motor. Hmmm...

Just using a bit of common sense... if someone tells you to do something... and someone else, of equal standing and power, tells you NOT to do that something... what do you do? You obviously have a conflict... it "does not compute".

The real issue here is the conflict in the names.

Let's look at a real version of a hardwired Start/Stop.


START STOP MTR
---| |---+---|/|-------( )
|
MTR |
---| |---+


There is only one difference between this drawing and the previous drawing.
In the previous drawing, the PLC version, the STOP contact is Normally Open.
In this drawing, the real, hardwired version, the STOP contact is Normally Closed.

In the hardwired world, the STOP signal and its relay indicates that the STOP button is wired through a Normally closed contact. In the hardwired world, you press the STOP button to open the contact and thus drop the circuit. This is how it should be.

It just so happens that you do the same thing, however, with a different contact-type, in the PLC world. Huuuuuh? (That was a Tool-Man Huuuuh.)

Looking at the hardwired drawing... If START is true (Start button is pressed) and STOP is NOT true (Stop button is NOT pressed), then turn ON the Motor.

Again... let's back off a bit and look at common language...

If it is true that you see a START signal and it is true that you DO NOT see a STOP signal... then Start the Motor. Sounds pretty clear to me... how 'bout you?

Looking back at the PLC version...

START STOP MTR
---| |---+---| |-------( )
|
MTR |
---| |---+


.
To be logically consistent... without relying on any "internalized interpretation", the STOP signal should be called... "DON'T STOP".

In that case, if it is true that you see a START signal, and it is true that you see a DON'T STOP signal... then, Start the Motor.

This is logically correct.

If at any time you DON'T see the DON'T STOP signal... then Stop the Motor!

This too is logically correct.

At the very least, the Stop Element should be named "STOP (N/C)"

MGD...

Beyond that example... "names" should indicate the "CONDITION", not the device. For example, if a limit switch is used to indicate that a cylinder is extended... the name of the element should be "Cylinder is Extended"... not LS-2. And, be logically careful about the wiring of that switch... N/O or N/C... and the given name.
 
OkiePC said:
Sarit,
Looking again at the example cited in your first post, It appears that Scan 1 shows a false contact in the first rung on the second branch. I think it should show that contact as true. Scan 1001 has the same issue. This looks like a mistake on the part of whoever created this document: http://www.plcs.net/chapters/scan13.htm

I disagree... sorta.

It's been over 9 years since I wrote that so my memory may be fading on what I was thinking. But I'm quite sure I was trying to emphasize the evaluation order of each instruction in the ladder.
In re-reading the page I can see how that's hard to understand since it was never fully explained to the reader...

My point was to evaluate each instruction in order as the plc scan will. Like so:
contact 0000
or contact 1000
contact 0001
coil 1000
contact 1000
coil 500

therefore:

initially 0000 and 0001 are TRUE (or 1's or ON or...)
so:
contact 0000 is true
or contact 1000 is false AT THIS POINT IN TIME
contact 0001 is true
coil 1000 is true NOW because of the true path through 0000 and 0001
contact 1000 is true from the above line
coil 0500 is true because there is a true path through 1000

Does that confuse the issue more? Maybe. Perhaps drawing the image tables at each point in time would help...

Anyway, I'm 99.999999999% sure that's what was going through my mind at the time of writing it. Sorry for the confusion....
 
Thanks and also a doubt

Thanks everybody. I am now quite clear about the ladder scan but coming accross a new word or a concept called double-coil. I did a search on this forum with key word as "double-coil" but the result it showed did not explain the concept of double-coil. Can anybody explain (or point to a link) what it is and is it related to old relay related connection before PLC came into existence....it is really interesting
 

Similar Topics

Could somebody please shed some light one the example "How a Ladder is Scanned" I don't understand why after scan 1 the contact referenced to the...
Replies
6
Views
2,598
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
1
Views
40
What is the best way to make an online program change with structured ladder without stopping the operation of the PLC using GX Works 2?
Replies
1
Views
98
Dear all, I don't know why setup of password became challenging and weird. After setting up the password and try to upload the ladder from the plc...
Replies
3
Views
98
Good morning crew! Ok my logic works but I am missing something. When the start button is pushed it should like the red light for 4sec then shut...
Replies
13
Views
352
Back
Top Bottom