SCALE_UINT_INT

Scale UINT data to INT data

This instruction scales an unsigned INTEGER value between a lower and an upper limit to an INTEGER output value. Use WITHIN_LIMITS to check if the input value is within the specified limits.

Parameters

Input

uiInput (UINT)

Input signal

uiInputLowerLimit (UINT)

Lower limit of the input range

uiInputUpperLimit (UINT)

Upper limit of the input range

iOutputLowerLimit (INT)

Output value assigned to the lower limit of the input range (can be higher than iOutputUpperLimit)

iOutputUpperLimit (INT)

Output value assigned to the upper limit of the input range (can be lower than iOutputLowerLimit)

Output

VAR_OUT (INT)

Scaled output signal

Example

POU header

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
		uiInput3: UINT:=37500;
		iInput3: INT:=0;
	END_VAR

LD body

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_UINT_INT!,,15,0,26,7,,?DuiInput?DuiInputLowerLimit?DuiInputUpperLimit?DiOutputLowerLimit?DiOutputUpperLimit?C);
B(B_VARIN,,uiInput3,13,1,15,3,);
B(B_VARIN,,30000,13,2,15,4,);
B(B_VARIN,,40000,13,3,15,5,);
B(B_VARIN,,-10000,13,4,15,6,);
B(B_VARIN,,30000,13,5,15,7,);
B(B_VAROUT,,iOutput3,26,1,28,3,);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bScale) then
    iOutput3 := SCALE_UINT_INT(uiInput := uiInput3,
           uiInputLowerLimit := 30000
           uiInputUpperLimit := 40000,
           iOutputLowerLimit := -10000,
           iOutputUpperLimit := 30000);
end_if;

Modified on: 2019-06-03Feedback on this pagePanasonic hotline