TIME into REAL
TIME_TO_REAL converts a value of the data type TIME into a value of the data type REAL. 10ms of the data type TIME correspond to 1.0 REAL unit, e.g. when TIME = 10ms, REAL = 1.0; when TIME = 1s, REAL = 100.0. The resolution amounts to 10ms.
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
input_time: TIME:=T#1h1m1s;
result_time: REAL:=0.0;
END_VAR
This example uses variables. You can also use a constant for the input variable.
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,TIME_TO_REAL!,Instance,8,2,17,4,,?D?C);
B(B_VARIN,,input_time,6,2,8,4,);
B(B_VAROUT,,result_time,17,2,19,4,);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
result_real:=TIME_TO_REAL(input_time);