TON (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


The TON function block is an ON delay timer that enables the "q" output a specific number of milliseconds after the trig input is enabled.

 

When the trig input is set TRUE, the elapsed time counter (et) is reset to zero and then incremented until the preset timer value (pt) is reached, after which the "q" output is set TRUE.

When the trig input is switched to FALSE, the "q" output is set FALSE.

If the trig input is set to FALSE before the et counter reaches the pt value, the timer keeps running but the "q" output is not set TRUE when the et counter reaches the pt value.

 

This image shows the TON function block timing:

 

clip0023

 

 

 

Input:

trig : BOOL (true/false)

On the leading edge of this input, the output "q" will go high and the timer will start. When this input goes low, the "q" output will also go low.  

 

pt : DINT (0..2147483648)

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

         

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 TON;
VAR_INPUT
  trig : BOOL; | Signal that starts timer, and sets 'q' high
  pt   : DINT; | Delay before 'q' goes high 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 : TON; // Declare an instance of the TON functionblock
END_VAR;
 
PROGRAM test;
 
BEGIN
  timer();
  ...
  timer.pt := 100; // number of milliseconds the q output will be delayed from 'trig'
  timer.trig := input1; // The timer will start when input1 goes high
  signal := timer.q; // output will follow the q output from the timer
  ...
END;
END_PROGRAM;