Timers Overview

Reference for Ladder Logic timer instructions in rungs.dev — TON, TOF, RTO, and RES — and the TIMER tag structure with preset, accumulator, and status bits.

Timers measure elapsed time. A timer instruction references a TIMER tag, which is a structure with a preset, an accumulator, and three status bits.

Available Timer Instructions

InstructionSymbolPurpose
TON

TON

Timer

timer

(EN)

Preset

?

(DN)

Accum

?

On-delay timer. Starts timing when the rung goes true; sets .DN when .ACC reaches .PRE. Resets the moment the rung goes false.
TOF

TOF

Timer

timer

(EN)

Preset

?

(DN)

Accum

?

Off-delay timer. Starts timing when the rung goes false; holds .DN at 1 for the preset duration after the rung drops.
RTO

RTO

Timer

timer

(EN)

Preset

?

(DN)

Accum

?

Retentive on-delay timer. Like TON, but the accumulator survives rung transitions. Must be cleared explicitly with RES.

TIMER Tag Members

Every TIMER tag exposes the same fields. Access them with a dot (MyTimer.DN).

MemberTypeMeaning
.PREDINTPreset — target time in milliseconds
.ACCDINTAccumulated time in milliseconds
.ENBOOLEnable — 1 while the rung is true
.TTBOOLTiming — 1 while accumulating toward .PRE
.DNBOOLDone — each timer (TON, TOF, RTO) decides when this turns on

Reference these members as contacts:

0

MyTimer.DN

Light

How Timers Use Scan Time

A timer measures how much simulation time passes between the times its instruction runs. The first scan that starts the timer adds no time: TON and TOF start at .ACC = 0, while RTO resumes at its retained value.

During Start, Studio uses the configured scan period, which is 100 ms by default. Small browser delays do not change those simulated scan times. If several scans are missed, the next scan catches the timer up to the latest scheduled scan time. Switching browser tabs pauses the simulation instead of creating a large jump.

Completion is checked only when the timer executes. With Studio's 100 ms scans, .PRE = 2000 can finish exactly at 2000 ms. .PRE = 2050 finishes at the next check, 2100 ms, and keeps that value — .ACC is not forced back to .PRE.

Setting the Preset

The preset is stored on the timer tag, not inside the instruction. There are two ways to set it:

  • From the rung: click the Preset row on the TON, TOF, or RTO block and type the value. This edits the .PRE default of the underlying TIMER tag in place — no need to leave the ladder editor.
  • From the Tag editor: expand the timer tag's row and edit the Default Value of .PRE.

Either way, the value is the target time in milliseconds: 5000 = 5 seconds. The Accum row on the block is editable the same way and sets the .ACC default. During prescan — the preparation pass before the first scan — TON sets .ACC to 0, TOF sets it to .PRE, and RTO retains its current value.

Writing .ACC from a running rung takes effect on a ladder timer, but do not use MOVE(0, MyTimer.ACC) to restart a finished timer. Its .DN bit stays in the finished state, so a done TON or RTO can sit at .ACC = 0, .DN = 1 while its rung remains true. Use RES instead: it clears .ACC, .EN, .TT, and .DN together and re-arms the timer. Structured Text timers (TONR / TOFR / RTOR) overwrite their output members each time they run, so writing .ACC does not restart them either.

Units

All timer values are in milliseconds. There is no separate time base — always multiply seconds by 1000.

On this page