Round up to the nearest integer
This FP instruction rounds up to the nearest integer.
Input
Input value
Output
Result
if the area specified using the index modifier exceeds the limit.
if s is not a REAL number
if the area specified using the index modifier exceeds the limit.
if s is not a REAL number
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
bStart: BOOL:=FALSE;
(*activates the function*)
rInput_value: REAL:=32.71;
rOutput_value: REAL:=0.0;
(*result after a 0->1 leading
edge from start: 33.0*)
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
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,FP_ROUND!,,13,0,20,4,,?DEN?D@'s'?AENO?Cd);
B(B_CONTACT,,bStart,4,1,6,3,);
B(B_VARIN,,rInput_value,11,2,13,4,);
B(B_VAROUT,,rOutput_value,20,2,22,4,);
L(1,2,4,2);
L(6,2,13,2);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF bStart THEN
FP_ROUND(s := rInput_value, d => rOutput_value);
END_IF;