ABS block
Short summary
Name |
ABS |
→POU type |
|
Category |
|
Conform to →IEC-standard |
no restrictions |
Graphical interface |
|
Available since |
|
Functionality
The mathematical function Abs is called: The block returns the absolute value (i.e. without sign) of the value connected to the input value.
Special case: If the input gets a negative value that matches the lower limit of the data type, the block returns this negative value. Reason: There is no corresponding positive value for the lower limit (= the most negative value). Furthermore, the output ENO is set to value FALSE.
See under "Example for usage within ST-editor"
: If the most negative SINT value -128 is connected to the input, the blocks returns the value -128 (the most positive SINT value is 127) and ENO=FALSE.
Inputs, return value
|
Identifier |
Description |
|
Inputs: |
IN |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
value |
Return value: |
– |
REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT |
|
Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.
See:
"Blocks for safe logic" whether this block is supported for developing safety-relevant applications.
"Highlighting safe logic in the FBD-editor" for the effects when using the block as a block for safe logic .
Internal error diagnostic for block
The block checks the return value. If the return value is a negative value that matches the lower limit of the data type, the output ENO of the block is set to value FALSE (or an equivalent).
Example for usage within ST-editor
PROGRAM Test
VAR
result1, result2, result3 : SINT;
CheckENO1, CheckENO2, CheckENO3 : BOOL;
END_VAR
result1 := ABS(IN := -
5
, ENO => CheckENO1); (* The variable
'result1'
evaluates to
'5'
. The variable
'CheckENO1'
evaluates to
'TRUE'
. *)
result2 := ABS(IN := -
127
, ENO => CheckENO2); (* The variable
'result2'
evaluates to
'127'
. The variable
'CheckENO2'
evaluates to
'TRUE'
. *)
result3 := ABS(IN := -
128
, ENO => CheckENO3); (* The variable
'result3'
evaluates to
'-128'
. The variable
'CheckENO3'
evaluates to
'FALSE'
. *)
END_PROGRAM
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.