REAL into TIME
REAL_TO_TIME converts a value of the data type REAL into a value of the data type TIME. 10ms of the data type TIME correspond to 1.0 REAL unit, e.g. when REAL = 1.0, TIME = 10ms; when REAL = 100.0, TIME = 1s. The value of the data type real is rounded off to the nearest whole number for the conversion.
Input
Output
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
result_time: TIME:=T#0s;
END_VAR
By clicking on the monitor icon while in the online mode, you can see the result 0.00ms immediately. Since the value at the REAL input contact is less than 0.5, it is rounded down to 0.0.
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,REAL_TO_TIME!,Instance,8,2,17,4,,?D?C);
B(B_VARIN,,0.499,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_time:= REAL_TO_TIME(0.499);