Absolute Value (ABS)

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

0 comments :

Negate (NEG)

The NEG instruction changes the sign of the Source and places the result in the Destination.

Available Languages
-    Ladder Diagram
-    Function Block
-    Structured Text
This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use the operator in an expression.
Operands

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Source
SINT
INT
DINT
REAL
Immediate
tag
value to negate
Destination
SINT
INT
DINT
REAL
tag
tag to store the result

-    Function Block
Operand
Type
Format
Description
NEG tag
FBD_MATH_ADVANCED
structure
NEG structure

-    Structured Text
Use the minus sign "-" as an operator in an expression. This expression changes the sign of source and stores the result in dest.

dest := -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 to negate.
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
Change the sign of value_1 and place the result in negate_result.

-    Ladder Diagram
-    Function Block
-    Structured Text
negate_result := -value_1;

File name: PLC-23_IS_CMI-NEG.pdf
File size: 408.47 KB

0 comments :

Square Root (SQR/SQRT)

The SQR instruction computes the square root of the Source and places the result in the Destination.

Available Languages
-    Ladder Diagram
-    Function Block
-    Structured Text
Use SQRT as a function.

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Source
SINT
INT
DINT
REAL
Immediate
tag
find the square root of this value
Destination
SINT
INT
DINT
REAL
tag
tag to store the result

-    Function Block
Operand
Type
Format
Description
SQR tag
FBD_MATH_ADVANCED
structure
SQR structure

-    Structured Text
Use SQRT as a function. This expression computes the square root of source and stores the result in dest.

dest := SQRT(source);

FBD_MATH_ADVANCED 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
Find the square root of this 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
Calculate the square root of value_1 and place the result in sqr_result.

-    Ladder Diagram
-    Function Block
-    Structured Text
sqr_result := SQRT(value_1);

File name: PLC-22_IS_CMI-SQR-SQRT.pdf
File size: 408.99 KB

0 comments :

Modulo (MOD)

The MOD instruction divides Source A by Source B and places the remainder in the Destination.

Available Languages
-    Ladder Diagram
-    Function Block
-    Structured Text
This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use the operator in an expression.

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Source A*
SINT
INT
DINT
REAL
Immediate
tag
value of the dividend
Source B*
SINT
INT
DINT
REAL
immediate
tag
value of the divisor
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
MOD tag
FBD_MATH
structure
MOD structure

-    Structured Text
Use MOD as an operator in an expression. This expression divides sourceA by sourceB and stores the remainder in dest.

dest := sourceA MOD sourceB;

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.
SourceA
REAL
Value of the dividend.
Valid = any float
SourceB
REAL
Value of the divisor.
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
Divide dividend by divisor and place the remainder in remainder. In this example, 3 goes into 10 ten times, with a remainder of 1.

-    Ladder Diagram
-    Function Block
-    Structured Text

remainder := dividend MOD divisor;

File name: PLC-21_IS_CMI-MOD.pdf
File size: 418.71 KB

0 comments :

Divide (DIV)

The DIV instruction divides Source A by Source B and places the result in the Destination.

Available Languages
-    Ladder Diagram
-    Function Block
-    Structured Text
This instruction is not available in structured text. *
* There is no equivalent structured text instruction. Use the operator in an expression.

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Source A
SINT
INT
DINT
REAL
Immediate
tag
value of the dividend
Source B
SINT
INT
DINT
REAL
immediate
tag
value of the divisor
Destination
SINT
INT
DINT
REAL
tag
tag to store the result

-    Function Block
Operand
Type
Format
Description
DIV tag
FBD_MATH
structure
DIV structure

-    Structured Text
Use the divide sign "/" as an operator within an expression. This expression divides sourceA by sourceB and stores the result in dest.

dest := sourceA / sourceB;

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.
SourceA
REAL
Value of the dividend.
Valid = any float
SourceB
REAL
Value of the divisor.
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
Divide float_value_1 by float_value_2 and place the result in divide_result.

-    Ladder Diagram
-    Function Block
-    Structured Text

divide_result := float_value_1 / float_value_2;

File name: PLC-20_IS_CMI-DIV.pdf
File size: 418.86 KB

0 comments :