Very basic ladder logic question

how deep shall we dig? ...

secret handshake on PLC timers ...



timers do not really “start” and they don’t really “run” ... in basic terms, the TON (the part in the ladder logic program) is an “instruction” which tells the processor to “SERVICE the timer” ... the actual timer is a location in the processor’s memory ...



this link should tell you much more about timers than you really want to know ... you’ll also want to read post #32 in that same thread for a step-by-step breakdown of how the TON timer does its job ...
 
Last edited:
my distinguished colleague robertmee has pointed out an “issue” in the latest way that you’ve described the processor’s scan cycle ...



Step two it executes the programming and step three it changes the outputs.



let’s just say that your terminology wouldn’t be allowed in my classroom - because it’s ambiguous ... what EXACTLY do you mean by the statement “changes the outputs”? ...



let’s try this abbreviated description ...



during Step 2, the processor executes the programming and THAT includes writing ONES and ZEROS into the appropriate bit/boxes ... (quite often these are “output” bit/boxes - but ANY bit/box can be written to) ... specifically, the bit/boxes do NOT necessarily have to have “O:” type addresses ...



now then on Step 3, the processor “sends the contents of the output bits to the output modules” ...



if you’ll express the two ideas in those exact terms, you should make quick progress ...



again - in an abbreviated form:



Step 2 - ...... the processor WRITES (ones and zeros) into bit/boxes ...



Step 3 - ...... the processor SENDS the contents of OUTPUT bit/boxes to the output modules ...



finally ... the most common mistake that most of my students make is considering those little round things at the ends of the rungs to be “outputs” ... they are NOT outputs ... they are instructions which tell the processor what (either a ONE or a ZERO) to write into the appropriate bit/box ...



I know that it's sometimes hard to understand EXACTLY what someone means just by reading a written statement ... it's much easier when questions and answers can be exchanged in "real time" ... so if you’re still confused, you’re welcome to call me ... my typing time is just about up for today ...
 
Last edited:
Since we now know that our OP will ultimately be working with an AB PLC lets talk about that for a moment.

The AB TON instruction supports multiple time bases, depending on the platform. I'll choose Logix500 platforms for this discussion since they are so common, but the same principles apply to other platform.

Since my purpose is to illustrate some nuances that result from the timer actually being a computer instruction as opposed to a hardware timer, lets just pretend that our PLC's internal time reference is dead nuts on and leave that discussion tangent by the way side.

The logic in the OP can be carried out by a simple single timer in any AB PLC. I'll select a one second time base and a 10,000 second preset for the timer as those are supported in the SLC500.
A072908A.JPG


For the sake of discussion, lets pretend that the logic above is part of a larger PLC program that takes 5 milliseconds, including the IO updates, to scan. The switch wired to input I:1/0 is closed at any arbitrary time and at the beginning of the next scan the input image table is updated to reflect that bit I:1/0 now has a value of 1. At some point in the program the timer instruction above will be exectued and it will begin recording the passage of time. This is not the passage of time from the instant the switch was closed, but from the time that the TON instruction was executed on memory address T4:0 after the switch was closed, which could be up to 5 milliseconds later.

Now lets leave our PLC undisturbed for 10,000 seconds. Remember we are pretending that our PLC time reference is exactly accurate for the sake of illustrating the point, but suffice it to say, that there will be a time where exactly 10,000 seconds have passed since the timer instruction addressed to T4:0 was first evaluated as enabled. Where will the PLC be in its program scan at that point in time? We don't know, it could be immediately before the TON instruction (best case) or immediately after the TON instruction (worst case), or anywhere else in the program scan. So our timer instruction could actually execute up to five milliseconds after the time period actually expired, meaning that it might be up to five milliseconds late on setting its done, DN, bit. This means our timing accuracy with respect to the switch closure could be 10,000 seconds plus 10 milliseconds. That is, it could be ten milliseconds late in writing a 1 into the DN bit.

The actual output switching on could be a few additonal milliseconds, up to an additional five milliseconds (depending on where in the program our TON instruction is located) + the actual swtich time of the hardware.

Now lets look at the AB equivalent of the OP program. A five second self resetting timer operates a counter to count 2000 five second periods.
A072908B.JPG


Same scan conditons as above apply. The timer instruction will be executed at a time up to five milliseconds after the switch wired to I:1/0 is closed. At that point in time it will begin tracking a five second time period. Time marches on, and five seconds expires. The processor could be on any instruction in the PLC program. It could be on the instruction immediately before the TON instruction (best case) or immediately after (worst case). Once again, when the timer instruction is executed and the DN bit is set, it could be five milliseconds late. So when our counter's accumulator counts up to 1, that could mean that a time anywhere from 5.0 to 5.005 seconds has passed. So far, so good, we expected that. On to the next scan. Remember that the timer DN bit is set. Next time the rung with our TON instruction is scanned the rung is false because the DN bit is set, so the timer instruction resets the ACC value in the memory element T4:0, and clears the DN bit and enable bit. Then it moves on. And the next scan after that the rung is true so the processor begins recording the passage of time again. Did you catch that? Two scans passed. That's the passage of ten milliseconds of time that were not accounted for. After our counter reaches 2,000 counts we are going to be off by twenty seconds absolutely best case, and off by maybe 30 seconds worst case. At this point the milliseconds lost at switch closure and ouput hardware update times seem like tears in the ocean.

Now we have a 999.9 second time limitation in the OP program, how would one minimize the error of timing 10,000 seconds? The error almost seems to be unavoidable. One way is to minimize the number of times we add in the error icurred every time the timer times out. At five second intervals we have 2,000 opportunities to totalize timing errors. But at 100 second intervals we have 100 opportunities to totalize timing errors, and at 500 second intervals we have just twenty opportunities. There are other methods as well which are not difficult to implement and are more accurate, but thats beyond the scope of this particular post, but I've covered them in other threads if one is inclined to search.

BTW, sometimes we have a tendency to think that a .01 second time base will be more accurate at timing than a one second time base, but that is not the case. A ten second timer using a one second time base will be just as accurate as a ten second timer using a .01 second time base (refer to Ron's links on how timers work if you want to get into the reasons) however, a 1 second time base has a problem resolving a 9.5 second time period, and a .01 second timer has a problem timing past five and a half minutes.
 
Before I open my mouth anymore let me do some heavy reading on this forum and on the links that were provided. Hopfully a 1 will get set in my brain in step one and the program in step 2 will process this and step 3 will turn on the light. Maybe.
Do not comment on this for I have to have something wrong.....
I will be back, but before I keep wasting your time I want to spend some time of my own reading.
 
before I keep wasting your time

if we thought that you were truly "wasting our time" then we wouldn't be replying ... you asked us for help - we're trying to help you ... and rest assured that there are many others who will come looking for help on this same topic in the future ... they will also be confused by these same issues - quite possibly even more so than you are ... we're writing for them too ...
 

Similar Topics

Im looking to hook up a 3 wire PNP photocell to an Allen Bradley 1746IV 16 module. Ive watched videos about hooking up DC sensors, but they show...
Replies
3
Views
2,967
I finally have my test/learning bed set up at home. I understand logic and programming, there are some holes in my basic electronics knowledge...
Replies
6
Views
3,414
Hello, I have an application where I will need to use the Serial port in a L55 CPU, and I can go about it in two ways, but both require me to...
Replies
2
Views
1,486
Hello, Forgive the basic question, but I've been having a hard time finding a clear answer to this online or otherwise. I'd really appreciate any...
Replies
10
Views
2,244
I will apologize in advance for this question. In a PLC scan I understand the inputs are read, then the PLC carries out a scan out the logic and...
Replies
11
Views
4,142
Back
Top Bottom