To Latch Or Not To Latch

BOWRIDER

Member
Join Date
Mar 2003
Location
FLORIDA
Posts
58
Hello again fellas! I have a little question/observation. I am fairly new to the wonders of plc programming. I probably started self study at work and at home about two years ago almost exclusively on AB rslogix and feel that I have become fairly proficient at discrete type programming. I have yet to venture into analog or pid stuff yet but I will save that for another time.
What I have noticed during my studies is for reasons unknown to myself until just recently, is I have always favored latching outputs, bits etc using a branch as opposed to the OTL and OTU instructions. Recently while troubleshooting a program at work that had many otl and otu instructions I think it has dawned on me as to why they were never popular with me. The reason is troubleshooting. My feeble mind finds it very distracting to have to jump back and forth in the program finding all the latches and unlatches for a particular output.
Now for my questions.... Which method do you seasoned guys prefer? and also do other manufactures programming software contain their own versions of the OTL and OTU instructions? I can't stay here tonight but I look forward to reading your replies Tomorrow.
good night gentlemen! And happy Halloween!
 
I don't have a problem with either method. Each has their pluses and minuses.

If your code is really modular then handling latch/unlatch is pretty straight forward and really easy to troubleshoot.

As in the case for any PLC programming, careful planning (organization) rules the day.

There will be plenty of others that say NO! NO! NEVER USE LATCH/UNLATCH!

Those are guys that have been burned by their own inadequate planning.

Latch & Unlatch are reasonable tools to use... otherwise... why do they exist?

It boils down to careful usage and organization... just like anything else in programming.
 
YOU'RE NOT DOING IT RIGHT!

And you're not doing it wrong, either. The use of latches is, in a lot of cases, the preference of the programmer. Now, there are times when one is more sensible than the other, and some instances where one is necessary. But the beauty of programming is you can basically program in a signature style all your own. As you program more you'll start to notice where the differences I mentioned above come into play.
 
I use both methods. As Terry stated, each one has their advantages/disadvantages.

When I use latch and unlatch, I try to keep them on adjacent rungs, so you don't run into the troubleshooting headaches that you mention.

beerchug

-Eric
 
Eric hit it right on the head....the key to OTL and OTU are keeping them in the same proximity in the code for a given coil, preferrably in adjacent rungs...some people claim OTL and OTU is a little more spaghetti like, but I disagree....I use them when I can, don't be afraid to if you have well thought out code.


Greg
 
Eric Nelson said:
When I use latch and unlatch, I try to keep them on adjacent rungs, so you don't run into the troubleshooting headaches that you mention.

I agree. I try to only use latches when I want info to be retained through power cycles.

Though in RSlogix, the right-click find all button reduces the headache significantly.

(Not a RSL pom pom, its just that I do most of my programming with it and haven't used much else lately)
 
I'm pretty much like everyone else, I use both; and I keep the latch/unlatches together. The latch & unlatch command is really a set and clear function. Many other programming interfaces have these commands, I know Tisoft does, and Foxboro DCS has the set/clear function also.

Ken
 
I use latch&Unlatch with AB because that the only option AB offer for retentive relaye when the power is go off&on.
I dont like to use latch&Unlatch even it "make sense"
You need to write your code in a way you can easily see when you latch certain bit and where you unlatch.
You also need to unlatch all when the power go on or under certain conditions.
 
I typically use latches on occasion, but I try to avoid over-using them.

Some of my customers specify that latches are forbidden in their code (I believe it's in a DaimlerChrysler spec. somewhere). I suspect that they do that for troubleshooting/readability reasons.
 
I avoid latching and unlatching coils, and resetting bits through other kinds of manipulation. That is for the very reason you identify - troubleshooting is simplified. A holding contact is much more obvious, and you can more easily keep track of what is going on and why things are behaving the way they are.

I do occassionally use them, but only when it represents a significant advantage in the logic (which is seldom) and then I comment the heck out of the code and try to keep them in close proximity in the code.
 
but don’t forget the SAFETY issue ...

Greetings to all,

besides all of the other aspects of “to latch or not to latch” being discussed here, one EXTREMELY important characteristic of latches which has not been specifically mentioned is the “retentive” nature of these beasts ...

these guys did mention something about the subject in passing ...

from Rube in post #3:

The use of latches is, in a lot of cases, the preference of the programmer. Now, there are times when one is more sensible than the other, and some instances where one is necessary.

from Rick Densing in post #8:

I try to only use latches when I want info to be retained through power cycles.

from ArikBY in post #11:

I use latch&Unlatch with AB because that the only option AB offer for retentive relaye when the power is go off&on. ... You also need to unlatch all when the power go on or under certain conditions.

let’s take a look at this in more detail ...

suppose that programmer Sam likes the “seal-in” type of construction ... and Sam has programmed the saw in the figure below ...

suppose that programmer Greg likes the “latch/unlatch” type of construction as his personal favorite ... and Greg has programmed the grinder in the figure below ...

[attachment]

and both machines having been working fine for a very long time now ... the start buttons start ... the stop buttons stop ... the boss is making money ... what more could we ask for? ...

now suppose that while the saw and the grinder are both happily running along, the electrical power to the building suddenly dies ... naturally all of the machinery comes to a halt ... the question is, folks: “what is going to happen when the power eventually comes back on?” ...

well, the saw motor will NOT start back up automatically ... BUT (and here’s the punch-line) ... the grinder motor WILL start back up just as soon as the power comes back on ... and that could be a BIG safety issue ...

now ... I know that I’m going to get a bunch of posts saying stuff like: “well you should have OTHER things (mechanical interlocks, etc., etc., etc.) to prevent the grinder from coming back on” ... I’m not going to debate all of that ... the major point here, folks, is that there are some BIG differences between the way “seal-in” constructions and “latch/unlatch” constructions behave ... the example above is meant to demonstrate that concept in an easy-to-visualize way ...

the book says that the latches are “retentive” but doesn’t do much in the way of explaining (from a safety standpoint) just what the term “retentive” means ... basically it means that you can write a program using latches and unlatches which will perform flawlessly in the shop ... and work perfectly when you commission the machine ... and function faultlessly when the customer accepts the machine and puts it into use ... BUT ... if you haven’t adequately considered the “retentive” nature of the latch/unlatch construction, then you could conceivably have a ticking time-bomb on your hands ...

now I know that some people don’t like latches ... and some even flatly refuse to use them at all ... but now let’s go one step further and think about this next angle ...

suppose that we use a Recirculation Pump for our next example ... suppose that this particular recirculation pump is necessary to keep our nuclear reactor cool ... now if we were to unwisely use the “seal-in” approach to program its control, then every time the electrical power flickered, someone would need to go over and press the start button to bring the pump back on again ... so this would be a natural place to use a “latch/unlatch” construction ... because the latches are “retentive” ... they “retain” their ON status when the processor is power-cycled ... so a latched-on construction would definitely be a better (SAFER) way to program our recirculation pump ...

and please, folks, don’t jump on my case about how to REALLY control a nuclear power plant ... we all know that I’m just trying to come up with some interesting examples to illustrate these programming concepts ...

next ... a basically true story ... suppose that a customer has programmed his lumber mill using seal-in rungs to help the processor “remember” where the logs are located ... so when a log moves past Limit Switch A, he seals-in bit B3/22 ... this means there is a log in position A ... when the log moves past Limit Switch B, he unseals bit B3/22 ... this means that Position A is empty and ready for the hydraulic ram to feed in another log ... now suppose that the ram has just shoved a log into Position A ... so bit B3/22 is set (1) ... but then the power to the plant flickers ... what happens to B3/22? ... since he’s using a seal-in rung construction, B3/22 gets reset (0) ... oops! ... the PLC thinks that Position A is empty ... the hydraulic ram shoves in an extra log and does about $4,000 damage to the saw ...

this would have been a good place to have used a “latched-on” type rung construction ...

and so in summation ... in addition to all of the perfectly valid “keep the controls together” and “latches and unlatches are neater than seal-ins” and “seal-ins are easier to troubleshoot” arguments, there ARE some important SAFETY issues to consider when deciding whether “to latch or not to latch” ...

finally ... for those who want to dig even deeper into this subject, much of what I’ve included here (and much more) can be found in this previous thread about “pre-scan” ... for inquiring minds, it might make for some interesting reading ...

retain.jpg
 
Last edited:

Similar Topics

So I'm having issues with a certain rung and one of my coworkers mentioned it may not allow the signal past the latch coil. For example in the...
Replies
27
Views
3,692
Hello All, Can someone see what I did wrong here. My "PA" bit never seems to get energized despite hitting "SOFTKEY7" many times
Replies
5
Views
707
I am trying to use level switches to control a valve. If a level switch goes hi, it closes a valve. I am using ONS to keep the switches...
Replies
4
Views
1,011
There are some programs that have multiple latch instruction on the same rung of logic when RS Logix 5000 is the development software. The RS...
Replies
11
Views
1,555
I need to describe sections of a ladder logic program is a latch section to stop/start a machine also considered an or gate ??
Replies
1
Views
665
Back
Top Bottom