Reading and Understanding S5 AWL Code: A Practical Guide
Learn to read Siemens S5 AWL (Instruction List) code from scratch. Covers the accumulator model, bit logic, load/transfer, timers, counters, jumps, and data blocks with real code examples and line-by-line explanations.
Reading and Understanding S5 AWL Code: A Practical Guide
S5 AWL (Anweisungsliste / Instruction List) is a low-level text language where each line is one instruction operating on a single-bit result (VKE) or the 16-bit accumulators. To read AWL code, you need to understand three things: how the VKE (logic result bit) chains bit operations, how the two accumulators handle word/integer operations, and how jumps control program flow. This guide teaches all three with real code examples.
AWL is the most common programming language in legacy S5 systems. Even if the program was originally written in KOP (Ladder) or FUP (Function Block Diagram), the stored format is often AWL. If you open an S5 program and see text like U E 0.0 or L KT 030.2, you are looking at AWL.
The Two Core Concepts
Concept 1: The VKE (Verknüpfungsergebnis / Result of Logic Operation)
The VKE is a single bit that holds the result of all bit logic operations. Think of it as a running TRUE/FALSE answer that gets updated with every bit instruction.
U E 0.0 // VKE = state of E 0.0 (TRUE if input is ON)
U E 0.1 // VKE = previous VKE AND E 0.1
UN M 10.0 // VKE = previous VKE AND NOT M 10.0
= A 4.0 // Write VKE to output A 4.0
Reading this: "IF E 0.0 AND E 0.1 AND NOT M 10.0, THEN A 4.0 = ON."
VKE rules:
U(UND/AND) — VKE = VKE AND operandO(ODER/OR) — VKE = VKE OR operandUN(UND NICHT/AND NOT) — VKE = VKE AND NOT operandON(ODER NICHT/OR NOT) — VKE = VKE OR NOT operand=(Zuweisung/Assign) — Write VKE to operand, then reset VKES(Setzen/Set) — If VKE = TRUE, set operand to TRUE (latch)R(Rücksetzen/Reset) — If VKE = TRUE, set operand to FALSE (unlatch)
The VKE resets after an assignment (=), set (S), or reset (R) instruction. The next U or O instruction starts a new logic chain.
Concept 2: The Accumulators (ACCU1 and ACCU2)
The S5 CPU has two 16-bit registers called accumulators. All word operations (load, transfer, arithmetic, comparisons) use these two registers.
L MW 10 // Load MW10 into ACCU1 (previous ACCU1 moves to ACCU2)
L MW 12 // Load MW12 into ACCU1 (previous ACCU1=MW10 moves to ACCU2)
+F // ACCU1 = ACCU2 + ACCU1 = MW10 + MW12
T MW 20 // Transfer ACCU1 to MW20
Key rule: Every L (Load) instruction pushes the current ACCU1 content into ACCU2, then loads the new value into ACCU1. This is how two operands get into the two accumulators for arithmetic or comparison.
Accumulator operations:
L(Laden/Load) — Load value into ACCU1 (old ACCU1 → ACCU2)T(Transferieren/Transfer) — Copy ACCU1 to the specified address (accumulators unchanged)+F/+I— ACCU1 = ACCU2 + ACCU1 (integer addition)-F/-I— ACCU1 = ACCU2 - ACCU1 (integer subtraction)!=F/==I— Compare: sets VKE to TRUE if ACCU2 == ACCU1>F/>I— Compare: VKE = TRUE if ACCU2 > ACCU1TAK— Swap ACCU1 and ACCU2
Reading Bit Logic: The Self-Holding Circuit
The most common pattern in any S5 program:
U E 0.0 // Start button pressed?
S M 10.0 // Yes → Set memory flag (latch ON)
U E 0.1 // Stop button pressed?
R M 10.0 // Yes → Reset memory flag (latch OFF)
U M 10.0 // Is memory flag ON?
= A 4.0 // Yes → Turn on motor output
Plain English: "Press Start (E 0.0) to turn on the motor (A 4.0). It stays on until Stop (E 0.1) is pressed." This is the PLC equivalent of a relay self-holding circuit. You will see this pattern dozens of times in any industrial S5 program.
Note: If both Start AND Stop are pressed simultaneously, R (Reset) wins because it comes after S (Set) in the program. The last instruction in the scan cycle determines the final state.
Reading Timer Instructions
S5 timers look like this:
U E 0.0 // Start condition
L KT 030.2 // Load timer value: 30 × 1s = 30 seconds
SD T 1 // Start On-Delay Timer 1
U T 1 // Timer 1 finished?
= A 4.0 // Yes → Turn on output
How to read KT 030.2: The number before the dot (030) is the value. The number after the dot (2) is the time base. Time bases: 0 = 10ms, 1 = 100ms, 2 = 1s, 3 = 10s. So KT 030.2 = 30 × 1s = 30 seconds.
Timer types:
SI— Pulse: output ON while timing, OFF when done or input goes OFFSE— Extended pulse: like SI, but restarts on re-triggerSD— On-delay: output ON after time expires, IF input still ONSS— Retentive on-delay: like SD, but output stays ON until resetSA— Off-delay: output immediately ON, stays ON for set time after input goes OFF
Use our S5 Timer Calculator to decode any KT value.
Reading Counter Instructions
U E 1.0 // Count pulse (sensor)
L KZ 100 // Preset value 100
ZV Z 3 // Count UP on Z3
L Z 3 // Load current count value
T MW 30 // Store count in MW30
U Z 3 // Count > 0?
= A 5.0 // Yes → Output ON
ZV= Count up (Zähler vorwärts)ZR= Count down (Zähler rückwärts)KZ= Counter constant (0–999, BCD-encoded)
Reading Jump Instructions
Jumps are how AWL implements IF/ELSE logic:
U E 0.0 // Check input
SPB M001 // IF TRUE → jump to label M001
L KF +0 // (this executes when E 0.0 is FALSE)
T MW 20 // MW20 = 0
SPA DONE // Skip over the TRUE branch
M001: L KF +100 // (this executes when E 0.0 is TRUE)
T MW 20 // MW20 = 100
DONE: NOP 0 // Continue program
Jump types:
SPA— Jump unconditional (always jumps)SPB— Jump if VKE = 1 (jump if true)SPBN— Jump if VKE = 0 (jump if not true)SPZ— Jump if result = 0SPN— Jump if result ≠ 0
Reading tip: SPBN SKIP followed by some code and then SKIP: NOP 0 means: "Execute the code between SPBN and SKIP only if the condition is TRUE." The code is skipped when the condition is FALSE.
Reading Data Block Access
A DB 10 // Open Data Block 10
L DW 5 // Load Data Word 5 from DB10
T MW 20 // Store in MW20
A DB (Aufschlagen) opens a data block. It stays open until another A DB or C DB instruction. All subsequent DW accesses refer to the currently open DB. This is different from S7, where every access explicitly names the DB (DB10.DBW10).
Common trap: If you see L DW 5 without a preceding A DB in the same network, look backwards — the DB was opened earlier, possibly in a previous network or even a calling block.
Data word addressing: S5 uses word addressing. DW 0 is the first word, DW 1 is the next word (2 bytes later). When migrating to S7, multiply by 2: DW 5 → DBW 10.
Reading Block Calls
SPA FB 10 // Call Function Block 10 (unconditional)
SPA PB 3 // Call Program Block 3
In S5, SPA FB calls a function block, SPA PB calls a program block. S5 also has:
FX— Extended function blocks (with parameters)PB— Program blocks (like FCs but simpler)SB— Sequence blocks (for step chains)OB— Organization blocks (system-called)DB/DX— Data blocks / Extended data blocks
Reading Constant Formats
S5 uses prefix letters for different constant types:
| Format | Meaning | Example | Value |
|---|---|---|---|
| KF | Fixed-point integer | KF +100 | Integer 100 |
| KH | Hexadecimal | KH 00FF | Hex 00FF = 255 |
| KM | Bit pattern (16 bits) | KM 1111 0000 1111 0000 | Binary mask |
| KC | Character (2 chars) | KC AB | ASCII "AB" |
| KT | Timer value | KT 030.2 | 30 seconds |
| KZ | Counter value | KZ 100 | Count 100 |
| KY | Two bytes | KY 10,20 | Byte1=10, Byte2=20 |
| KG | Floating-point | KG +1.500+003 | 1.5 × 10³ |
Practical Example: Reading a Complete Network
Here is a real-world S5 network with line-by-line explanation:
U E 1.0 // Proximity sensor: part present
FP M 20.0 // Detect rising edge (part just arrived)
SPB M010 // IF edge detected → jump to M010
SPA M020 // ELSE → skip to M020
M010: L Z 1 // Load counter Z1 value
L KF +1 // Load constant 1
+F // Add: counter + 1
T MW 100 // Store new count
L MW 100 // Reload count
L KZ 050 // Load preset 50 (batch complete)
!=F // Compare: count == 50?
S M 30.0 // Yes → Set "batch complete" flag
M020: NOP 0 // Continue
Plain English: "Every time a new part arrives (rising edge on E 1.0), increment the counter in MW 100. When 50 parts have been counted, set the batch-complete flag M 30.0."
Quick Reference: Most Common S5 Instructions
| Instruction | What It Does |
|---|---|
| U / UN | AND / AND NOT (bit logic) |
| O / ON | OR / OR NOT (bit logic) |
| S / R | Set / Reset (latch) |
| = | Assign VKE to operand |
| L / T | Load into ACCU1 / Transfer ACCU1 to address |
| +F / -F | Integer add / subtract |
| !=F / >F / <F | Compare equal / greater / less |
| SPB / SPBN | Jump if true / Jump if not true |
| SPA | Jump unconditional |
| SD / SA / SI / SE / SS | Timer types |
| ZV / ZR | Count up / Count down |
| A DB | Open data block |
| BE | Block end |
| NOP 0 | No operation (placeholder) |
PLCcheck Pro explains any AWL code in plain language instantly. Upload your S5 program and get a complete line-by-line explanation. Try it now →
Frequently Asked Questions
What does VKE mean in AWL?
VKE stands for Verknüpfungsergebnis (Result of Logic Operation). It is a single bit that holds the running result of all bit logic instructions (U, O, UN, ON). It is the AWL equivalent of the "power rail" in ladder logic.
Why does AWL use two accumulators?
Because arithmetic and comparison operations need two operands. The first L loads a value into ACCU1. The second L pushes the first value to ACCU2 and loads the new value into ACCU1. Now both operands are available for +F, -F, !=F, etc.
What is the difference between SPB and SPBN?
SPB (Sprung bedingt) jumps IF the VKE is TRUE (=1). SPBN (Sprung bedingt NICHT) jumps IF the VKE is FALSE (=0). SPB skips code when the condition is false. SPBN skips code when the condition is true.
How do I know which data block is open?
Look backwards in the code for the most recent A DB or C DB instruction. The DB stays open until another one is opened. In online monitoring (STEP 5 status mode), the current DB number is shown in the status display.
Maintained by PLCcheck.ai. Last update: March 2026. Not affiliated with Siemens AG.
Related Articles
Taking Over an Undocumented PLC System: A Survival Guide
Practical step-by-step guide for technicians taking over an unknown PLC system. Covers the first-week checklist: hardware audit, program backup, risk assessment, spare parts, and building system knowledge from scratch.
14 min read
plc-documentationHow to Document a PLC Program Without Original Documentation
Practical step-by-step method for documenting an undocumented PLC program. Covers block inventory, I/O tracing, cross-reference analysis, symbol table creation, and generating useful documentation from raw code.
15 min read
migration-guideConverting S5 AWL to S7 SCL: Step-by-Step
Practical guide for converting Siemens S5 AWL (Instruction List) code to S7 SCL (Structured Text). Includes conversion tables, code examples for bit logic, timers, counters, jumps, and data blocks.
14 min read
Analyze your PLC code with AI
PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.
Try PLCcheck Pro →Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.