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.
Input
Negative bias value
Positive bias value
Input value
Output
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)
if the area specified using the index modifier exceeds the limit.
if s1_Min > s2_Max
if the area specified using the index modifier exceeds the limit.
if s1_Min > s2_Max
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
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
IF bStart THEN
FP_ZONE(s1_NegBias := 5, s2_PosBias := 2, s3_In := diChecked_value, d => diOutput_value);
END_IF;