Timer Off Delay with Reset (TOFR)
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 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.
Function Block
Structured Text
TOFR(TOFR_tag)
Operands
Structured Text
Variable | Type | Format | Description |
---|---|---|---|
TOFR tag | FBD_TIMER | Structure | TOFR structure |
See Structured Text Syntax for more information on the syntax of expressions within structured text.
Function Block
Operand | Type | Format | Description |
---|---|---|---|
TOFR tag | FBD_TIMER | Structure | TOFR structure |
FBD_TIMER Structure
Input Parameters | 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 cleared, 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.
Default is cleared. When the Reset input parameter is set, the instruction clears EN, TT and DN and sets ACC = PRE. Note that this is different than using a RES instruction on a TOF instruction. |
Output Parameters | Data Type | Description |
---|---|---|
EnableOut | BOOL | The instruction produced a valid result. |
ACC | BOOL | Accumulated time in milliseconds. |
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
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.
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 main algorithm of the instruction will be executed and outputs will be updated. |
Instruction first run | N/A |
Instruction first scan | EN, TT and DN are cleared ACC value is not modified. |
Postscan | EnableIn and EnableOut bits 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
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.
Function Block
Structured Text
TOFR_01.PRE := 500;
TOFR_01.Reset := Reset;
TOFR_01.TimerEnable := Input;
TOFR(TOFR_01);
timer_state := TOFR_01.DN;
Provide Feedback