# Interlocks

# Interlocks

A safety limit that *acts*. When it trips, Phloem drives the outputs you name to
safe values. They stay there (**latches**) until you **Reset**.

```python
interlock(
    name="over_limit",
    when=lambda: ch["/dut/signal"] > 20,
    then=[set(ch["/out/enable"], False)],  # de-energise the output
)
```

| | |
|---|---|
| **`when`** | the condition that trips it |
| **`then`** | safe actions, run the instant it trips |

It runs on the machine itself, so a trip acts within milliseconds. It never waits
on the network or the UI. An [alert](https://phloem.ai/docs/trellis/alerts/) notifies; an interlock acts.
A [stop condition](https://phloem.ai/docs/trellis/checks/) stops the whole test.

> **Note:** Interlock actions use only *this* machine's channels, so your hardware
> still trips safe if a peer link drops. To command another device, use a
> [procedure](https://phloem.ai/docs/trellis/sequences/).
