Skip to main content

RTOR — Retentive Timer

Structured Text retentive timer function block. Uses FBD_TIMER; the ST equivalent of ladder RTO.

Operands

NameType
timerFBD_TIMER

FBD_TIMER Tag Members

MemberTypeMeaning
.EnableInBOOLForced to 1 each scan by the instruction call — setting it 0 has no effect
.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

RTOR is the Structured Text function-block equivalent of the ladder RTO instruction. It operates on an FBD_TIMER tag.

Like TONR, but .ACC retains its value when TimerEnable drops to 0. Timing resumes where it left off. Clear the accumulator by setting .Reset to 1.

Example

RunHours.TimerEnable := MachineRunning;
RunHours.Reset := ResetMaint;
RunHours.PRE := 28800000;
RTOR(RunHours);

MaintAlert := RunHours.DN;
Practice

Try RTOR in the Run Hours exercise — accumulate a motor's run time and retain it across enable drops.

Common Mistakes

  • Trying to pause with .EnableIn := 0. The instruction call forces .EnableIn back to 1 every scan, so the assignment has no effect. To pause and keep .ACC, drop .TimerEnable to 0; clear the accumulator with .Reset.
  • Assigning .ACC from logic to reset it (MyTimer.ACC := 0). Structured Text recomputes .ACC every scan, so a runtime write is ignored (the initial .ACC default is still honored). Clear it with .Reset := 1. The same write does take effect on the ladder RTO — so don't rely on it either way; it isn't portable.
  • RTO — the ladder-logic equivalent
  • TONR, TOFR — other ST timer function blocks