Ladder Logic Arithmetic Status Flags

Arithmetic Status Flags

Status flags are set when arithmetic operation are used and can be directly programmed in Ladder Logic. Status flags cannot be aliased to other tags.

S:V         Math Overflow

The Overflow Flag also known as the Overflow Bit, is set if a value does not fit into the destination. Either the value is larger than the maximum value or the value is smaller than the minimum value of the destination. The Overflow bit generates a minor fault type 4, code 4.

The MOD instruction does not set the Overflow Flag.

The Overflow Flag can be referenced to the following bit instructions: XIC, XIO, OTE, OTU and OTL. The Overflow Flag should be used immediately after an instruction, or before an instruction capable of setting the Overflow Flag is used, as the Overflow Flag is set until another instruction capable of setting the Overflow flag is scanned.

S:Z          Zero

The Zero Flag also known as the Zero Bit, is set when an instruction is executed and the output or “Destination” value is zero. Using the Zero Flag in lieu of the CMP instruction is preferred for its efficiency to quickly check for a zero result.

The Zero Flag can be referenced to the following bit instructions: XIC, XIO, OTE, OTU and OTL. The Zero Flag should be used immediately after an instruction, or before an instruction capable of setting the Zero Flag is used, as the Zero Flag is set until another instruction capable of setting the Zero flag is scanned.

S:N         Sign Or Negative

The Sign Flag also known as the Sign Bit, is set when an instruction is executed and the output or “Destination” value is negative. Using the Sign Flag in lieu of the CMP instruction is preferred for its efficiency to quickly check for a negative result.

The Sign Flag can be referenced to the following bit instructions: XIC, XIO, OTE, OTU and OTL. The Sign Flag should be used immediately after an instruction, or before an instruction capable of setting the Sign Flag is used, as the Sign Flag is set until another instruction capable of setting the Sign flag is scanned.

S:C          Carry

The Carry Flag is set when an instruction is executed and the result of the math generates a carry out of the most significant bit.

The Carry Flag can be referenced to the following bit instructions: XIC, XIO, OTE, OTU and OTL. The Carry Flag should be used immediately after an instruction, or before an instruction capable of setting the Carry Flag is used, as the Carry Flag is set until another instruction capable of setting the Carry flag is scanned.