Retentive Timer On with Reset (RTOR)

The RTOR instruction is a retentive timer that accumulates time when TimerEnable is set.
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.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram.
Structured Text
RTOR(RTOR_tag)
Operands
Structured Text
Variable
Type
Format
Description
RTOR tag
TIMER
Structure
RTOR structure
See Structured Text syntax for more information on the syntax of expressions within structured text.
TIMER Structure
Mnemonic
Data Type
Description
.EN
BOOL
The enable bit contains rung-condition-in when the instruction was last executed.
.TT
BOOL
The timing bit when set indicates the timing operation is in process.
.DN
BOOL
The done bit when set indicates the timing operation is complete (or paused).
.PRE
DINT
The preset value specifies the value (1 millisecond units) which the accumulated value must reach before the instruction indicates it is done.
.ACC
DINT
The accumulated value specifies the number of milliseconds that have elapsed since the RTO instruction was enabled.
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.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Structured Text
Condition/State
Action Taken
Prescan
EnableIn and EnableOut bits are cleared to false.
Normal execution
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.
Postscan
EnableIn and EnableOut are cleared to false.
Example
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.
Normal