PLCcheck

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.

·16 min read
S5AWLSTLInstruction Listreading codeunderstandingVKEaccumulatorSiemenslegacy

Diesen Artikel auf Deutsch lesen

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:

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:

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:

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

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:

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:

Reading Constant Formats

S5 uses prefix letters for different constant types:

FormatMeaningExampleValue
KFFixed-point integerKF +100Integer 100
KHHexadecimalKH 00FFHex 00FF = 255
KMBit pattern (16 bits)KM 1111 0000 1111 0000Binary mask
KCCharacter (2 chars)KC ABASCII "AB"
KTTimer valueKT 030.230 seconds
KZCounter valueKZ 100Count 100
KYTwo bytesKY 10,20Byte1=10, Byte2=20
KGFloating-pointKG +1.500+0031.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

InstructionWhat It Does
U / UNAND / AND NOT (bit logic)
O / ONOR / OR NOT (bit logic)
S / RSet / Reset (latch)
=Assign VKE to operand
L / TLoad into ACCU1 / Transfer ACCU1 to address
+F / -FInteger add / subtract
!=F / >F / <FCompare equal / greater / less
SPB / SPBNJump if true / Jump if not true
SPAJump unconditional
SD / SA / SI / SE / SSTimer types
ZV / ZRCount up / Count down
A DBOpen data block
BEBlock end
NOP 0No 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

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.