# NOP / AFI — No Operation and Always False

Source: https://rungs.dev/docs/ladder-logic/instructions/nop-afi

> NOP and AFI in rungs.dev — NOP is a placeholder that does nothing, AFI forces the rest of its rung false. Both are used while building and debugging programs, not in finished logic.

Most instructions read or write tags. These two exist for a different reason: they help you
**build and debug** a program. Neither takes any operands — you place them on a rung from
the **Program** tab of the ladder toolbar, and there is nothing to fill in.

## NOP — No Operation [#nop--no-operation]

Does nothing. Power flows through it unchanged.

Two everyday uses:

- **Placeholder** — when you know a rung will be needed but haven't written its logic yet,
  a rung containing just a `NOP` keeps the routine valid so everything else can compile
  and run.
- **Documentation rung** — a `NOP` rung exists only to carry a rung comment. Programmers
  use these as headers between sections of a routine: the comment explains what the next
  rungs do, and the `NOP` gives the comment a rung to live on without affecting the
  machine.

```ladder
NOP()
```

## AFI — Always False [#afi--always-false]

Forces the rest of the rung false, every scan, no matter what comes before it.

Use it to temporarily disable a rung without deleting anything: place an `AFI` at the start
of the rung, and every instruction after it sees no power. Remove it and the rung works
exactly as before. This is a standard trick when testing a machine — modeled on the Always
False instruction in Logix 5000® controllers.

```ladder
XIC(StartButton)AFI()OTE(Motor)
```

Here `Motor` stays off even while `StartButton` is pressed, because the `AFI` blocks the
power before it reaches the coil.

Placed inside a branch, an `AFI` only kills its own path — parallel paths still work:

```ladder
[AFI(),XIC(Override)]OTE(Motor)
```

`Motor` still follows `Override`, because only the first path is forced false.

`AFI` is an input instruction — it conditions a rung, it doesn't complete one. A rung
containing only an `AFI` is an error, because every rung still needs an output instruction.
If you want a rung that exists only to hold a comment, that's `NOP`'s job.

## How They Differ [#how-they-differ]

|       | Power in → power out | Typical use                                                  |
| ----- | -------------------- | ------------------------------------------------------------ |
| `NOP` | unchanged            | stub out a rung, or carry a rung comment as a section header |
| `AFI` | always `0`           | temporarily disable a rung while testing                     |

## Common Mistakes [#common-mistakes]

- Leaving an `AFI` in finished logic — the rung silently never runs. Search your routine
  for `AFI` before you call a program done.
- Putting an `AFI` alone on a rung — it is an input instruction, so the rung still needs an
  output and reports an error. A comment-only rung is what `NOP` is for.
- Keeping dead logic disabled with an `AFI` forever. If the logic is dead, delete it.