S7-1200 Data Block Programming in TIA Portal V13: Access and Size

David Krause13 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

S7-1200 Data Block Programming in TIA Portal V13: Storage, Access, and Size

1. Overview: Purpose of a Data Block (DB) in STEP 7 V13

A Data Block (DB) in TIA Portal V13 (STEP 7 Basic V13 / Professional V13) is a globally accessible memory area on the S7-1200 or S7-1500 CPU that stores user data structured as fixed or variable tags. Every cell inside a DB is a global memory location that can be read and written from:

  • User program code (OB, FB, FC, other DBs)
  • Watch / Monitor tables (VAT)
  • HMI / SCADA tags (WinCC, HMI Panels, third-party OPC UA clients)
  • Web server of the CPU (S7-1200 firmware V4.0 and later)
  • Data log / recipe functions that bind to DB tags

For S7-1200, the relevant firmware range when working with TIA Portal V13 is CPU firmware V4.0 to V4.2. S7-1500 projects in TIA Portal V13 update 6+ target firmware V1.5 to V1.8. Refer to the SIMATIC S7-1200 Programmable Controller System Manual and the SIMATIC S7-1500 Programmable Controller System Manual for the exact CPU and firmware compatibility matrix.

Compatibility reminder: TIA Portal V13 (released 09/2014) and V13 SP1 (03/2015) are legacy versions. Projects saved in newer TIA Portal versions (V15, V16, V17, V18, V19) cannot be opened in V13. Use TIA Portal V13 only when matching legacy hardware or when a specific firmware lock is required.

2. Prerequisites

  1. Installed and licensed TIA Portal V13 / V13 SP1 / V13 SP1 Update 4..9 with STEP 7 Basic (for S7-1200) or STEP 7 Professional (for S7-1200 + S7-300/400/WinAC).
  2. Configured CPU: S7-1212C, S7-1214C, S7-1215C, S7-1217C, S7-1500 (any variant) with matching device version in the hardware catalog.
  3. Programming device IP reachable to the CPU (default PROFINET subnet 192.168.0.1/24, CPU default 192.168.0.1).
  4. Project created: Project → New → Name → Add new device → Controllers → SIMATIC S7-1200 → CPU → specific article number.

3. The Three DB Types in TIA Portal V13

Type Symbol Optimized Typical Use
Global DB (instance-free) Standard / Optimized Yes (S7-1500 default) / No (S7-1200 default) Recipes, setpoints, machine parameters, status words
Instance DB Tied to a FB Inherits from FB Static working data of a function block (motor, valve, axis)
System / Array DB System-defined No Generated by the system for diagnostics or libraries (e.g., Motion Control technology DBs)

For S7-1200 firmware V4.0 to V4.2 in TIA Portal V13, optimized block access is supported but is not the default. Right-click the DB in the project tree, choose Properties → Attributes, and clear the Optimized block access checkbox if you need the classic offset column.

4. Creating a Data Block

4.1 Path to create a Global DB

  1. In the project tree, expand PLC_x [CPU 1214C DC/DC/DC].
  2. Expand Program blocks.
  3. Double-click Add new block (or right-click → Add new block).
  4. Select type Data block (DB).
  5. Set the name (e.g., DB_MachineData). The number is auto-assigned; it can be forced to a specific number (1..65535) by typing the value, provided the number is not already used by a system DB.
  6. Click OK. The DB editor opens in the declaration view.
DB number range: User DBs occupy 1..65535. S7-1200 reserves DB 0 and a small range around it for system use. The first user DB you create is typically DB 1. S7-1500 in TIA Portal V13 also allows symbolic-only DBs that do not consume a fixed numeric slot until compile.

5. Declaring Variables in the DB

5.1 The declaration table

When the DB opens in declaration view, you see columns:

Column Purpose Editable
Name Symbolic name of the tag (e.g., i_Setpoint) Yes
Data type BOOL, INT, REAL, STRING, ARRAY, STRUCT, UDT, etc. Yes (dropdown)
Offset Absolute byte.bit position in the DB No (auto)
Initial value Value loaded on CPU restart (cold/warm) Yes
Retain Yes / No — survives power cycle Yes
Comment Free text for documentation Yes

5.2 Adding a row

Click an empty row, type a name (must not start with a digit, must not be a reserved keyword such as TRUE, FALSE, VOID). Press TAB, choose the data type, press TAB, set the initial value, press Enter. The Offset column auto-fills after compile.

5.3 Data type sizes (S7-1200 / S7-1500)

Data type Size (bytes) Range / notes
BOOL 1 bit packed 0 or 1; 8 BOOLs occupy 1 byte
BYTE 1 0..255 / B#16#00..B#16#FF
WORD 2 Unsigned 16-bit
DWORD 4 Unsigned 32-bit
SINT 1 -128..+127
USINT 1 0..255
INT 2 -32768..+32767
UINT 2 0..65535
DINT 4 -2147483648..+2147483647
UDINT 4 Unsigned 32-bit
REAL 4 IEEE 754 single
LREAL 8 IEEE 754 double
CHAR 1 Single ASCII character
STRING[n] n + 2 n = 0..254
DTL 12 Date and time long (year..nanosecond)
TOD (TIME_OF_DAY) 4 Midnight to 23:59:59.999
DATE 2 Days since 1990-01-01
ARRAY[lo..hi] of type size_of(type) × count Static size, 1-D or multi-D
STRUCT sum of members + alignment Composite type

5.4 Sample declaration

Name Data type Initial value Retain Comment
i_SetpointRPM INT 1500 Yes Motor target speed
r_ActualFlow REAL 0.0 No Live process value
b_StartCmd BOOL FALSE No HMI start button
b_Running BOOL FALSE No Drive feedback
w_StatusWord WORD 16#0000 No Bit-packed status flags
a_Recipe[0..9] ARRAY[0..9] of REAL 10(0.0) Yes 10 recipe slots
s_Operator STRING[32] '' No Logged-in user

6. Accessing DB Variables in the Program

6.1 Symbolic (fully qualified) access

TIA Portal V13 strongly encourages symbolic access. The syntax is:

"DB_MachineData".i_SetpointRPM := 1750;
"DB_MachineData".a_Recipe[3] := 42.5;
IF "DB_MachineData".b_Running THEN
    "DB_MachineData".r_ActualFlow := "DB_MachineData".r_ActualFlow + 0.1;
END_IF;

The double-quoted names are case-sensitive. If you rename the DB or the tag, the compiler updates all references automatically.

6.2 Absolute access (legacy, standard-access DBs only)

For a non-optimized DB, each tag has a fixed offset. The absolute form uses DB number + byte.bit:

OPN   DB    1                         // open DB1 (standard access)
L     DBW   0                         // load INT at offset 0.0
T     MW    100                       // copy to work memory
A     DBX   4.0                       // check BOOL at offset 4.0
=     M10.0

For non-optimized DBs the format is DB1.DBW0 in SCL/ST and DB1.DBX4.0 in LAD/FBD. Absolute access is not available on optimized DBs — the compiler reports a syntax error.

6.3 Slice and view access

For a WORD tag, individual bits can be sliced without copying:

"DB_MachineData".w_StatusWord.%X0   // bit 0
"DB_MachineData".w_StatusWord.%X7   // bit 7
"DB_MachineData".w_StatusWord.%B0   // low byte of the word

6.4 HMI access

In the HMI tag editor, choose PLC tag → Browse → Drill into the project tree → DB_MachineData → i_SetpointRPM. The HMI automatically gets the symbolic connection; no manual addressing is required. Acquisition cycle and limit values are configured per tag.

7. Fix: TIA Portal V13 Missing Address Column

A common complaint in V13 is that the Offset column is blank or not visible. The reasons are:

  1. The DB has not been compiled. Offsets are populated only after a successful compile. Press Ctrl + B or right-click the DB → Compile → Software (rebuild all). The Offset column fills after compile.
  2. The Offset column is hidden. Right-click any column header (Name, Data type, ...) and tick Offset. The column appears at the right of the table.
  3. The DB is optimized and access is symbolic-only. Optimized DBs do not expose a fixed offset. Right-click the DB → Properties → Attributes → Optimized block access → uncheck to switch to standard access (requires a rebuild of the program blocks).
  4. The view is wrong. Click the tab at the bottom of the editor: Declaration shows the table with offset; Data view shows the runtime values and the offset as read-only.
Tip: In TIA Portal V13, switching a DB between optimized and standard access is permitted but causes all absolute references elsewhere in the project to be invalidated. A full Compile → Software (rebuild all blocks) is required. Subsequent downloads to the CPU will clear the instance data area unless the DB is configured as Non-retain — i.e., retentive tags are reset to their initial value.

8. Determining the Size of a Data Block

8.1 From the project tree

  1. Right-click the DB → Properties → Information (or Size in the work memory tab on newer service packs).
  2. For V13 SP1 Update 4 and later the dialog reports the Length (bytes), the Length in MC7 (work memory), and the Length in load memory.

8.2 From the Online view

  1. Go online with the CPU.
  2. Project tree → right-click Program blocks → DB_MachineData → Online & diagnostics.
  3. The Information tab shows the DB number, Length, and Author / Last modified.

8.3 Manually computing the size

For a standard (non-optimized) DB, the size is the sum of declared tag sizes with byte alignment. With the sample table above:

  • i_SetpointRPM (INT): 2 bytes → offset 0.0
  • r_ActualFlow (REAL): 4 bytes → offset 2.0
  • b_StartCmd (BOOL): 1 bit → offset 6.0
  • b_Running (BOOL): 1 bit → offset 6.1
  • Padding: 1 byte → offset 7.0
  • w_StatusWord (WORD): 2 bytes → offset 8.0
  • a_Recipe[0..9]: 10 × 4 = 40 bytes → offset 10.0
  • s_Operator (STRING[32]): 34 bytes → offset 50.0

Total length = 84 bytes. The compiler pads BOOLs into the next free bit of the current byte; an entire byte is skipped if a multi-byte tag cannot fit.

8.4 Optimized DB size (V13)

Optimized DBs on S7-1200 firmware V4.0+ and S7-1500 add an internal symbol table and organize data by user-declared grouping. The runtime length is the same as the logical sum, but additional overhead (typ. 14–32 bytes) is added in the work memory and is not visible in the Offset column. Always check the Information tab in the DB properties for the exact value used by the resource planner.

9. Initial Values vs. Actual Values

State Where it lives When it is loaded
Initial value Project offline, in the DB declaration Loaded on STOP → RUN transition, on cold restart, on memory reset, and on download of the DB
Actual value Online, in CPU load memory after compile Retained across RUN/STOP, lost on cold restart (unless Retain = Yes)
Snapshot User-initiated, written to load memory Triggered by right-click → Snapshot of monitored values; persisted in the project for the next download

On S7-1200, retentive tags survive power cycle. The total retentive area is configured in CPU properties → Retain memory. Exceeding the area causes compile error Retain area overflow in V13. A typical CPU 1214C has 10 KB of retentive area covering MB, timers, counters, and DB tags marked as Retain = Yes.

10. Best Practices for TIA Portal V13 DB Design

  1. Use UDTs (User-Defined Data Types) for repeated structures (e.g., UDT_MotorAxis). A UDT is declared once, then instantiated as ARRAY[..] of UDT_MotorAxis inside a DB. Any change to the UDT propagates to all instances.
  2. Separate data by life cycle: DB_ProcessImage (non-retain, scan-time), DB_Recipes (retain, downloaded as needed), DB_Diagnostics (non-retain, overwritten on fault).
  3. Avoid BOOLs in standalone rows when a status word is more efficient. A WORD holds 16 flags and is faster to clear in one move.
  4. Use a STRUCT named Inputs / Outputs / Config / Status at the top of the DB — this becomes the HMI tag structure, allowing grouped visibility in WinCC.
  5. Always declare the same data type on both sides of a copy. Implicit conversion (e.g., INT := REAL) is allowed but generates a compile warning Type conversion possible loss of accuracy.
  6. Set Retain only for tags that must survive a power cycle. Excessive retain tags reduce usable work memory and slow startup.
  7. Reserve a "magic word" first tag, e.g., w_DBVersion : WORD := 16#A001. On startup the code can check the value and run a one-time migration if the version mismatches.

11. Verification After Programming

  1. Compile: Project tree → PLC_x → right-click → Compile → Software (rebuild all). The Output window must show 0 errors, 0 warnings for a clean build.
  2. Download: Right-click the device → Download to device → Software and hardware configuration. For S7-1200, accept the prompt to stop the CPU and load.
  3. Go online → Monitoring: Open the DB in Data view. Toggle Monitoring on/off. Initial values should appear as declared, then change as the program runs.
  4. Watch table test: Add a VAT, type "DB_MachineData".i_SetpointRPM, set a value with Modify → Once and now. Verify that the program or HMI sees the new value within one cycle.
  5. HMI round-trip: Bind an HMI tag to the DB tag, change it on the panel, confirm the online value updates and that the change persists across power cycle if Retain = Yes.

12. Troubleshooting Matrix

Symptom Likely cause Fix
Offset column blank DB not compiled, column hidden, or DB optimized Ctrl+B, right-click header → show Offset, or uncheck Optimized block access
Compile error: "Unknown tag" Typo in symbolic name; case mismatch Use Go to → Definition; verify double-quoted name spelling
Runtime value does not change DB opened with OPN DB and overwritten, or HMI acquiring with Continuous cycle Re-check write source; reduce HMI cycle to On change for read-only tags
Retain tags reset unexpectedly Memory reset, cold restart, DB downloaded with new initial values Configure Retain properly, use Snapshot before download, or use Recipe functions
"Retain area overflow" compile error Total retentive bytes exceed CPU limit Move large arrays to non-retain, or split into multiple DBs
HMI shows "--" or stale value PLC tag connection broken or DB optimized without symbolic HMI support Rebuild HMI connections; for S7-1200 V13, ensure DB is symbolic-accessible (default in V13 SP1+)
SCL: "Operand too complex" Multi-dimensional slice on optimized DB not supported Copy to a temporary variable first, then slice

13. Notes on Field-Proven Caveats in V13

  • V13 SP1 introduced the Software unit concept; for plain DBs the feature is not required but a unit must be assigned when the project structure uses units. An unassigned DB still compiles but triggers warning No software unit assigned.
  • The V13 portal sometimes loses the Monitoring toggle when an HMI connection cycles; reopening the DB re-establishes the live state.
  • Renumbering a DB in V13 invalidates any OPN DB n in older STL code; the renumber tool issues a warning and updates references automatically, but verify with a fresh compile.
  • The Cross-reference tool (Ctrl+Shift+F) shows every read and write of a tag, which is the fastest way to validate a DB is used correctly across OB1, FBs, and HMI screens.

14. FAQ

How do I see the absolute address (offset) of a tag in TIA Portal V13?

Compile the project (Ctrl+B), then open the DB in Declaration view. If the Offset column is missing, right-click any column header and tick Offset. For optimized DBs the column stays empty because the symbol table replaces fixed addresses; switch to standard access in DB properties if you need offsets.

How can I find the total size in bytes of a data block?

Open DB → Properties → Information (V13 SP1 Update 4+) for an automatic length, or sum the declared tags manually. The example DB above measures 84 bytes. Online, Online & diagnostics → Information shows the work-memory length used by the CPU.

Why does my DB show zero after a power cycle even though the tag has Retain = Yes?

Three possible reasons: (1) the tag was declared in an instance DB whose parent FB is not loaded as retentive, (2) the CPU retentive area is full and TIA Portal silently moved the tag to non-retain, or (3) a memory-reset was performed before the restart. Check the CPU Retain memory configuration and the diagnostic buffer entry Retain data lost.

Can I access DB tags from another DB in SCL?

Yes. Use the fully qualified symbolic name, e.g., "DB_MachineData".i_SetpointRPM := "DB_Recipes".a_Recipe[2];. The DBs must be in the same program block folder, or one of them must be globally marked as Accessible from all blocks (the default).

Is absolute access like DB1.DBW0 still supported in V13?

Yes, but only for non-optimized DBs. S7-1200 default DBs in V13 are non-optimized and therefore allow DB1.DBW0, DB1.DBX4.0, etc. S7-1500 in V13 prefers optimized blocks, where the only valid access is symbolic. Enable Show all addresses in the project tree settings to see the offsets of standard DBs.

Back to blog