Learn › Instructions
OTL and OTU: Latch and Unlatch
OTL turns a bit on and leaves it on. OTU turns the same bit off. Together they give you set/reset logic: one rung decides when something starts, another decides when it stops.
What they do
Both are output instructions, so they sit in the last column of a rung, just like an OTE coil. The difference is what happens when the rung goes false.
| Instruction | Rung true | Rung false |
|---|---|---|
OTE Output Energize | Bit = 1 | Bit = 0 |
OTL Output Latch | Bit = 1 | Does nothing (bit keeps its value) |
OTU Output Unlatch | Bit = 0 | Does nothing (bit keeps its value) |
An OTE follows its rung every scan. OTL and OTU only act while their rung is true and are silent otherwise. That's what makes the bit "remember": once an OTL has turned it on, nothing changes it again until an OTU with the same tag sees a true rung.
A basic latch and unlatch
Here's a motor started by one push button and stopped by another, using a latch instead of a seal-in circuit:
| Start Motor |
|----] [------------------------------------(L)----|
| |
| Stop Motor |
|----] [------------------------------------(U)----|
Press Start for a single scan and Motor turns on. Let go and rung 0 goes false, but OTL does nothing on a false rung, so Motor stays on. Press Stop and rung 1 turns Motor off. Let go, and again nothing changes it.
Notice that Stop uses an XIC here, not an XIO. The OTU should act when the stop button is pressed, so the rung needs to be true while it's pressed. If you're used to seal-in circuits, where the stop button is usually an XIO, this is an easy one to get backwards. The XIC and XIO lesson explains why.
What if both rungs are true?
If someone holds Start and Stop at the same time, both rungs are true in the same scan. The PLC solves rungs top to bottom, so the OTL turns Motor on and then the OTU turns it off a moment later. The last rung to write the bit wins, and the outputs see Motor off at the end of the scan.
That means rung order is how you choose which command has priority. Put the OTU below the OTL and stop wins, which is what you almost always want for anything that moves. If you put the unlatch first, start would win, which is rarely safe. See how the scan cycle works for more on why order matters.
Latch or seal-in?
A seal-in circuit does the same job as a latch/unlatch pair using an ordinary OTE and a contact that holds the rung true. Both work, so which should you use?
- Seal-in keeps all the logic for one output on one rung, so it's easy to read. Because it's an OTE, the output turns off on its own if any condition in the rung breaks. On a real PLC, it also drops out after a power loss, which is usually the safe choice for motors.
- Latch/unlatch is better when the "set" and "reset" conditions are far apart or complicated: a fault that's latched when it happens and only cleared by a reset button, a step in a sequence, or a mode that's chosen in one place and cancelled in several. On a real PLC, a latched bit also keeps its value through a power cycle, which is exactly what you want for a fault memory and exactly what you don't want for a motor.
A practical example: latching a fault
Faults are the classic use for OTL. Say a photo eye at the end of a conveyor should never stay blocked for long. A TON timer watches for a jam, and an OTL remembers it even after the box is cleared, so the operator has to acknowledge it.
| PE_End |
|----] [------------------------------[TON JamT PRE 3.0s]--|
| |
| JamT.DN Jam |
|----] [------------------------------------(L)----|
| |
| Reset PE_End Jam |
|----] [---------]/[------------------------(U)----|
| |
| Run Jam Conveyor |
|----] [---------]/[------------------------( )----|
The reset rung includes XIO PE_End, so pressing Reset while the box is still stuck does nothing. That small detail stops the operator from clearing a fault that's still there.
Try it in the Playground
- Open the Playground and pick the conveyor scene. Add two push buttons and name their tags
StartandStop. - Build rung 0:
XIC StartthenOTL Motor. Build rung 1:XIC StopthenOTU Motor. - Set the conveyor's Forward bit to
Motor, press Run, and tap Start. The conveyor keeps running after you let go. - Hold both buttons together. Stop wins because its rung is lower. Now drag rung 1 above rung 0 and try again to see start win instead.
Common mistakes
- Mixing OTL/OTU and OTE on one tag. An OTE writes its bit every scan, so it will overwrite whatever the latch did. Use one style per tag.
- Forgetting the unlatch. Every OTL needs at least one OTU (or some other instruction) that can turn it off, or the bit stays on forever.
- Using an XIO for the stop button on the unlatch rung. That would unlatch the bit every scan the button is not pressed.
- Latching motors. On real equipment, a latched motor can restart by itself after a power cut. Prefer a seal-in for anything that moves.