Chapter 6
Compute/Math Instructions (CPT, ADD, SUB, MUL, DIV, MOD, SQR, SQRT, NEG, ABS)
Negate (NEG)
dest := -source;
Input Parameter
Data Type
EnableIn
BOOL
Source
REAL
Output Parameter
Data Type
EnableOut
BOOL
Dest
REAL
286
The NEG instruction changes the sign of the Source and places the result in the
Destination.
Operands:
Relay Ladder
Operand
Source
Destination
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.
See
Structured Text Programming
within structured text.
Function Block
Operand
NEG tag
FBD_MATH Structure
Description
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
Value to negate.
Valid = any float
Description
The instruction produced a valid result.
Result of the math instruction. Arithmetic status flags are set for this output.
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Type
Format
SINT
Immediate Tag
INT
DINT
REAL
A SINT or INT tag converts to a DINT value by sign-extension.
SINT
Tag
INT
DINT
REAL
for information on the syntax of expressions
Type
FBD_MATH_ADVANCED
Description
Value to negate
Tag to store the result
Format
Description
Structure
NEG structure