Selected Negate (SNEG)

This information applies to the
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370,
GuardLogix
5570,
Compact GuardLogix
5380,
CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580, and
GuardLogix
5580 controllers.
The Selected Negate (SNEG) instruction uses a digital input to select between the input value and the negative of the input value.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram logic.
Function Block
SNEG_FBD_avail_v31
Structured Text
SNEG(SNEG_tag);
Operands
Function Block
Operand
Type
Format
Description
SNEG tag
SELECTABLE_NEGATE
Structure
SNEG structure
SNEG Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If false, the instruction does not execute and outputs are not updated.
Default is true.
Structured Text:
No effect. The instruction executes.
In
REAL
The analog signal input to the instruction.
Valid = any float
Default = 0.0
NegateEnable
BOOL
Negate enable. When NegateEnable is true, the instruction sets Out to the negative value of In.
Default is true.
Output Parameter
Data Type
Description
EnableOut
BOOL
Indicates if instruction is enabled. Cleared to false if Out overflows.
Structured Text
Operand
Type
Format
Description
SNEG tag
SELECTABLE_NEGATE
Structure
SNEG structure
See Structured Text Syntax for more information on the syntax of expressions within structured text.
Description
The SNEG instruction operates as follows:
Condition
Action
NegateEnable is true
Out = - In
NegateEnable is false
Out = In
Affects Math Status Flags
No
Major/Minor faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Function Block
Condition/State
Action Taken
Prescan
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is false
EnableIn and EnableOut bits are cleared to false.
Tag.EnableIn is true
EnableIn and EnableOut bits are set to true.
The instruction executes.
Instruction first run
N/A
Instruction first scan
N/A
Postscan
EnableIn and EnableOut bits are cleared to false.
Structured Text
Condition/State
Action Taken
Prescan
See Prescan in the Function Block table.
Normal Execution
See Tag.EnableIn is true in the Function Block table.
Postscan
See Postscan in the Function Block table.
Example
The negate_enable input determines whether to negate In or not. The instruction sets Out = In if NegateEnable is false. The instruction sets Out = -In if NegateEnable is true.
Function Block
SNEG_FBD_ex_v31
Structured Text
SNEG_01.In := analog_input1;
SNEG_01.NegateEnable := negate_enable;
SNEG(SNEG_01);
output_value := SNEG_01.Out;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.