In Siemens PLCs the Status Word is an internal CPU register used to keep track of the state of the instructions as they are being processed. In order to use STL more effectively it is important to understand the Status Word and its functions.
Each bit in the Status Word has a specific function to keep track of bit logic (RLO, STA), math (OV, OS), comparison operations (CC0, CC1) and whether the logic should continue, be nested or start new (/FC, OR, BR). Only the first 9 of the 16 bits are used.
Bit Positions
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
BR |
CC0 |
CC1 |
OV |
OS |
OR |
STA |
RLO |
/FC |
Each instruction may do the following to each bit in the status word.
- |
No read or write |
* |
Read |
x |
May write "1" or "0" |
0 |
Reset to "0" |
1 |
Set to "1" |
The status word can be seen by displaying the STATUS column while monitoring in STL view. The RLO (bit 1) and the STA (bit 2) are also displayed in the RLO and STA column.
The Most Important Status Word Bits
/FC – First Check (bit 0)
If the /FC bit is a 0 then the instruction is considered to be the first instruction being processed. If the /FC is a 1 then the instruction being scanned will use the logic from the previous instruction. Certain instructions like =, S and R will set the /FC bit to 0 thus starting new logic after it. Other instructions like A or O will set the /FC bit to 1 signalling to combine the logic with the next instruction.
RLO – Result of Logic Operation (bit 1)
The RLO bit stores the running logic state of the currently processing instructions. Certain bit logic and comparison instruction will turn the RLO to a 1 when the condition is TRUE and write a 0 when the condition is FALSE. Other instructions read the RLO (=, S, R) to determine how they are to execute.
STA – Status (bit 2)
The STA bit reflects the state of the current Boolean address.
Help with RLO, STA and /FC
If you are used to ladder logic and struggling to understand the purpose of the RLO and STA it may help to visualize a rung like below. The STA is used to keep track of the state of the addresses. The RLO is used to keep track of the state of the rung.
The equivalent STL is shown below.
It steps through the logic as follows:
The Other Status Bits
OR (bit 3)
The OR bit is used for combining AND functions before OR functions.
OS – Overflow Stored (bit 4)
In the event of an overflow (OV bit 5) the OS bit will store the value even after the OV bit has been reset. The following commands reset the OS bit: JOS (Jump if OS=1), block call instructions, block end instructions.
OV – Overflow (bit 5)
The OV bit is set by a math instruction with floating point numbers after a fault has occurred (overflow, illegal operation, comparison unordered). The OV bit is reset when the fault is eliminated.
CC0, CC1 – Condition Code (bits 6 and 7)
The Condition Code bits provide results for comparison and math instructions.
Comparison Instructions
CC 1 |
CC 0 |
Meaning |
0 |
0 |
ACCU 2 = ACCU 1 |
0 |
1 |
ACCU 2 < ACCU 1 |
1 |
0 |
ACCU 2 > ACCU 1 |
1 |
1 |
Unordered (floating point comparison only) |
Math Instructions, without Overflow
CC 1 |
CC 0 |
Meaning |
0 |
0 |
Result = 0 |
0 |
1 |
Result < 0 |
1 |
0 |
Result > 0 |
Integer Math Instructions, with Overflow
CC 1 |
CC 0 |
Meaning |
0 |
0 |
Negative range overflow in ADD_I and ADD_DI |
0 |
1 |
Negative range overflow in MUL_I and MUL_DI |
1 |
0 |
Negative range overflow in ADD_I, ADD_DI, SUB_I, and SUB_DI |
1 |
1 |
Division by 0 in DIV_I, DIV_DI, and MOD_DI |
Floating Point Math Instructions, with Overflow
CC 1 |
CC 0 |
Meaning |
0 |
0 |
Gradual underflow |
0 |
1 |
Negative range overflow |
1 |
0 |
Positive range overflow |
1 |
1 |
Not a valid floating-point number |
Shift and Rotate Instructions
CC 1 |
CC 0 |
Meaning |
0 |
0 |
Bit shifted out = 0 |
1 |
0 |
Bit shifted out = 1 |
Word Logic Instructions
CC 1 |
CC 0 |
Meaning |
0 |
0 |
Result = 0 |
1 |
0 |
Result <> 0 |
BR – Binary Result (bit 8)
The Binary Result transfers the result of the operations
onto the next instruction for reference. When the BR bit is 1 it enables the output
of the block (ENO) to be TRUE and thus allow other blocks after it to be
processed. The SAVE, JCB and JNB instructions set the BR bit.