TIME into DOUBLE WORD
TIME_TO_DWORD converts a value of the data type TIME into a value of the data type DWORD. The time 10ms corresponds to the value 1, e.g. an input value of T#1s is converted to the value 100 (16#64).
Input
Input data type
Output
Conversion result
If the required data type is supported, we recommend using the overloaded instruction TO_DWORD
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
time_value: TIME:=T#0s;
DWORD_value: DWORD:=0;
END_VAR
This example uses variables. You can also use a constant for the input variable.
time_value of the data type TIME is converted to value of the data type DWORD and written into the output variable DWORD_value.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,TIME_value,8,1,10,3,);
B(B_VAROUT,,DWORD_value,20,1,22,3,);
B(B_F,TIME_TO_DWORD!,Instance,10,1,20,3,,?D?C);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
DWORD_value:=TIME_TO_DWORD(time_value);