Scale INTEGER data to unsigned INTEGER data
This instruction scales an INTEGER value between a lower and an upper limit to an unsigned INTEGER output value. Use WITHIN_LIMITS to check if the input value is within the specified limits.
Input
Input signal
Lower limit of the input range
Upper limit of the input range
Output value assigned to the lower limit of the input range (can be higher than uiOutputUpperLimit)
Output value assigned to the upper limit of the input range (can be lower than uiOutputLowerLimit)
Output
Scaled output signal
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
iInput1: INT:=2000;
uiOutput1: UINT:=0;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_F,SCALE_INT_UINT!,,15,0,26,7,,?DiInput?DiInputLowerLimit?DiInputUpperLimit?DuiOutputLowerLimit?DuiOutputUpperLimit?C);
B(B_VARIN,,iInput1,13,1,15,3,);
B(B_VARIN,,-1000,13,2,15,4,);
B(B_VARIN,,3000,13,3,15,5,);
B(B_VARIN,,20000,13,4,15,6,);
B(B_VARIN,,60000,13,5,15,7,);
B(B_VAROUT,,uiOutput1,26,1,28,3,);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if (bScale) then
uiOutput1 := SCALE_INT_UINT(iInput := iInput1,
iInputLowerLimit := -1000,
iInputUpperLimit := 3000,
uiOutputLowerLimit := 20000,
uiOutputUpperLimit := 60000);
end_if;