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
Clears the accumulator and status bits of a TIMER, COUNTER or CONTROL tag back to zero. The preset — .PRE or .LEN — is kept.
Operands
| Name | Type |
|---|---|
structure | TIMER | 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—.ACCon aTIMERorCOUNTER,.POSon aCONTROL— and every status bit on the structure (.EN,.TT,.DN,.CU,.CD,.OV,.UN,.EU,.EM,.ER,.UL,.IN,.FDas applicable) is cleared to0. - The target is not touched:
.PREon a timer or counter,.LENon a control. - Rung goes false →
RESdoes 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
Preset
10
Accum
0
1
ResetCount
PartsCount
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.ACCback 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. CallingRESon it is redundant.
Common Mistakes
- Leaving the
RESrung always-true — that holds the structure at zero forever and the timer or counter never runs.
Related
- Timers overview
- Counters overview
- RTO — retentive timer that requires
RES - CTU, CTD — retentive counters
- BSL and BSR — array instructions that keep their state in a
CONTROL
CTD — Count Down
CTD (Count Down) in rungs.dev decrements .ACC by 1 on each rising edge of the rung. Typically paired with CTU on the same COUNTER tag for bidirectional counting.
Math — ADD / SUB / MUL / DIV / MOD
Reference for Ladder Logic math instructions in rungs.dev — ADD, SUB, MUL, DIV, MOD — performing arithmetic on two sources and writing the result to a destination tag.