Math Status Flags
Follow the guidelines in this topic for Math Status Flags.
Description
A set of Math Status Flags for accessing directly with instructions. These flags are only
updated in ladder diagram routines, and are not tags, and flag aliases are not
applicable.
Status Flags
Status Flag | Description |
|---|---|
S:FS First scan flag | The first scan flag is set by the controller:
Use the first scan flag to initialize data for use in later scans. It is also
referred to as the first pass bit. |
S:N Negative flag | The controller sets the negative flag when the result of a math or logical
operation is a negative value. Use this flag as a quick test for a negative
value. |
S:Z Zero flag | The zero flag is set by the controller when the result of a math or logical
operation is zero. Use this flag as a quick test for a zero value. The zero flag clears at the start of executing an instruction capable of setting
this flag. |
S:V Overflow flag | The controller sets the overflow flag when:
Use the overflow flag to verify the result of an operation is still in range. If the data being stored is a string type, S:V is set if the string is too large
to fit into the destination tag.
TIP:
If applicable, set S:V with an OTE or OTL
instruction.
Click Controller Properties > Advanced tab > Report Overflow Faults
to enable or disable reporting overflow faults.If an overflow occurs while evaluating an array subscript, a minor fault is
generated and a major fault is generated to indicate the index is out of
range. |
S:C Carry flag | The controller sets the carry flag when the result of a math operation resulted
in the generation of a carry out of the most significant bit. Only the ADD and SUB instructions, and not the + and – operators, with integer
values affect this flag. |
S:MINOR Minor fault flag | The controller sets the minor fault flag when there is at least one minor program
fault. Use the minor fault tag to test if a minor fault occurred. This bit only triggers
by programming faults, such as overflow. It is not triggered by a battery fault.
The bit clears at the beginning of every scan.
TIP:
If applicable, explicitly set S:MINOR with
an OTE or OTL instruction.
|
IMPORTANT:
The math status flags are set based on the
stored value. Instructions that normally do not affect math status flags might appear to
affect math status flags if type conversion occurs from mixed data types for the
instruction parameters. The type conversion process sets the math status flags.
Expressions in Array Subscripts
Expressions do not set status flags based on the results of math operations. If expressions
overflow:
- A minor fault generates if the controller is configured to generate minor faults.
- A major fault (type 4, code 20) generates because the resulting value is out of range.
TIP:
If an array subscript is too large (out of range), a major fault (type 4,
code 20) generates.
Provide Feedback