SCALE_REAL

Scale REAL data

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

Parameters

Input

rInput (REAL)

Input signal

rInputLowerLimit (REAL)

Lower limit of the input range

rInputUpperLimit (REAL)

Upper limit of the input range

rOutputLowerLimit (REAL)

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

rOutputUpperLimit (REAL)

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

Output

VAR_OUT (REAL)

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
		rInput4: REAL:=50.0e3;
		rOutput4: REAL:=0.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_REAL!,,15,0,26,7,,?DrInput?DrInputLowerLimit?DrInputUpperLimit?DrOutputLowerLimit?DrOutputUpperLimit?C);
B(B_VARIN,,rInput4,13,1,15,3,);
B(B_VARIN,,-100.0e3,13,2,15,4,);
B(B_VARIN,,+100.0e3,13,3,15,5,);
B(B_VARIN,,0,13,4,15,6,);
B(B_VARIN,,1000.0e4,13,5,15,7,);
B(B_VAROUT,,rOutput4,26,1,28,3,);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bScale) then
    rOutput4 := SCALE_REAL(rInput := rInput4t,
           rInputLowerLimit := -100.0e3,
           rInputUpperLimit := 100.0e3,
           rOutputLowerLimit := 0,
           rOutputUpperLimit := 1000.0e4);
end_if;

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