... but don't forget "prescan" ...
Greetings to all,
first the bad news: this topic is just a little bit beyond a “beginner” stage discussion ...
now the good news: there is nothing here that a beginner won’t be able to understand ...
well, everything that’s been posted so far in this thread is right on target ... but no one has mentioned “prescan” yet ... so I’ll do my best ... now I’m not sure about other brands of PLC’s but here’s the basic idea behind the Allen-Bradley’s “startup” routine ... at least as far as “prescan” is concerned ...
before we get too deep into this, let me say that the “scan” chart provided by elhagan IS accurate ... but that chart is showing how the processor “starts” each NORMAL scan ... important point: the chart is only accurate AFTER the processor has finished its “prescan” routine ... THEN the chart is correct ... what the chart does NOT show is what happens when the processor VERY FIRST starts up ... just BEFORE the first “normal” scan ... and this is what I think Beryl is specifically interested in ... in other words, suppose that we “power down” the processor ... and then we “power it back up” ... what happens first? ... what happens next? ... then what happens after that? ...
now some people will tell you “just don’t worry about it” ... or “it all happens so fast that we can’t understand it” ... but then again, sometimes we absolutely MUST worry about it ... because sometimes things act really WEIRD when the system is first turned on ... the specific “real world” example given below comes from a frustrated customer’s “please help me” call ... he had been fighting this particular problem all day without success ... true, his program was a lot more complicated than the one I’m posting ... I’ve simplified it down to a few rungs so that we can concentrate on the major points ... but to this customer’s mind, what he was seeing the processor do - just “didn’t make sense at all” ... stay tuned ...
disclaimer: there are some minor (but important) differences between “prescan” for the PLC-5 family and for the SLC-500 family ... this discussion uses an SLC-5/04 processor as an example ... but in this specific discussion, either processor family would give the same results ...
Beryl asked:
Where does a PLC start up? I thought on powerup the PLC did a self test and some overhead then moved on to reading the inputs.
when the processor first “starts up” it does all of the “housekeeping” things that the previous responders have mentioned ... but next it does NOT start scanning the program rungs ... and it also does NOT examine the status of the inputs ... at least not yet anyways ... why not? ... because before it actually starts “scanning” the program and trying to control things, it’s going to do a “prescan” of the program ... and yes, this is done mostly for safety reasons ...
one of the things that the processor does during this “prescan” is to go through the ENTIRE program once and execute ALL OF THE RUNGS as FALSE ...
first notice that I said “ONE of the things” ... there is more to this subject than I’ll have time to cover in one or two posts ... next, notice that I said “ALL of the rungs” ... specifically, that includes rungs that are located in Ladder Files that are no longer “used” in the program ... specifically, EVEN in cases where the JSR (Jump to Subroutine) which “calls” the Ladder File has been disabled or even totally removed ... so that’s the tricky part ... usually when we disable or remove the JSR, then we normally expect that the affected Ladder File will no longer be scanned ... specifically, we expect that it will no longer have ANY effect on the operation of our program ... and normally it doesn’t ... but then again, there’s that little-known “prescan” thing which occasionally gives some quite confusing results ... stay tuned ...
for example, suppose that we PREVIOUSLY had a simple rung to control our Recirculation Pump ...
[attachment]
(just ignore the branch for awhile ... we’ll talk about that later) ... here in Ladder File 3, we were using a simple maintained contact switch to turn the pump off or on ... and we used to have a JSR rung located back in Ladder File 2 which “called” this Ladder File 3 ... life was simple and everything worked fine ... then one day the boss decided that he didn’t like the switch any more ... now he wants us to control the pump with momentary contact push buttons ... this should be a very simple task for people of our caliber ...
now we could have simply modified our existing rung to incorporate the new buttons ... we COULD have ... and we SHOULD have ... but we didn’t ... instead, we simply deleted the JSR rung from Ladder File 2 ... and we left this old “unused” rung stored away in Ladder File 3 ... we even changed the file’s name to “junk” so that future programmers wouldn’t be confused ... now keep in mind, we’ve totally deleted the JSR rung ... so there is NO WAY that this old rung will EVER be scanned again ... right? ... so it will have NO EFFECT on the operation of our program ... right? ... wrong! ... there’s that sneaky little “prescan” thing that I’m building up to ... stay tuned ...
on to the next post ...