Skip to main content

TONR — On-Delay Timer

Structured Text on-delay timer function block. Uses FBD_TIMER; the ST equivalent of ladder TON.

Operands

NameType
timerFBD_TIMER

FBD_TIMER Tag Members

MemberTypeMeaning
.EnableInBOOL1 lets the instruction run; 0 holds all outputs unchanged. Normally 1.
.TimerEnableBOOL1 runs the timer and advances ACC; 0 stops timing
.PREDINTPreset target time in milliseconds
.ResetBOOL1 clears EN, TT, DN and sets ACC to 0
.EnableOutBOOL1 while the instruction is executing normally
.ACCDINTAccumulated time in milliseconds
.ENBOOL1 while TimerEnable is 1 and Reset is 0
.TTBOOL1 while the timer is actively counting toward PRE
.DNBOOLDone status — each timer (TONR, TOFR, RTOR) decides when this turns on
.StatusDINTPacked status word — combines InstructFault and PresetInv bits
.InstructFaultBOOL1 when the instruction hit an execution error
.PresetInvBOOL1 when PRE is outside its valid range

How It Works

TONR is the Structured Text function-block equivalent of the ladder TON instruction. It operates on an FBD_TIMER tag and exposes the same on-delay behaviour via named members.

When called with a true TimerEnable, the timer accumulates toward .PRE. .DN becomes 1 when .ACC reaches .PRE.

Example

MyTimer.TimerEnable := Start_Button;
MyTimer.PRE := 5000;
TONR(MyTimer);

IF MyTimer.DN THEN
Alarm := 1;
END_IF;

Common Mistakes

  • Setting .EnableIn := 0 to pause the timer. EnableIn = 0 freezes all outputs — .ACC, .EN, .TT, .DN — without advancing them. To stop timing, drop .TimerEnable to 0 instead and leave .EnableIn at 1.
  • TON — the ladder-logic equivalent
  • TOFR, RTOR — other ST timer function blocks