# OTL / OTU — Latch and Unlatch

Source: https://rungs.dev/docs/ladder-logic/instructions/otl-otu

> OTL latches a bit to 1 and holds it on after the rung goes false. Pair it with OTU to unlatch the bit back to 0 in the rungs.dev ladder simulator.

Latches a bit to `1` and leaves it on, even after the rung goes false. Pair with `OTU` to clear.

Unlatches a bit back to `0` while the rung is true. Pair with `OTL`.

## Operands [#operands]

| Name      | Type   |
| --------- | ------ |
| `dataBit` | `BOOL` |

## How They Work [#how-they-work]

While the rung is true, `OTL` writes `1` to `dataBit` and `OTU` writes `0`. While the rung is false, neither writes — `dataBit` keeps whatever value it last had. This is the key difference from [`OTE`](https://rungs.dev/docs/ladder-logic/instructions/ote): `OTE` always writes the rung state, while `OTL` and `OTU` only write on rung-true.

## Example — Fault Latch [#example--fault-latch]

```ladder
XIC(Reset)OTU(Fault);XIC(Overload)OTL(Fault)
```

- When `Overload` goes true, `Fault` latches on and stays on.
- `Reset` clears `Fault` once `Overload` has dropped.
- Rung order matters: the `OTL` rung runs **after** the `OTU` rung, so a held `Reset` cannot mask a live `Overload` — the latch has the last word each scan.

> **IDEA**
>
> **Practice**
>
> Try latch and unlatch in the [Press-Toggle Lamp exercise](https://rungs.dev/exercises/press-toggle-lamp) — toggle a lamp on and off with a single button.

## When to Use [#when-to-use]

- Fault registers that must persist until explicitly cleared.
- Machine-state flags that survive across a momentary input.
- Alarm annunciators.

## When Not to Use [#when-not-to-use]

- For a regular momentary-start output, prefer the [seal-in](https://rungs.dev/docs/ladder-logic/instructions/ote#seal-in-pattern) pattern with `OTE`. It is easier to reason about and fails safe — losing power de-energizes the output.
- Avoid mixing `OTL`/`OTU` and `OTE` on the same bit. The write order during the scan makes behaviour hard to predict.

## Common Mistakes [#common-mistakes]

- Forgetting to write the matching `OTU` — the bit will latch forever with no way to clear it.

## Related [#related]

- [OTE](https://rungs.dev/docs/ladder-logic/instructions/ote) — momentary output coil
- [Bit instructions overview](https://rungs.dev/docs/ladder-logic/instructions/bit-instructions)