Learning STEP 5: Program Structure, OBs, Memory, and Instruction Set
STEP 5 is the Siemens programming environment for the SIMATIC S5 family of programmable logic controllers. The S5 line entered service in 1979 and remained in volume production through the mid-1990s, and tens of thousands of machines in the field still depend on it. This reference consolidates the architecture, block model, memory map, and instruction set you need to read, write, and troubleshoot STEP 5 programs. Every section ends with a verification step you can run on a physical PG (programmer) or in the S5-DOS/Windows simulator.
1. STEP 5 and SIMATIC S5 Architecture
STEP 5 is the engineering software; SIMATIC S5 is the PLC family. The CPU you target determines memory size, block count, and instruction support. Memorize the CPU class because every block, address, and timing parameter is qualified by it.
| CPU class | Typical memory (code/data) | Timers | Counters | Flags | Block count (code) |
|---|---|---|---|---|---|
| S5-90U | 4 KB | 32 | 32 | 256 bits | OB+PB+FB+SB ≤ 64 |
| S5-95U | 4 / 8 / 16 KB | 32 | 32 | 512 bits | up to 128 |
| S5-100U (CPU 100/102/103) | 2 / 4 / 8 KB | 32 | 32 | 256 bits | up to 64 |
| S5-115U (CPU 941/942/943/944/945) | 24 / 48 / 96 / 192 / 256 KB | 128 / 256 | 128 / 256 | 2048 bits | up to 1024 |
| S5-135U (CPU 928/928B/948) | 64 KB – 2 MB | 256 | 256 | 2048 bits | up to 2048 |
| S5-155U (CPU 946/947) | 128 KB – 2 MB | 256 | 256 | 2048 bits | up to 4096 |
STEP 5 itself was shipped in many versions; the last DOS-based release is STEP 5 V7.2 (file set 6ES5 894-7MA02, 6ES5 894-7MA03), with a Windows port under DOS/Win. Programming devices supported range from the PG 685 (CP/M-86) through the PG 720, PG 740, PG 760, and Field PG with the AS 511 serial interface or the SINEC L2 interface module (CP 521, CP 524, CP 5431).
2. Prerequisites: Hardware, PG, and Cable Setup
- Programming device (PG). Any PG running STEP 5 V6.x or V7.x, or a modern PC with a USB-to-RS232 adapter plus the AS 511 protocol stack from S5Tools/SIMATIC S5 for Windows.
- AS 511 cable (TTY or RS232). The 6ES5 734-1BD20 TTY cable is the original; 6ES5 734-1BD60 and 6ES5 734-1BF20 cover RS232. Modern equivalents use the IBH Link S5 / S5-LAN gateway (not Siemens, used as a field bridge) but the protocol payload is the documented Siemens AS 511.
- STEP 5 media kit. 3.5" floppy or downloaded archive. Mount the “Basic” disk and the “Optional” disk with the ‘F’ drives mounted for source files.
- Online connection to the PLC. Confirm the S5 CPU is in STOP before connecting. The PG can cold-start the PLC after link setup.
3. Installing STEP 5 and Project Setup
- Insert the STEP 5 installation floppy set. Run
INSTALL.EXEfrom Disk 1. - Accept the default install path
C:\STEP5and choose your target S5 family (90U/95U/100U/115U/135U/155U). The installer writes different runtime DLLs per family. - After install, launch
S5.EXE. The Project Manager shows available EXE files, S5D containers, and ST.S5D source files. - Create a new project:
File → New → Program file. STEP 5 stores the active program in a binary EXE file plus source ST.S5D in the S5D container. - Set the target CPU under Settings → CPU type so the editor enforces the correct block and address range.
Verify: open File → Project info and confirm CPU family, total code memory, free memory, and revision number of the loaded S5.EXE matches the in-PLC CPU (PIQ/SFZ output via PLC → Operating state → Module information).
4. Program Block Architecture (OB, PB, FB, DB, SB, FX)
STEP 5 uses a strict block model. The CPU scans OB1 cyclically and that block (or its child calls) drives the rest of the program. Knowing what each block is for is half the battle.
| Block | Full name | Purpose | Calling mechanism |
|---|---|---|---|
| OB | Organization block | System interface: cyclic, restart, time-of-day, hardware interrupt, error handler | Called by the operating system |
| PB | Program block | User program, structured by function (e.g. PB 10 = valve sequencing) | Called from OB1 or other PBs via JU/JC PB n |
| FB | Function block | Reusable code with parameter list, local bit memory (F 0.0–F 255.7), and timing | Called via JU FB n with parameter assignment |
| DB | Data block | Word-oriented data area (DW 0–DW 255), 16 bits per word | Activated by CDB (or implied inside FB) |
| SB | Sequence block | Step/transition logic for the GRAPH 5 sequencer | Called from GRAPH 5 or OB1 |
| FX | Extended function block | FB with extended parameter set; used on 135U/155U with COM 115/155 FBs | Same as FB, larger parameter footprint |
Block numbers are 0–255 by default, expanded to 0–4095 on 155U. A block is uniquely identified by number and type: PB 17 differs from FB 17.
5. Memory Model and Address Allocation
The S5 memory is split into the same eight areas used by every Siemens PLC since the S3 era. The PG presents them as operands in STL, LAD, and CSF.
| Operand | Size | Access granularity | Range (S5-115U, typical) | Notes |
|---|---|---|---|---|
| I (inputs / process input) | 128 to 1024 bytes | bit, byte, word, double word | I 0.0 – I 127.7; IB 0, IW 0, ID 0 | PI (process image) is loaded each scan; direct I access via PIB/PIW/PID bypasses the image |
| Q (outputs) | 128 to 1024 bytes | bit, byte, word, double word | Q 0.0 – Q 127.7; QB 0, QW 0, QD 0 | PQ (peripheral output) writes directly to the bus |
| M (flags / Merkers) | 256 to 4096 bits | bit, byte, word, double word | M 0.0 – M 255.7; MB 0–MB 255; MW 0–MW 254; MD 0–MD 252 | Retentive flags configured via the system data word SD |
| T (timers) | 0 – 255 (CPU dependent) | word (current time, BCD 0.0–999.0 s) | T 0 – T 255 | TI (timer current value) and T (binary coil) views |
| C (counters) | 0 – 255 (CPU dependent) | word (current count, BCD 0–999) | C 0 – C 255 | CI (counter current value) and C (binary coil) views |
| D / DW (data words) | 0 – 255 per DB | word, double word, bit within a DW | DW 0 – DW 255; DD 0, DR 0 | Bit addressing inside a DW: D 5.7 = bit 7 of DW 5 |
| L (local data) | Stack frame, FB-dependent | bit, byte, word | L 0.0 – L 63.7 per call | FB local stack, not retained between calls |
| F (flags inside FB) | 256 bits per FB | bit, byte, word | F 0.0 – F 255.7 | Static, like M but scoped to the FB instance |
Address overlap rules: bit, byte, word, and double-word views share the same physical memory. MW 4 = MB 4 (high byte) + MB 5 (low byte). Always step word addresses by 2 to avoid straddling. There is no endian setting; Siemens S5 is little-endian with the low byte at the higher address.
6. Programming Languages: STL, LAD, and CSF
STEP 5 supports three source representations that share the same executable code.
- STL — Statement List (AWL). Mnemonic, machine-close. Used by service engineers for diagnostics, force workarounds, and patches. This is the canonical learning path because the STL-to-MC5 mapping is one-to-one.
- LAD — Ladder Diagram (KOP). Graphical, contact/coil. Best for digital logic and discrete I/O mapping.
- CSF — Control System Flowchart (FUP). Function-chart style, ideal for boolean and arithmetic block networks.
You toggle languages on a per-block basis: Editor → Presentation → STL/LAD/CSF. The internal representation is MC5 (machine code 5), a 16-bit 24-byte instruction. STEP 5 stores MC5 plus symbol and source comments in the ST.S5D file; the EXE file holds pure MC5 plus block headers.
7. Basic Bit Logic and Standard Instructions
The STL instruction set is compact. The table below lists the operations you will use in 90 % of service work.
| Instruction | Operands allowed | Function |
|---|---|---|
| A | I, Q, M, T, C, D | AND — contact closes when operand = 1 |
| AN | I, Q, M, T, C, D | AND NOT — contact closes when operand = 0 |
| O | I, Q, M, T, C, D | OR — parallel branch closed when operand = 1 |
| ON | I, Q, M, T, C, D | OR NOT |
| X / XN | I, Q, M, T, C, D | Exclusive OR / XOR NOT |
| = | Q, M, D | Assign RLO to operand (single-shot assignment) |
| S / R | Q, M, C | Set / Reset (latching) |
| SI / RI | I (input, immediate) | Direct read (bypasses process image), useful for fast signals |
| P / N | any bit | Positive / negative edge (single-cycle pulse) |
| JU / JC | PB, FB, OB, SB, FX, label | Jump unconditional / conditional on RLO = 1 |
| JZ / JN | label | Jump if accumulator zero / not zero (after math or compare) |
| JP / JM | label | Jump if positive / negative (after signed compare) |
| SLW / SRW / SLD / RRD | constant 0–16 | Shift left word / right word / double word / rotate right double |
| C | DB | Call data block (e.g. C DB 10) |
| CDB | none | Close currently open DB |
Example: a latched motor starter with overload trip.
FB 12
NAME : MOTOR_START
U I 1.0 // Start pushbutton
UN I 1.1 // Stop pushbutton (closed contact)
UN I 1.2 // Overload relay
O M 12.0 // Seal-in contact
S Q 2.0 // Contactor
UN I 1.0
UN I 1.1
R Q 2.0
U I 1.2
= M 12.1 // Fault flag
Verify: load to the PLC (PLC → Download), switch to RUN, monitor block in Status (F8). All operand states should change in real time as you toggle inputs.
8. Timers, Counters, and Edge Detection
STEP 5 has 256 timer/counter words in 115U, fewer in 95U/100U. The time/count value is BCD 0–999 in the upper 12 bits of the word; the lower 4 bits are the binary time-base or ×0.01, ×0.1, ×1, ×10 seconds.
| Instruction | Function | Use |
|---|---|---|
| SP T n | Start pulse (one-shot, time-base governed) | Indicator flash, fixed on-time |
| SE T n | Start extended pulse (re-triggerable) | Lamp on while button held, plus a minimum on-time |
| SD T n | Start on-delay | Process start delay (e.g. star-delta) |
| SS T n | Start stored on-delay (latches until R) | Total runtime accumulator, service interval |
| SF T n | Start off-delay | Fan cool-down, lamp hold after stop |
| R T n | Reset timer and clear word | Cancels running timer |
| CU C n | Count up (input edge) | Piece counter, increment |
| CD C n | Count down (input edge) | Remnant, decrement |
| S C n | Set counter to value in ACCU 1 | Pre-load counter |
| R C n | Reset counter and clear word | Zero counter |
Example: 5-second on-delay to start a pump.
U I 5.0 // Start request
L KT 050.1 // 5.0 s (KT = constant time, KT 050.1)
SD T 17 // On-delay, timer 17
U T 17 // Timer done
= Q 4.0 // Pump contactor
Edge detection uses FP (rising edge) and FN (falling edge) flag patterns:
U I 6.0
FP M 20.0 // M 20.0 is the edge memory bit
= M 20.1 // One-scan pulse on rising edge
Verify: open Status in the timer/counter word view (View → Current values) and watch the value decrement in real time. For edge flags, use Status with RLO to confirm the pulse width is exactly one OB1 scan.
9. Organization Block (OB) Reference and Use Cases
OBs are the OS-to-application interface. The CPU calls them based on the listed trigger; you supply the program.
| OB | Trigger | Default use |
|---|---|---|
| OB 1 | Cyclic, end of process image | Main scan; always present |
| OB 2 | Triggered by interrupt input (digital) | Fast input response < 1 ms |
| OB 3 / OB 4 / OB 5 | Time-based interrupts (selectable, 10 ms–1 min) | Time-of-day-driven tasks |
| OB 10 | Time-of-day 0:00 | Daily job |
| OB 11 | Time-of-day 1:00 (or configurable) | Hourly job |
| OB 12 – OB 18 | Time-of-day 2:00 – 8:00 (configurable) | Shift-related tasks |
| OB 21 / OB 22 | Manual / automatic warm restart | Initialize data, re-enable outputs |
| OB 31 – OB 39 | Time-of-day interrupts (1–99 h) | Long-period maintenance flags |
| OB 40 – OB 47 | Hardware interrupt (interrupter module / IP 240) | Event-driven acquisition |
| OB 60 | Stop completion | Clean up before STOP |
| OB 121 | Substitution error (CPU detected illegal MC5) | Default: STOP, override possible |
| OB 122 | Peripheral access error (IM/CP unreachable) | Default: STOP, override possible |
| OB 200 / OB 202 | PG stop / restart | Informational, mostly unused |
| OB 250 | Error in PIQ error handler | Diagnostic |
The S5 does not scan OBs the way a S7 scans OB1+OB35+OB82. Each OB is only entered if it exists in the EXE file; otherwise the OS executes the system default (typically a no-op or a STOP). Loading an OB121 with an empty body allows the PLC to continue on substitution errors instead of stopping.
Verify: insert BE (block end) only in OB1; never call OB1 from itself. Use Reference data → Cross-reference → Block call structure to see which OBs the program uses.
10. Data Blocks, Word Operations, and Indirect Addressing
DBs hold 16-bit words. Open a DB with A DB n (or C DB n in 115U) and read with L DW k, write with T DW k. The bit access D x.y works only when a DB is open.
C DB 50
L DW 10 // Load recipe word 10 into ACCU 1
L KH 03E8 // Load constant 1000 (hex)
<F> // Compare < in the editor
JC FB 200 // If recipe < 1000, call alarm FB
Indirect addressing on a DB word:
L KB 17 // Constant byte 17
T MW 100 // Use as index
L DW [MW 100] // Indirect read of DW 17 in current DB
Verify: launch Test → Data block display, set Format to KH (hex), KF (fixed-point), or KT (time), and step through DW 0 to DW 255. Save the displayed DB to disk and diff against the previous commissioning baseline.
11. Online Functions: Status, Control, Force, and Commissioning
When the PG is online (AS 511 or SINEC L2), the following operations are available from PLC → ...:
- Status (F8). Live operand view; Status with RLO highlights which path of the STL is active.
- Control (F9). Modify outputs, flags, timers, and counters one shot at a time. Range-checked; illegal writes are rejected.
- Force. Pin a bit to a value; CPU ignores program writes to that bit until force is released. Use with extreme caution on safety circuits.
- Compress. Reclaims deleted-block space in EXE. Run after major block deletion.
- Memory reset (MRES). Cold image reload; clears all flags/timers/counters and non-retentive data.
- Block comparison. PG ↔ PLC diff for verification after upload.
- Documentation. Save ST.S5D, symbol table, and reference data with Project → Document → Save all.
Verify: after upload, run PLC → Compare → PG ↔ PLC for every block type and confirm the “identical” status for OB/PB/FB/DB.
12. Migration Path to STEP 7 / TIA Portal
While the focus here is learning STEP 5, every green-field S5 migration uses the S5 → S7 converter that ships with STEP 7 V5.x (Start → SIMATIC → STEP 7 → S5 → S7 Converter). The converter:
- Reads the S5 EXE and ST.S5D,
- Maps I, Q, M, T, C, DW to S7 I, Q, M, T, C, DB operands,
- Translates STL to S7 STL with extension comments,
- Flags unsupported FB calls (e.g. analog FB 250 on 155U) for manual rework.
For TIA Portal (V14+), S5 programs are not natively imported. The accepted workflow is: STEP 5 → STEP 7 V5.x → STEP 7 V5.5 (final S7-classic) → TIA Portal via “Migrate project”. Hardware conversion goes S5-115U → S7-300, S5-135U/155U → S7-400 or ET 200SP with PROFINET.
13. Verification and Common Errors
After writing any STEP 5 program, walk this checklist:
- Block list shows every PB/FB/DB/OB you expected. No stray “???” placeholders.
- Cross-reference shows each operand used and the blocks that touch it. Look for uninitialized flags (M 100.0 written but never read, or read before write).
- Compare PG ↔ PLC after every download.
- Status with RLO for OB1 confirms the cyclic scan is reaching the last statement in < 50 ms (S5-115U) or < 200 ms (S5-135U for a heavy program).
- Diagnostic buffer (Status word / ISTACK) on the CPU shows no OB121/OB122 trips during a full 24-hour soak.
| Symptom | Likely cause | First action |
|---|---|---|
| CPU in STOP, “SUBST ERROR” in ISTACK | OB121 not loaded; illegal MC5 hit | Load an empty OB121 to enable error-tolerant scan, then read ISTACK for faulting MC5 address |
| Outputs do not energize despite Q 2.0 = 1 in status | PIQ not refreshed (Q and PQ confused); or output module pulled | Replace = Q 2.0 with S Q 2.0; or write via T PQW 0
|
| Timer never decrements | Time base wrong; or two timers share T n | Check KT 005.1 format; cross-reference T 17 |
| PG cannot go online | Wrong interface (TTY vs V.24); baud mismatch | Check AS 511 cable pinning: pin 4 = +24 V sense, pins 2/3 crossed, pin 7 ground; CPU in STOP |
| “Address beyond operand area” | CPU family mismatch in project setup | Re-target “CPU type” in Settings, then recompile and reload |
14. Field-Proven Tips
- Comment every block header and every network. STEP 5 comments live in ST.S5D; they are stripped from EXE on download, so always save the source.
- Use a symbol table (Symbols → Edit) for every I/O, and let the editor substitute
I 1.0↔MOTOR_START_PB. The symbol table is portable and survives project moves. - Use FB parameter names (
FB 12: MOTOR_START) so the same FB can be called with different DBs (instance DBs) on 115U/135U. This is the closest S5 equivalent to an FB instance in STEP 7. - Back up the entire project (EXE + S5D + symbol table + reference data) weekly. S5 file sets are small (a few MB even for large projects); loss of ST.S5D is irrecoverable once the original PG is gone.
FAQ
Where do I download the official STEP 5 manual?
The primary learning manual is the STEP 5 Programming Manual (6ES5 998-0MA24) on Siemens Industry Online Support. Additional manuals are listed at support.industry.siemens.com under SIMATIC S5 → STEP 5 → Manuals.
What is the difference between OB, PB, FB, and DB in STEP 5?
OB (organization block) is called by the operating system; PB (program block) and FB (function block) hold user code; DB (data block) stores 16-bit data words. OBs and PBs run in OB1's scan; FBs keep local flags (F) and can be called with parameter lists; DBs are addressed only when opened with A DB n or C DB n.
How do I check whether a STEP 5 timer counts correctly?
Open Status on the timer word and switch the format to KT (constant time). The high 12 bits show the BCD current value and the low 4 bits show the time base (0=10 ms, 1=100 ms, 2=1 s, 3=10 s). The time must decrement in real time and the timer's binary coil (T n) must go to 1 at zero.
Can I keep an S5 program running indefinitely on a new machine?
Yes, but with a documented obsolescence plan. S5 spare parts, repair services, and firmware updates are no longer under active development at Siemens. For new lines, design on SIMATIC S7-1500 / TIA Portal and use the S5-to-S7 converter in STEP 7 V5.x as a transition tool.
What is the simplest way to force an output from a PG for testing?
With the CPU in RUN, open PLC → Force, enter the bit address (for example Q 2.0) and the desired state. Confirm the safety checklist (see Force safety rule above) and the output bit will stay at the forced value until released. Use Force → Delete all to clear every force at once.