Timer Off Delay with Reset (TOFR)

The TOFR instruction is a non-retentive timer that accumulates time when TimerEnable is cleared.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram.
Structured Text
TOFR(TOFR_tag)
Operands
Structured Text
Variable
Type
Format
Description
TOFR tag
TIMER
Structure
TOFR 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 cleared 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 TOF instruction was enabled.
Description
When true, the TOFR instruction accumulates time until the:
  • TOFR instruction is disabled
    • ACC is greater than or equal to PRE
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 false when Reset is true, the TOFR instruction does not begin timing again when Reset is false.
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
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
Each scan after limit_switch1 is cleared, the TOFR instruction increments the ACC value by elapsed time until the ACC value reaches the PRE value. When ACC ≥ PRE, the DN parameter is cleared, and timer_state2 is set.
Structured Text
TOFR_01.PRE := 500;
TOFR_01.Reset := Reset;
TOFR_01.TimerEnable := Input;
TOFR(TOFR_01);
timer_state := TOFR_01.DN;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal