WITHIN_LIMITS

Evaluate if a value is inside the limit

This instruction evaluates whether the value at the input IN is within the limits set at minimum MN and maximum MX.

Parameters

Input

MN (ANY)

Minimum limit

IN (ANY)

Value compared to the limits

MX (ANY)

Maximum limit

Output

VAR_OUT (BOOL)

TRUE if the input value at IN falls within the lower and upper limits

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
		iMinValue: INT:=50;
		iValidateValue: INT:=750;
		iMaxValue: INT:=1000;
		bResult: BOOL:=FALSE;
	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 := 6 ;
        NETWORK_BODY
B(B_F,WITHIN_LIMITS!,,12,1,20,6,,?DMN?DIN?DMX?C);
B(B_VARIN,,iMinValue,10,2,12,4,);
B(B_VARIN,,iValidateValue,10,3,12,5,);
B(B_VARIN,,iMaxValue,10,4,12,6,);
B(B_VAROUT,,bResult,20,2,22,4,);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

bResult := WITHIN_LIMITS(MN := iMinValue,
                           IN := iValidateValue,
                           MX := iMaxValue);

Modified on: 2022-08-23Feedback on this pagePanasonic hotline