When to use a Sealed Coil vs. a Latch/Unlatch?

I just realized something I didn’t learn until at least a year into programming PLCs, and thought it would be a great thing to share for newer ladder logic programmers: when should you use a sealed-in coil vs. a latch/unlatch?

On the surface of it, a latch/unlatch instruction is sometimes frowned upon by experienced programmers because it’s correlated with bad programming form: that is, modifying program state in more than one location in the program. If you have one memory bit that you’re latching and unlatching all over the place, it really hinders readability, and I pity the fool that has to troubleshoot that code. Of course, most PLCs let you use the same memory bit in a coil instruction as much as you want, and that’s equally bad form, so I don’t take too strict of a stance on this. If you are going to use latch/unlatch instructions, make sure you only use one of each (for a given memory bit), and keep them very close together (preferably on adjacent rungs, or even in different branches of the same rung). Don’t make the user scroll, or worse yet, do a cross reference.

As you can imagine, if you’re going to use a Latch/Unlatch instruction and keep them very close together, it’s trivial to convert that to a rung with a sealed in coil, so what, if anything is the difference? Why have two sets of instructions that do the same thing?

It turns out (depending on the PLC hardware you’re using) that they act differently. On Allen-Bradley hardware, at least, an OTE instruction (coil) will always be reset (cleared to off) during the pre-scan. The pre-scan happens any time you restart the program, which is most importantly after a loss of power. If you’re using a sealed in coil to remember you have a pallet present in a zone, you’ll be in for a big surprise when you cycle power. All your zones will be unblocked, and you could end up with a bunch of crashes! On the other hand, OTL and OTU instructions don’t do anything during a pre-scan, so the state remains the same as it was before the power was removed.

For that reason, a latch/unlatch is a great indication of long term program state. If you have to track physical state about the real world, use a latch/unlatch instruction.

On the other hand, a sealed-in coil is a great way to implement a motion command (e.g. “attempting to advance axis A”). In that case you want your motion command to reset if the power drops out.

I hope that clears it up a bit. I always tried to avoid all latch/unlatch instructions until I understood these concepts.


3 thoughts on “When to use a Sealed Coil vs. a Latch/Unlatch?

  1. Dave H

    My rule of thumb is to only use a latch command when you want a bit to remain on in the event of a power loss/power cycle.

  2. Ron Houston

    I have a question. I am following another programmer and found him using (U) all over the place for and OTE nonlatching instruction.

    when I do a (verify controller) it shows a ton of warnings.

    why use a (U) on an OTE?

  3. Scott Whitlock Post author

    @Ron Houston – Using an OTE instruction and an OTU instruction on the same tag or address is certainly a big red flag. The OTE instruction will overwrite the coil value based on the rung in condition, and also has the effect of writing a 0 to the coil value during the pre-scan, which is when the CPU is booting. Any experienced ladder programmer, when looking at an OTE instruction, will assume that coil isn’t being written to anywhere else, so it’s essentially a trap for the next programmer to come along. That’s why it’s warning you about this when you do a Verify Controller.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.