Timer with switch-on delay
The function block TON allows you to program a switch-on delay.
Input
timer ON
an internal timer is started for each rising edge detected at IN
switch-on delay (PT = preset time)
16-bit value: 0–327.27s
32-bit value: 0–21,474,836.47s (32-bit value not available for FP3, FPC, FP5, FP10/10S)
resolution 10ms each
Output
signal output
set to TRUE if PT = ET
elapsed time
indicates the current value of the elapsed time
The value can be changed during counting operation by writing to the variable from the programming editor.
Q is set delayed with the time defined in PT. Resetting is without any delay.
If the input IN is only set for the period of the delay time PT or even for a shorter period of time (t3 - t2 < PT), Q will not be set.
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
copy_name: TON;
start: BOOL:=FALSE;
set_value: TIME:=T#0s;
signal_output: BOOL:=FALSE;
current_value: TIME:=T#0s;
END_VAR
If start is set (status = TRUE), the input signal is transferred to signal_output with a delay by the time period set_value.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_CONTACT,,start,3,2,5,4,);
B(B_VARIN,,set_value,7,3,9,5,);
B(B_VAROUT,,current_value,14,3,16,5,);
B(B_COIL,,signal_output,21,2,23,4,);
B(B_FB,TON!,copy_name,9,1,14,5,,?BIN?BPT?AQ?AET);
L(1,3,3,3);
L(1,0,1,6);
L(5,3,9,3);
L(14,3,21,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
copy_name( IN:= start ,
PT:= set_value ,
Q=> signal_output ,
ET=> current_value );
If you want to call the function block in an instruction list, enter the following:
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
TOF1: TOF;
tPT: TIME:=T#10s;
tET: TIME:=T#0s;
bIN: BOOL:=FALSE;
bQ: BOOL:=FALSE;
bEmergencyStop: BOOL:=FALSE;
END_VAR
After a falling edge at bIN, the timer starts counting and Q is set to TRUE. When bEmergencyStop is set to TRUE before the timer value has been elapsed, counting stops and the output Q is immediatiely reset. The timer is initialized with the preset time PT of 10s in this example.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 4 ;
NETWORK_BODY
B(B_F,E_MOVE!,,16,0,22,4,,?DEN?D?AENO?C);
B(B_VARIN,,tPT,14,2,16,4,);
B(B_VAROUT,,TOF1.ET,22,2,24,4,);
B(B_CONTACT,,bIN,11,1,13,3,N);
B(B_CONTACT,,bEmergencyStop,6,1,8,3,);
L(1,2,6,2);
L(13,2,16,2);
L(8,2,11,2);
L(1,0,1,4);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_FB,TOF!,TOF1,16,1,21,5,,?BIN?BPT?AQ?AET);
B(B_VARIN,,tPT,14,3,16,5,);
B(B_VAROUT,,tET,21,3,23,5,);
B(B_CONTACT,,bIN,6,2,8,4,);
B(B_COIL,,bQ,34,2,36,4,);
B(B_CONTACT,,bEmergencyStop,27,2,29,4,N);
L(21,3,27,3);
L(29,3,34,3);
L(8,3,16,3);
L(1,3,6,3);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if (bEmergencyStop AND NOT bIN) then
TOF1.ET:=tPT;
end_if;
TOF1(IN := bIN, PT := tPT, ET => tET);
bQ := NOT bEmergencyStop AND TOF1.Q;