Timer for 1s intervals (0 to 32767s)
This timer for 1s units works as an ON-delay timer. If the start contact of the function block is in the ON state, the preset time SV (set value) is started. When this time has elapsed, the timer contact T turns ON.
Input
start contact
each time a rising edge is detected, the set value SV is copied to the elapsed value EV and the timer is started
set value
the defined ON-delay time (0 to 32767s)
Output
timer contact
is set when the time defined at SV has elapsed, this means when EV becomes 0
elapsed value
count value from which 1 is subtracted every 1s while the timer is running
The value can be changed during counting operation by writing to the variable from the programming editor.
The number of available timers is limited and depends on the settings in the system registers 5 and 6.
For the timer function blocks the compiler automatically assigns a NUM* address to every timer instance. The addresses are assigned counting downwards, starting at the highest possible address.
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
Alarm_control: TM_1s_FB;
Start_contact: BOOL:=FALSE;
Alarm_Relay_1: BOOL:=FALSE;
Alarm_Relay_2: BOOL:=FALSE;
END_VAR
This example uses variables. You may also use constants for the input variables.
As soon the variable Start_contact becomes TRUE, the timer Alarm_control will be started. The variable EV of the timer is set to the value of SV. As long as Start_contact is TRUE, the value 1 is subtracted from EV every 1s. When EV reaches the value 0 (after 10 seconds as SV = 10 with the timer type TM_1s_FB), the variable Alarm_Relay_2 becomes TRUE.
As soon as the value of the variable EV of the timer is smaller than or equal to 5 (after 5s) and EV is unequal 0, Alarm_Relay_1 is set to TRUE.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 8 ;
NETWORK_BODY
B(B_VARIN,,Start_contact,8,3,10,5,);
B(B_VARIN,,10,8,4,10,6,);
B(B_VAROUT,,Alarm_Relay_2,18,3,20,5,);
B(B_FB,TM_1s_FB,Alarm_control,10,2,18,6,,?Bstart?BSV?AT?AEV);
L(1,0,1,8);
END_NETWORK_BODY
END_NET_WORK
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 8 ;
NETWORK_BODY
B(B_F,@LE-2!,Instance,11,0,16,3,,?D?D?C);
B(B_VARIN,,Alarm_control.EV,9,0,11,2,);
B(B_VARIN,,5,9,1,11,3,);
B(B_F,@NE!,Instance,11,5,16,8,,?D?D?C);
B(B_VARIN,,0,9,6,11,8,);
B(B_VARIN,,Alarm_control.EV,9,5,11,7,);
B(B_F,@AND-2!,Instance,20,2,25,5,,?D?D?C);
B(B_VAROUT,,Alarm_Relay_1,25,2,27,4,);
L(16,1,17,1);
L(17,1,17,3);
L(17,3,20,3);
L(17,4,20,4);
L(17,4,17,6);
L(16,6,17,6);
L(1,0,1,8);
END_NETWORK_BODY
END_NET_WORK
END_BODY
Alarm_Control( start:= Start_Contact ,
SV:= 10,
T=> Alarm_Relay_2 ,
EV=> Alarm_Control.EV );
(*The ON-delay time is 10s*)
Alarm_Relay_1:= Alarm_Control.EV <= 5 & Alarm_Control.EV <> 0;
(*Alarm_Relay_1 is set to TRUE after 5s*)
If you want to call the function block in an instruction list, enter the following:
CAL |
Alarm_control (start:=Start_contact, SV:= 10 , T:= Alarm_Relay_2) |
LD |
Alarm_control.EV |
LE |
5 |
AND( |
Alarm_control.EV |
NE |
0 |
) |
|
ST |
Alarm_Relay_1 |