S5 AWL Command: A DB (Open Data Block)
S5 AWL instruction A DB: Opens a data block for subsequent DW/DL/DR/D access. The DB stays open until another A DB is called.
S5 AWL Command: A DB (Open Data Block)
A DB opens a data block for subsequent data access. All DW, DL, DR, and D instructions after A DB refer to the opened block. The DB stays open until another A DB instruction is executed or the block ends.
Syntax
A DB 10 // Open data block DB10
L DW 5 // Load word 5 from DB10
T MW 20 // Store in marker word
S7 Equivalent
| S5 AWL | S7 STL | S7 SCL |
|---|---|---|
A DB 10 | OPN DB 10 | Not needed — use DB10.DBW10 directly |
S7 advantage: In S7, you can access data blocks directly without opening them first: L DB10.DBW10. The OPN instruction still exists for compatibility but is rarely used in new code.
Critical Behavior: DB Stays Open
A DB 10 // DB10 is now open
L DW 0 // Reads DB10.DW0
... // 50 lines of code later...
L DW 5 // STILL reads from DB10!
...
SPA FB 20 // FB20 may open a DIFFERENT DB internally!
L DW 3 // WARNING: Which DB is open now? Not necessarily DB10!
The trap: If a called FB opens its own DB, the originally opened DB is replaced. After returning from the FB, the "current DB" may not be what you expect. This is the most common DB-related bug in S5 programs.
S7 solution: Always use fully qualified access (DB10.DBW10) instead of relying on the "current DB" concept. This eliminates the entire class of bugs.
Common Patterns
// Read from one DB, write to another
A DB 10
L DW 5 // Read from DB10
A DB 20 // Now DB20 is open (DB10 is "closed")
T DW 3 // Write to DB20
Related: Data Block Address Mapping — The ×2 rule for DW→DBW conversion
Part of the S5 AWL Command Reference. Maintained by PLCcheck.ai.
Analyze Your S5 Code Automatically
PLCcheck Pro reads your complete S5 AWL program and explains every instruction — including this one — in plain language. Upload your code and get instant documentation, S7 equivalents, and migration guidance.
Upload S5 code for free analysis → | S5→S7 Migration Guide →
Related Articles
Understanding S5 Data Blocks (DB0, DB1, DX0) in S7
What are S5 system data blocks DB0, DB1, and DX0? Why they exist, what they contain, and how to handle them during S5 to S7 migration.
10 min read
plc-documentationReading 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
migration-guideThe Siemens S5/S7 Converter Tool: What It Does and What It Doesn't
Honest assessment of the Siemens STEP 7 S5→S7 conversion tool. What it converts automatically, what it cannot handle, common errors, and how to deal with the remaining 20–40% that requires manual work.
12 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.