Latch instructions

ddear

Member
Join Date
Aug 2013
Location
York, Pa
Posts
4
Someone recently told me that a OTU cannot precede the OTL for the same bit in ladder logic. Is that old school or still valid? In my mind it's affecting the value of a memory location so what does it matter?
 
You're right, it doesn't matter. But if the rung conditions for both are true, the last OTU/OTL instruction performed will "win" for the remainder of that scan until the next OTU/OTL instruction is executed.
 
You're right, it doesn't matter. But if the rung conditions for both are true, the last OTU/OTL instruction performed will "win" for the remainder of that scan until the next OTU/OTL instruction is executed.


If the logic for the latch and unlatch were identical, then it would be inappropriate to use a latch to begin with.
 
I agree, latches have their place but the OP was asking if the order in which they should appear within a program scan is a requirement.


I agree. There are instances in which scan order matters. Even if the latch and unlatch statements don't have identical logic, it is certainly possible for both statements to be true within the same program sweep. In such a case, one would be assigning priority to either the latched or unlatched state by making one of them the last statement, rather than the first.
 
I agree. There are instances in which scan order matters. Even if the latch and unlatch statements don't have identical logic, it is certainly possible for both statements to be true within the same program sweep. In such a case, one would be assigning priority to either the latched or unlatched state by making one of them the last statement, rather than the first.
yeah, I believe Steve and I said as much.
 
feel free to ignore this post - but without meaning to beat this dead horse any further - the main difference in operation would become important whenever BOTH instructions might happen to be executed with TRUE logic ...

so ...

for those who use STX (Structured Text) or FBD (Function Block Diagram) programming, you might want to take a look at the SETD (Set Dominant) and the RESD (Reset Dominant) instruction/statements ...

these are provided to allow you to achieve the desired "LATCH last" - or "UNLATCH last" operation - whenever BOTH "inputs" might be TRUE at the same time ...

party on ...
 
Usually best to avoid latches, unless your purpose is to make retentive, or the situation dictates.
Better yet, comment why you chose to do it.
Especially if your code will be viewed by others. If not for the sole purpose of them having to determine if there will be a problem w/ those rungs, etc.
And yes, us structured text people get stuck w/ this a lot.
I fail sometimes, but I try to immediately add the set bit to a reset or startup routine that resets the bit before I forget.
 
I don't know if this is standard or recommended practice or not, but I have my M340 plc reset %m0 and not %mw on startup and try to use based off of what I want them to do retentively.
 
I take the "there are no bad instructions, just bad programmers" approach particularly in regard to latches.

There is not a right way, a wrong way, or even a recommended way to use latches. It is simply, what does the logic require to make it work properly.

You could expand this to include timers/counters and the (RES) reset. Should the RES come before or after what it is resetting? I typically put it before, but that doesn't make it right or wrong.

OG
 
Usually best to avoid latches, unless your purpose is to make retentive, or the situation dictates.


I've noticed many programmers complaining about latch instructions. I don't see a problem with using them. If you arbitrarily refuse to do so, then you're simply going to write more logic in order to turn a standard output into a latch bit.
 

Similar Topics

Hi everyone, I was wondering if experienced plc programmers could give some tips when to use latch/unlatch rather than ote. I have read in some...
Replies
21
Views
10,839
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,746
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
754
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,033
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,596
Back
Top Bottom