Learn PLCs free
Data Types & VariablesIntermediateImportant
6 min read
Updated
Intermediate

Siemens PLC Data Block: Global DB vs Instance DB

DB - Data Block

Quick answer

A Siemens data block (DB) is a typed memory block. A global DB stores shared project data; an instance DB stores the static state and interface data for a specific function-block instance. It is not executable code.

Key Takeaways

  • A Siemens data block (DB) is a typed memory block. A global DB stores shared project data; an instance DB stores the sta...
  • Intermediate-level topic in Data Types & Variables
  • Commonly used in: Machine configuration and recipe structures, Function-block instance state
  • Related to: Structure, Pointer, BOOL

Detailed Definition

A data block is a Siemens STEP 7/TIA Portal program object that stores structured values. A global DB is directly available to the user program and is suitable for data shared across program parts. An instance DB belongs to an FB call and stores that instance’s static variables, parameters and internal state. Multi-instances embed one FB instance inside another instance DB.

Good DB design uses named structures and PLC data types rather than unrelated flat tags. Ownership matters: shared writable data can become difficult to diagnose when many blocks modify it. Retentivity, start values, actual values, optimized access, external HMI access and recipe persistence are independent design decisions that must be documented and tested.

Evidence and scope

The global and instance data-block model was checked against Siemens programming guidance for S7-1200/1500. Optimized access, retain settings, download initialization and online-change behavior depend on CPU generation, TIA Portal version and project configuration.

Technical review:

IEC 61131 data model showing typed variables shared across program organization units
Editorial illustration: typed data contracts make ownership and interfaces visible
PLC variable-scope diagram comparing local, instance and global data visibility
Editorial illustration: use the narrowest scope that supports the required consumer

Critical behavior

  • Global DBs are shared data; instance DBs contain the persistent state of one FB instance.
  • A DB is not a subroutine and does not execute. Logic in OBs, FBs and FCs reads or writes its data.
  • Start values, online actual values and retained values are different concepts during download and restart.
  • Optimized block access can change addressing and external-access assumptions; symbolic access is preferred.
  • Copying or reinitializing an instance DB can also copy or reset hidden timer, edge and sequence state.

Verification checklist

  1. 1Classify every DB as global, single-instance or multi-instance.
  2. 2Assign one owner for each writable shared structure and document external clients.
  3. 3Test cold restart, warm restart, download and initialization with non-default values.
  4. 4Verify symbolic HMI/OPC access after compiling optimized blocks.
  5. 5Archive PLC data types and DB interface versions with the program release.

IEC and vendor terminology

Similar-looking instructions do not always have identical execution, initialization or storage behavior.

PlatformCommon termWhat to verify
Siemens global DBGlobal data blockStructured data accessible by multiple program blocks; assign a clear writer/owner for each field.
Siemens FB callInstance DBStores parameters, STAT variables and internal state for one FB instance.
Siemens FB hierarchyMulti-instanceStores child FB instances inside the parent instance DB to reduce separate DB objects.
Other IEC platformsGlobal variable list / FB instanceSimilar data ownership concepts exist, but the Siemens DB object and access settings are platform specific.

Global and instance DB ownership

Instance state stays with the FB instance; deliberately shared configuration lives in a named global contract.

Which Siemens data block should own the value?

Choose ownership before choosing a DB name or address.

State / phaseBest ownerTypical lifetimePrimary risk
Shared machine setpointTyped global DBProject / retained if justifiedUncontrolled writes from many blocks
One pump sequence statePump FB instance DBAcross scans; restart per designState copied or reset unexpectedly
Temporary calculationBlock TEMP/local variableOne executionMistaken expectation of persistence
Child valve instanceParent FB multi-instanceParent instance lifetimeInterface hidden by deep nesting
HMI exchange structureDedicated typed global DBDefined by interface contractOptimized/external access mismatch
DB architecture is a data-ownership decision first and a memory-layout decision second.
Program organization unit diagram connecting programs, function blocks, functions and stored data
Editorial illustration: data blocks support executable POUs but do not execute themselves
PLC task execution diagram showing when blocks read and write shared data
Editorial illustration: task order is part of the contract when multiple writers exist

Working LD and ST example

Use a typed global configuration with instance-owned state

Keep shared setpoints separate from the state of each reusable equipment module.

Ladder Diagram

|----[ CALL FB_Pump, DB_Pump101 ]--------------------------------|
|       Enable := DB_Config.AutoEnable                            |
|       StartLevel := DB_Config.Pump101.StartLevel                 |
|       Level := TankLevel       Running => Pump101Running          |

Structured Text

Pump101(
    Enable     := DB_Config.AutoEnable,
    StartLevel := DB_Config.Pump101.StartLevel,
    StopLevel  := DB_Config.Pump101.StopLevel,
    Level      := TankLevel,
    Running    => Pump101Running,
    Faulted    => Pump101Faulted
);

// Pump101 state belongs to DB_Pump101.
// Shared, reviewed setpoints belong to DB_Config.

Expected result: A second pump can reuse FB_Pump with a separate instance DB while both consume a controlled, typed configuration structure.

Structured Text function-block boundary separating inputs, outputs and persistent internal state
Editorial illustration: an instance DB preserves the state behind a reusable FB interface
Scan contract mapping input snapshot, logic execution, stored state and output publication
Editorial illustration: restart and download tests must include stored state as well as ordinary I/O

Failure modes and diagnostic checks

SymptomLikely causeCheck next
Values revert after downloadStart values, actual values and retain settings were misunderstood.Run a documented download and cold/warm restart matrix with representative values.
Timer or edge state behaves unexpectedlyThe FB instance DB was recreated, copied or initialized.Inspect the instance relationship and every initialization path.
HMI cannot browse or write a memberExternal-access or optimized-access settings do not match the communication path.Test symbolic access using the actual HMI/driver and compiled project.
A value changes with no obvious writerSeveral blocks, HMI scripts or communications clients write the global field.Use cross-reference and access protection; assign one owner and request interface.

Current primary and technical sources

These sources support the behavior summarized on this page. The project's controller, firmware and IDE help remain authoritative for implementation.

Continue with the practical guide

Common Questions

What is Data Block?

A Siemens data block (DB) is a typed memory block. A global DB stores shared project data; an instance DB stores the static state and interface data for a specific function-block instance. It is not executable code.

When should I use Data Block?

Data Block is particularly useful in scenarios such as Machine configuration and recipe structures and Function-block instance state. Consider implementing it when you need reliable, efficient solutions for these types of applications.

What should I verify before using Data Block?

Classify every DB as global, single-instance or multi-instance. Assign one owner for each writable shared structure and document external clients. Test cold restart, warm restart, download and initialization with non-default values. Verify symbolic HMI/OPC access after compiling optimized blocks. Archive PLC data types and DB interface versions with the program release.

What are related concepts I should learn?

To fully understand Data Block, you should also familiarize yourself with Structure, Pointer, and BOOL. These concepts work together in industrial automation systems.

Was this helpful?

Let us know if this glossary term helped you understand Data Block better.

Your feedback helps us improve our glossary and create better content for the PLC programming community.

Quick Info

Difficulty
Intermediate
Tier
Important

About Data Types & Variables

Data structures, variable types, and memory organization

Total Terms:30
Difficulty:Beginner to Intermediate

Free PLC simulator

Stop reading, start doing

Write ladder logic in your browser, hit Run, and watch machine scenarios react. A 12-lesson curriculum across 8 PLC dialects — free account, no credit card.

Practice PLCs free →