LadderLogicOnline

Learn › Instructions

RES: Reset timers and counters

RES puts a timer or counter back to the start. While its rung is true, it clears the accumulator to zero and turns the done bit off. It's how you start a new batch, clear a retentive timer, or restart a sequence.

What RES does

RES is an output instruction, so it goes in the last column of a rung. Its tag is a TIMER or COUNTER, the same tag used by the timer or counter you want to clear. On every scan where its rung is true, it:

Tag typeWhat RES clears
TIMERACC = 0, DN off, EN off, TT off
COUNTERACC = 0, DN off, CU off, CD off

The preset (PRE) is never changed. When the RES rung is false, RES does nothing at all.

Which instructions need a RES?

Ways to wire a reset

A reset button. The simplest form: an operator presses a button to clear a count.

 |   ResetPB                                         |
 |----] [------------------------------------(RES Parts)--|
Parts is held at zero for as long as ResetPB is pressed.

Auto-reset at the preset. A counter that resets itself when it reaches its preset makes a "every Nth item" signal:

 |   PE                                              |
 |----] [------------------------------[CTU  Every3  PRE 3]--|
 |                                                  |
 |   Every3.DN                              Divert   |
 |----] [------------------------------------( )----|
 |                                                  |
 |   Every3.DN      PE                               |
 |----] [---------]/[------------------------(RES Every3)--|
On the third box, DN turns on and Divert fires. Once that box has cleared the eye, the RES starts the next count.

Why the XIO PE on the reset rung? A simpler version that resets as soon as DN is on looks right, but it has a catch. RES also clears the counter's CU bit, so on the next scan the CTU thinks the rung has just gone true and counts the third box again, while it's still in front of the eye. Waiting until the eye is clear avoids that, and as a bonus Divert stays on for as long as the third box is at the eye instead of for a single scan.

The Divert rung also sits above the reset, so it always reads DN before the count is cleared. The scan cycle lesson explains why rung order decides this.

Reset on a mode change. Clear timers and counters when a machine is stopped, so every start begins from a known state:

 |   Running                                         |
 |----]/[------------+-----------------------(RES Boxes)--|
 |                   |                              |
 |                   +-----------------------(RES StepT)--|
A branch lets one condition reset several tags at once.

A held reset beats everything else

Because RES acts on every scan its rung is true, holding a reset keeps the timer or counter at zero no matter what its own rung is doing. Suppose a box passes the eye while the reset button is held:

RES also clears CU (or CD), so the counter forgets the rung was already true. That has a side effect worth knowing: if the box is still blocking the eye when the RES rung goes false, the CTU sees a "new" false-to-true change and counts it. It's usually harmless, but it's the reason some programs only allow a reset when the counting sensor is clear.

Try it in the Playground

  1. Open the Playground and add push buttons Count and Clear.
  2. Build rung 0: XIC Count then CTU C1. Build rung 1: XIC Clear then RES C1.
  3. Press Run, tap Count a few times, then tap Clear and watch ACC drop to zero in the Tags panel.
  4. Hold Clear and tap Count. Nothing counts. Then swap the rung order and repeat to see the difference described above.

Key points