DOUBLE INTEGER into TIME
DINT_TO_TIME converts a value of the data type DINT into a value of the data type TIME. A value of 1 corresponds to a time of 10ms, e.g. an input value of 123 is converted to a TIME T#1s230.00ms.
Input
Input data type
Output
Conversion result
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
DINT_value: DINT:=0;
time_value: TIME:=T#0s;
END_VAR
This example uses variables. You can also use a constant for the input variable.
DINT_value of the data type DOUBLE INTEGER is converted to value of the data type TIME. The result is written into the output variable time_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_F,DINT_TO_TIME!,Instance,10,2,18,4,,?D?C);
B(B_VARIN,,DINT_value,8,2,10,4,);
B(B_VAROUT,,TIME_value,18,2,20,4,);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
time_value:=DINT_TO_TIME(DINT_value);