TOF (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


The TOF function block is an OFF delay timer that disables the "q" output a specified number of milliseconds after the trig input is disabled.

 

When the trig input is set TRUE, the elapsed time counter (et) is reset to zero and the "q" output is set TRUE.

When the trig input is switched to FALSE, the "et" counter is incremented until it reaches the preset timer value (pt), after which the "q" output is set FALSE.

If the trig input is set TRUE before the et counter reaches the pt value, the timer is stopped, and the et counter is reset to zero.

 

This image shows the TON function block timing:

 

clip0024

 

 

 

Input:

trig : BOOL (true/false)

On the leading edge of this input, the output "q" will go high. On the falling edge, the timer will start. When the timer reaches "pt", the "q" output will go low.

 

pt : DINT (0..2147483648)

Specifies the delay in ms. from "trig" going low to "q" going low.

         

Output:

et : DINT (0..2147483648)

The current value of the timer.

 

q : BOOL (true/false)

Output from the timer. See description for "trig".

 

Declaration:

FUNCTION_BLOCK TOF;
VAR_INPUT
  trig : BOOL; | Signal that sets 'q' high, starts timer on low signal
  pt   : DINT; | Delay before 'q' goes low after 'trig' signal
END_VAR;
VAR_OUTPUT
  q   : BOOL; | Output from timer
  et   : DINT; | Current timer value          
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR_INPUT
  input1 : BOOL; | Input that will enable the timer
END_VAR;
 
VAR_OUTPUT
  signal : BOOL; | Output that will follow the q output from the timer.
END_VAR;
 
VAR
  timer : TOF; // Declare an instance of the TOF functionblock
END_VAR;
 
PROGRAM test;
 
timer.pt := 100; // number of milliseconds the q output will be delayed from 'trig'
BEGIN
  ...
  timer(trig := input1); // The timer will start when input1 goes low
  signal := timer.q; // output will follow the q output from the timer
  ...
END;
END_PROGRAM;