LREAL into TIME
LREAL_TO_TIME converts a value of the data type LREAL into a value of the data type TIME. 10ms of the data type TIME correspond to 1.0 LREAL unit, e.g. when LREAL = 1.0, TIME = 10ms; when LREAL = 100.0, TIME = 1s. The value of the data type real is rounded off to the nearest whole number for the conversion.
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
lrValue: LREAL:=5.983e5;
bStart: BOOL:=FALSE;
tResult: TIME:=T#0s;
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_CONTACT,,bStart,3,2,5,4,);
B(B_F,E_LREAL_TO_TIME!,,10,1,19,5,,?DEN?Da_LReal?AENO?C);
B(B_VARIN,,lrValue,8,3,10,5,);
B(B_VAROUT,,tResult,19,3,21,5,);
L(1,0,1,6);
L(1,3,3,3);
L(5,3,10,3);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if (bStart) then
tResult:=LREAL_TO_TIME(lrValue);
end_if;