Compare with deadband
This FP instruction compares the positive or negative input value at input s3_In with a deadband. The deadband's lower limit is specified at input s1_Min and its upper limit is specified at s2_Max. The result is stored in d.
Input
Input value
On 16-bit PLC types: (INT, DINT, REAL)
On 32-bit PLC types: (INT, DINT, UINT, UDINT, REAL, LREAL)
Input value
On 16-bit PLC types: (INT, DINT, REAL)
On 32-bit PLC types: (INT, DINT, UINT, UDINT, REAL, LREAL)
Input value
On 16-bit PLC types: (INT, DINT, REAL)
On 32-bit PLC types: (INT, DINT, UINT, UDINT, REAL, LREAL)
Output
Result
On 16-bit PLC types: (INT, DINT, REAL)
On 32-bit PLC types: (INT, DINT, UINT, UDINT, REAL, LREAL)
The result is calculated as follows:
For s3_In <s1_Min: d =s3_In – s1_Min (lower limit is subtracted from input value)
For s3_In >s2_Max: d =s3_In – s2_Max (upper limit is subtracted from input value)
For s2_Max³s3_In³s1_Min: d = 0
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:=6;
(*value to check*)
diOutput_value: DINT:=0;
(*result after a 0->1 leading
edge from start: -2*)
END_VAR
When the variable bStart is set to TRUE, the function is carried out.
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,FP_BAND!,,11,1,18,7,,?DEN?Ds1_Min?Ds2_Max?Ds3_In?AENO?Cd);
B(B_CONTACT,,bStart,4,2,6,4,);
B(B_VARIN,,-10,9,3,11,5,);
B(B_VARIN,,20,9,4,11,6,);
B(B_VARIN,,diChecked_value,9,5,11,7,);
B(B_VAROUT,,diOutput_value,18,3,20,5,);
L(1,3,4,3);
L(6,3,11,3);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF start THEN
FP_BAND(s1_Min := -10,
s2_Max := 20,
s3_In := diChecked_value,
d => diOutput_value);
END_IF; (* 10=lower limit of deadband, 20=upper limit of deadband *)