Showing posts with label ABS. Show all posts

Absolute Value (ABS)

0 comments
The ABS instruction takes the absolute value of the Source and places the result in the Destination.

Available Languages
-    Ladder Diagram

-    Function Block
-    Structured Text

dest := ABS(source);

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Source*
SINT
INT
DINT
REAL
Immediate
tag
value from which to take the absolute value
Destination
SINT
INT
DINT
REAL
tag
tag to store the result
*Data Conversion: SINT and INT tags are sign-extended.
   
-    Function Block
Operand
Type
Format
Description
ABS tag
FBD_MATH_ADVANCED
structure
ABS structure

-    Structured Text
Use ABS as a function. This expression computes the absolute value of source and stores the result in dest.

dest := ABS(source);

FBD_MATH Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
Source
REAL
Value of which to take the absolute value.
Valid = any float

Output Parameter
Data Type
Description
EnableOut
BOOL
Enable output.
Dest
REAL
Result of the math instruction. Arithmetic status flags are set for this output.

Example
Place the absolute value of value_1 into value_1_absolute. In this example, the absolute value of negative four is positive four.

-    Ladder Diagram
-    Function Block
-    Structured Text

value_1_absolute := ABS(value_1);

File name: PLC-24_IS_CMI-ABS.pdf
File size: 412.69 KB

Read More »