FP_ZONE

Add offset to input value

This FP instruction adds an offset value to the input value at s3_In. If the input value is negative, the offset specified at s1_NegBias is added. If the input value is positive, the offset specified at s2_PosBias is added. The result is stored in d.

Parameters

Input

s1_NegBias (INT, DINT, UINT, UDINT, REAL, LREAL)

Negative bias value

s2_PosBias (INT, DINT, UINT, UDINT, REAL, LREAL)

Positive bias value

s3_In (INT, DINT, UINT, UDINT, REAL, LREAL)

Input value

Output

d (INT, DINT, UINT, UDINT, REAL, LREAL)
Result

Remarks

The result is calculated as follows:

  • For s3_In < 0: d=s3_In +s1_NegBias (negative bias is added to input value)

  • s3_In = 0: d= 0

  • For s3_In > 0: d=s3_In +s2_PosBias (positive bias is added to input value)

    1.  (1) Output value d
    2.  (2) Positive bias value s2_PosBias
    3.  (3) Input value s3_In
    4.  (4) Negative bias value s1_NegBias

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the area specified using the index modifier exceeds the limit.

  • if s1_Min > s2_Max

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the area specified using the index modifier exceeds the limit.

  • if s1_Min > s2_Max

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
		bStart: BOOL:=FALSE;
			(*activates the function*)
		diChecked_value: DINT:=18;
			(*value to check*)
		diOutput_value: DINT:=0;
			(*result after a 0->1 leading
edge from start: 20*)
	END_VAR
When the variable bStart is set to TRUE, the function is carried out.

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,FP_ZONE!,,13,0,21,6,,?DEN?Ds1_NegBias?Ds2_PosBias?Ds3_In?AENO?Cd);
B(B_CONTACT,,bStart,5,1,7,3,);
B(B_VARIN,,5,11,2,13,4,);
B(B_VARIN,,2,11,3,13,5,);
B(B_VARIN,,diChecked_value,11,4,13,6,);
B(B_VAROUT,,diOutput_value,21,2,23,4,);
L(1,2,5,2);
L(7,2,13,2);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF bStart THEN     
    FP_ZONE(s1_NegBias := 5, s2_PosBias := 2, s3_In := diChecked_value, d => diOutput_value);
END_IF;

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