Retentive Timer On with Reset (RTOR)

This information applies to the
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370,
GuardLogix
5570,
Compact GuardLogix
5380,
CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580, and
GuardLogix
5580 controllers.
The RTOR instruction is a retentive timer that accumulates time when TimerEnable is set.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram.
Function Block
Structured Text
RTOR(RTOR_tag)
Operands
Structured Text
Variable
Type
Format
Description
RTOR tag
FBD_TIMER
Structure
RTOR structure
See for more information on the syntax of expressions within structured text.
Function Block
Operand
Type
Format
Description
RTOR tag
FBD_TIMER
Structure
RTOR structure
FBD_TIMER Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
If cleared, the instruction does not execute and outputs are not updated. If set, the instruction executes.
Default is set.
TimerEnable
BOOL
If set, this enables the timer to run and accumulate time.
Default is cleared.
PRE
DINT
Timer preset value. This is the value in 1 msec units that ACC must reach before timing is finished. If invalid, the instruction sets the appropriate bit in Status and the timer does not execute.
Valid = 0 to maximum positive integer
Reset
BOOL
Request to reset the timer. When set, the timer resets.
When the Reset input parameter is set, the instruction clears EN, TT and DN and sets ACC = 0.
Output Parameter
Data Type
Description
EnableOut
BOOL
The instruction produced a valid result.
ACC
DINT
Accumulated time in milliseconds. This value is retained even while the TimerEnable input is cleared.
EN
BOOL
Timer enabled output. Indicates the timer instruction is enabled.
TT
BOOL
Timer timing output. When set, a timing operation is in progress.
DN
BOOL
Timing done output. Indicates when accumulated time is greater than or equal to preset.
Status
DINT
Status of the function block.
InstructFault (Status.0)
BOOL
The instruction detected one of the following execution errors. This is not a minor or major controller error. Check the remaining status bits to determine what occurred.
PresetInv (Status.1)
BOOL
The preset value is invalid.
Description
The RTOR instruction accumulates time until it is false. When the RTOR instruction is false, it retains its ACC value. You must clear the .ACC value using the Reset input.
The time base is always 1 msec. For example, for a 2-second timer, enter 2000 for the PRE value.
Set the Reset input parameter to reset the instruction. If TimerEnable is set when Reset is set, the RTOR instruction begins timing again when Reset is cleared.
How a Timer Runs
A timer runs by subtracting the time of its last scan from the current time:
  • ACC = ACC + (current_time - last_time_scanned)
  • After it updates the ACC, the timer sets last_time_scanned= current_time. This gets the timer ready for the next scan.
    IMPORTANT:
    Be sure to scan the timer at least every 69 minutes while it runs. Otherwise, the ACC value won’t be correct.
The last_time_scanned value has a range of up to 69 minutes. The timer’s calculation rolls over if you don’t scan the timer within 69 minutes. The ACC value won’t be correct if this happens.
While a timer runs, scan it within 69 minutes if you put it in a:
  • Subroutine
  • Section of code that is between JMP and LBL instructions
  • Sequential function chart (SFC)
  • Event or periodic task
  • State routine of a phase
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See for operand-related faults.
Execution
Function Block
Condition/State
Action Taken
Prescan
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is false
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is true
EnableIn and EnableOut bits are set to true.
The instruction executes.
When the Reset input parameter is set, the instruction clears EN, TT and DN and sets ACC = 0.
Instruction first run
EN, TT and DN are cleared to false.
The instruction executes.
Instruction first scan
N/A
Postscan
EnableIn and EnableOut are cleared to false.
Structured Text
Condition/State
Action Taken
Prescan
See Prescan in the Function Block table.
Normal execution
See Tag.EnableIn is true in the Function Block table.
Postscan
See Postscan in the Function Block table.
Example
Function Block
Structured Text
RTOR_01.PRE := 500;
RTOR_01.Reset := Reset;
RTOR_01.TimerEnable := Input;
RTOR(RTOR_01);
timer_state := RTOR_01.DN;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.