RES — Reset

RES in rungs.dev clears the accumulator and status bits of a TIMER, COUNTER or CONTROL tag back to zero — typically paired with RTO, CTU, CTD, or an array instruction on the same tag.

structure

RES

Clears the accumulator and status bits of a TIMER, COUNTER or CONTROL tag back to zero. The preset — .PRE or .LEN — is kept.

Operands

NameType
structureTIMER | COUNTER | CONTROL

How It Works

Each structure has one field that counts up and one that says how far — and RES clears the first while keeping the second.

  • Rung goes true → the counting field is cleared to 0 — .ACC on a TIMER or COUNTER, .POS on a CONTROL — and every status bit on the structure (.EN, .TT, .DN, .CU, .CD, .OV, .UN, .EU, .EM, .ER, .UL, .IN, .FD as applicable) is cleared to 0.
  • The target is not touched: .PRE on a timer or counter, .LEN on a control.
  • Rung goes false → RES does nothing.

RES is checked on every scan the rung is true, not just the rising edge. Holding the rung true holds the structure at zero.

RES does not re-derive .EM

A CONTROL reset to .POS = 0 describes an empty buffer, but RES leaves .EM at 0. The next load or unload instruction works it out from .POS and sets it then.

Example — Clear a Counter

0

Button

CTU

Counter

PartsCount

(CU)

Preset

10

(DN)

Accum

0

1

ResetCount

PartsCount

RES

Each rising edge on Button increments PartsCount.ACC. Pressing ResetCount clears the accumulator and PartsCount.DN.

When to Use

  • Clearing a retentive timer (RTO) — it is the only way to drop .ACC back to zero.
  • Resetting a counter (CTU, CTD) — counters are retentive across rung transitions.

When Not to Use

  • A non-retentive timer (TON, TOF) already resets when its rung drops. Calling RES on it is redundant.

Common Mistakes

  • Leaving the RES rung always-true — that holds the structure at zero forever and the timer or counter never runs.
  • Restarting a timer on its own .DN to make it repeat (XIC(MyTimer.DN)RES(MyTimer)). The scan after RES only restarts the timer, so every cycle runs one scan longer than .PRE — two with XIO(MyTimer.DN) in front of the timer instead. That is fine for a flashing light, but a total counted from those cycles falls further behind every cycle. To keep time, let one timer run and work from its .ACC.

On this page