Mastering Siemens PLC Status Word and Control Word Applications


Hello everyone, I am your PLC teacher, Dog Brother. Today we will talk about the status word and control word in Siemens PLC. These two "words" are important roles in PLC programming! They act like the "eyes" and "hands" of the PLC, helping us monitor and control the operation state of the PLC. Mastering them will definitely elevate your PLC programming skills!
## 1. What is a Status Word?
The status word is like a "health report" for the PLC, recording the current operating state of the PLC. Imagine that when you are running, your watch displays your heart rate, step count, calories burned, etc. This information is equivalent to your "status word". In Siemens PLC, the status word is a 16-bit binary number, with each bit representing different state information.
Let's take a look at the structure of the status word:

Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0| | | | | | | | | | | | | | | || | | | | | | | | | | | | | | +– 1: Result is 0| | | | | | | | | | | | | | +—– 1: Result is negative| | | | | | | | | | | | | +——– 1: Overflow| | | | | | | | | | | | +———– 1: Division by 0| | | | | | | | | | | +————– Unused| | | | | | | | | | +—————– Unused| | | | | | | | | +——————– 1: Nested interrupt not allowed| | | | | | | | +———————– 1: Interrupt allowed| | | | | | | +————————– 1: Main program| | | | | | +—————————– 1: Scan monitoring time error| | | | | +——————————– 1: Battery fault| | | | +———————————– 1: Diagnostic buffer full| | | +————————————– 1: Maintenance needed| | +—————————————– 1: Clock running| +——————————————– 1: Start (warm start/cold start/warm restart)+———————————————– 1: Request complete communication reset


Tip: Remembering the meaning of each bit in the status word may be a bit difficult, but you don't need to memorize it. In practical programming, we usually only focus on a few important bits, such as "result is 0", "result is negative", etc.
## 2. How to Read the Status Word?
Reading the status word is simple; we can use STL (Statement List) or LAD (Ladder Diagram) to achieve this. Here I will show you the STL method:

L STW // Load the status word into accumulator 1T MW100 // Transfer the status word to MW100


This code stores the value of the status word into MW100. Now, if you want to know whether the calculation result is 0, you can do it like this:

L MW100 // Load the value of MW100 into accumulator 1L W#16#1 // Load binary mask 0000000000000001UW // Bitwise AND operationL W#16#1 // Load 1 for comparison==I // Compare for equality= M200.0 // If equal, set M200.0 to 1


Note: When using the status word, be aware that its value changes in real-time. If you need to use a specific state of the status word in multiple networks, it is best to first save the entire status word to a memory area, and then use this saved value.
## 3. What is a Control Word?
If the status word is the "health report" of the PLC, then the control word is the "remote control" of the PLC. By setting the control word, we can control certain behaviors of the PLC. The control word is also a 16-bit binary number, with each bit corresponding to different control functions.
The structure of the control word is as follows:

Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0| | | | | | | | | | | | | | | || | | | | | | | | | | | | | | +– 1: Request Start| | | | | | | | | | | | | | +—– 1: Request Cold Start| | | | | | | | | | | | | +——– 1: Request Warm Start| | | | | | | | | | | | +———– 1: Request Warm Restart| | | | | | | | | | | +————– 1: Request Delete All Areas| | | | | | | | | | +—————– 1: Request Compress Memory| | | | | | | | | +——————– Unused| | | | | | | | +———————– Unused| | | | | | | +————————– Unused| | | | | | +—————————– 1: Request Read Diagnostic Buffer| | | | | +——————————– 1: Request Set Time| | | | +———————————– Unused| | | +————————————– Unused| | +—————————————– Unused| +——————————————– Unused+———————————————– 1: Request Complete Communication Reset


## 4. How to Use the Control Word?
The process of using the control word is basically to set specific bits and then write the entire control word into the system memory. Here we take the request for a warm restart as an example:

L W#16#0 // Load 0 into accumulator 1SETS A 8 // Set bit 8 to 1 (request warm restart)T MW200 // Store the control word to MW200

L MW200 // Load the control wordT PQW 274 // Write the control word into system memory


Tip: Be extra careful when using the control word, as it may cause the PLC to restart or clear memory. In actual projects, safety mechanisms are usually set, such as requiring a specific password or multiple conditions to be met before executing certain sensitive operations.
## 5. Practical Applications of Status Word and Control Word
Let's look at a simple example of how to use the status word and control word to monitor and control a simple counter:

// Use status word to check if the counter has reached the target valueL C#10 // Load target value 10 into accumulator 1L C1 // Load the current value of counter C1==I // Compare for equalityJC NEXT // If equal, jump to NEXT

// If the counter has not reached the target value, continue countingL C1INC 1T C1

JU END // Jump to program end

NEXT: NOP 0

// Use control word to reset the counterL W#16#0 // Load 0 into accumulator 1SETS A 4 // Set bit 4 to 1 (request delete all areas)T MW300 // Store the control word to MW300

L MW300T PQW 274 // Write the control word into system memory

END: NOP 0


This example demonstrates how to use the status word to check the value of the counter, as well as how to use the control word to reset the counter.
Note: In practical applications, resetting all areas is a very aggressive operation. In most cases, we would choose a more gentle method, such as only resetting specific data blocks or using specific function blocks to reset the counter.
## Conclusion
Today we learned about the status word and control word in Siemens PLC. The status word helps us monitor the operating state of the PLC, while the control word allows us to control the behavior of the PLC. Mastering these two "words" will help you better understand and control the operation process of the PLC.
Mini Exercise: Try writing a program that uses the status word to detect whether a division operation has resulted in a division by zero error. If it occurs, use the control word to request a warm restart of the PLC. Tip: The division by zero error is indicated by the 3rd bit of the status word (counting from 0).
Friends, today's journey of learning Siemens PLC ends here! Remember to code, and feel free to ask Dog Brother any questions in the comments. Wishing everyone a pleasant learning experience and continuous improvement in Siemens PLC learning!

Leave a Comment