Renaming TIA Portal FB Variables Without IDB Re-Download

David Krause12 min read
SiemensTechnical ReferenceTIA Portal
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

Problem Overview

Engineers working in TIA Portal V14 SP1 and later on S7-1500 CPUs (15xx series) frequently hit a wall when modifying Function Block (FB) static variables: a simple name change in the FB interface forces a re-initialization of the associated instance data block (IDB) on the next download. Because the IDB holds the runtime state of the FB, a re-initialization wipes every tag in that block, which in a live process means losing HMI faceplate values, sequencer states, recipe indices, integrator windup values, and PID controller internals. The plant either has to be brought to a safe state or a long, intrusive commissioning procedure has to be executed.

Engineers migrating from STEP 7 V5.x (classic) remember that this was not always the case. With absolute addressing on standard FBs, renaming a static in the FB header did not require the IDB to be re-initialized, provided the engineering trick of pre-allocating spare variables of generous size was used. TIA Portal preserves a similar capability, but the switch is hidden in the block properties of the source FB, not in the instance DB itself.

This article applies to S7-1500 CPUs and S7-1200 CPUs from firmware V4.0 onward, programmed with TIA Portal V13 SP1 / V14 / V14 SP1 / V15 / V15.1 / V16 / V17 / V18. Earlier S7-300/S7-400 controllers use the classic STEP 7 V5.x model and do not support the optimized-block access concept described below.

Root Cause: Optimized Block Access and IDB Inheritance

The reason renaming forces a re-download stems from how TIA Portal generates and verifies instance DBs. Every FB exposes its Block access property in the block properties dialog. The default value on a fresh S7-1500 FB created in TIA Portal is Optimized block access. With this option enabled, TIA Portal stores each static variable at a slot the compiler is free to relocate when the interface changes. The compiler writes the new layout, marks the IDB as structurally modified, and the next online download must re-initialize the block to populate the new memory layout.

The Download without reinitialization option in the load preview dialog, which is widely used to retain the contents of shared global DBs across software changes, only operates on a subset of data blocks:

Block Type Supports Download Without Reinitialization?
Shared DB, optimized access Yes (since firmware V4.0 on S7-1500)
Shared DB, standard (non-optimized) access No
Instance DB, optimized access No - even though the parent FB is optimized, the IDB inherits the same layout and is treated as a new block
Instance DB, standard (non-optimized) access No in the TIA Portal sense - but the block structure is fixed, so renames do not force a re-init if spare variables were reserved

The key insight is that the IDB's storage layout is determined by the source FB, not by any property on the DB itself. If the source FB is set to Optimized block access, every instance DB created from it inherits the optimized layout. Switching only the DB's property has no effect; you must change the property on the FB and recompile.

Solution: Use Standard (Non-Optimized) Block Access with Spare Variables

The classic STEP 7 V5.x approach can be re-implemented in TIA Portal by combining two configuration choices:

  1. Set the source FB to Standard block access (also called non-optimized or absolute addressing).
  2. Reserve a generous block of unused VAR_TEMP-style spare statics at the end of the Static section so future additions can occupy the reserved offsets without disturbing existing data.

With this configuration, the compiler fixes each static variable at a deterministic byte offset in the IDB. Renaming a tag is treated as a symbolic-only modification; the byte layout does not change, and the online download does not need to re-initialize the IDB. This is the exact mechanism that made the classic S7 workflow work.

Step-by-Step Configuration

  1. Open the FB in the TIA Portal project tree.
  2. Right-click the FB block icon and choose Properties.
  3. Navigate to Attributes (or General > Block access, depending on TIA version).
  4. Clear the checkbox Optimized block access. TIA Portal will warn that this setting cannot be changed back without recompiling all instance DBs - acknowledge the warning.
  5. Click OK and compile the FB. Recompile the project so all instance DBs are regenerated.
  6. Open the FB's Static interface section and append a trailing block of spare statics at the end. A common convention is:
    spare_0 : Bool;    // offset 0.0
    spare_1 : Bool;
    spare_2 : Bool;
    spare_3 : Bool;
    spare_4 : Bool;
    spare_5 : Bool;
    spare_6 : Bool;
    spare_7 : Bool;
    spare_byte_0 : Byte;
    spare_byte_1 : Byte;
    spare_byte_2 : Byte;
    spare_byte_3 : Byte;
    spare_word_0 : Word;
    spare_word_1 : Word;
    spare_dword_0 : DWord;
    spare_dword_1 : DWord;
    spare_real_0  : Real;
    spare_real_1  : Real;
  7. Document the convention in the FB header so future engineers know that spare_* tags are reserved for future use and must not be written by application code.
  8. Compile, then go online. Test by adding a new BOOL static, recompiling, and downloading. The IDB should report no structural change; the existing data is preserved.
When you toggle Optimized block access off, TIA Portal will issue a one-time warning that all instance DBs will be re-initialized on the next download. Plan that single initial download during a planned outage. Every subsequent rename that does not change the data type or insert tags past the spare area will not re-initialize the IDB.

Verification Procedure

After applying the configuration, verify the behavior with a controlled test sequence:

  1. Go online with the CPU and force a known pattern into the IDB using a watch table (e.g. set spare_real_0 = 3.14159 and a few boolean flags).
  2. Go offline, rename a static in the FB (do not change its data type), recompile.
  3. Download to the CPU. In the load preview dialog, confirm that the instance DB is reported as no change and that the Download without reinitialization column is not required (the block is skipped entirely or loaded as a delta).
  4. Go back online and confirm spare_real_0 still reads 3.14159.
  5. Add a new static that fits in the spare region. Recompile and download. Repeat the verification.
  6. Add a new static larger than the spare region (e.g. a new REAL after all spares are consumed). On download, expect a re-initialization of the IDB - this is unavoidable regardless of access mode.

Spare Variable Sizing Heuristic

Sizing the spare region is a trade-off. Too small and you will still need to re-initialize the block when changes arrive; too large and you waste CPU work memory and slow download diffing. Practical conventions for S7-1500 application FBs:

FB Complexity Recommended Spare Reserve Rationale
Small utility FB (1-20 statics) 4 Bool + 2 Byte + 2 Word + 2 DWord + 4 Real ~24 bytes reserved; covers typical instrumentation additions
Medium control FB (20-60 statics) 8 Bool + 4 Byte + 4 Word + 4 DWord + 8 Real ~56 bytes; covers PID tunables, mode bits, alarm words
Large machine FB / sequencer (60+ statics) 16 Bool + 8 Byte + 8 Word + 8 DWord + 16 Real + 2 STRING[32] ~120+ bytes; covers step numbers, transition flags, recipe staging

Comparison: Classic STEP 7 vs TIA Portal Behavior

Capability STEP 7 V5.x (Classic) TIA Portal (Optimized) TIA Portal (Standard, with Spare Vars)
Default block access mode Absolute Optimized (symbolic only) Standard (absolute) - user opt-in
Symbolic-only renames force IDB re-init No, when spares are reserved Yes No, when spares are reserved
Symbolic access from HMI / OPC UA Limited (S7-symbol table required) Full, including partial access by name Full (TIA rebuilds the symbol table from the FB interface)
Block consistency check during download Strict timestamp + interface check Strict, including re-initialization of moved slots Strict, but the layout is fixed so renames are tolerated
Performance (S7-1500) Same as optimized for most code; optimized is marginally faster on tight loops Slightly faster on byte-level access patterns Equivalent for typical applications

Firmware and TIA Portal Version Notes

The Optimized / Standard block access switch is a project-side property. Once compiled, the resulting SCL or STL/GRAPH block carries a flag in the block header that the CPU firmware honors. The behavior described in this article has been stable from TIA Portal V13 SP1 onward and is supported by all S7-1500 firmware versions, including the latest V2.9 / V3.0 releases as of the current STEP 7 / TIA Portal version. There is no known case where a TIA Portal V14 SP1 build produces a different IDB re-initialization result than a V17 build for the same FB with the same access mode.

For S7-1200 CPUs (Firmware V4.0+), the same option is available but with one caveat: a small number of older S7-1200 firmware versions handled the standard-access IDB download path differently. Always perform the verification procedure on the target firmware before relying on the behavior in a production environment.

Symbolic Access from HMI and OPC UA in Standard Mode

One of the historic objections to disabling optimized block access was the loss of comfortable symbolic access from WinCC Unified, TIA HMI panels, and OPC UA servers. This objection is largely outdated. TIA Portal rebuilds the symbol table for the FB's statics even when the underlying access is absolute, so HMI tags and OPC UA nodes continue to resolve by symbolic name. The two areas where the difference is still felt are:

  • Slice access on tags (e.g. "myFB".status.%X0): fully supported in both modes on S7-1500.
  • Direct memory-bit access from STEP 7 code (e.g. DB1.DBX0.0): available only in standard mode. In optimized mode, the compiler may remap a bit, breaking the access.

What Triggers a Re-Initialization in Standard Mode?

Even with the spare variable strategy, certain interface changes will always force a re-initialization. The download will report this and the IDB will be wiped:

Change to FB Interface Re-Initializes IDB?
Rename an existing static (no type change) No
Change the comment of a static No
Reorder statics Yes (offsets change)
Add a new static within the spare region No, provided the spare bytes exist
Add a new static beyond the spare region Yes
Change the data type of an existing static Yes
Delete a static Yes (creates a hole that the compiler refills)
Change a static's initial value No in optimized mode; Yes in standard mode if the block is re-initialized for another reason

Operational Best Practices

  • Document the spare variable convention in the project standards and in the FB header comment. Future engineers must understand that spare_* tags are reserved.
  • Replenish the spare region when it drops below 25 percent of the original size. This is best done during a planned outage to absorb the one-time re-initialization.
  • Use Audit and versioning in TIA Portal so that a rename is traceable. The change log records which tag was renamed, which is the only durable record of the byte layout at the time of download.
  • For process-critical FBs, build a mirror shared DB that holds the last-known-good values. On every cycle, copy the relevant statics into the mirror. After any download that does re-initialize the IDB, the application can repopulate from the mirror, reducing the visible disturbance to the HMI.
  • For multi-instance FBs, apply the same rule. The multi-instance DB inherits the access mode of the parent FB. A multi-instance block under an optimized parent will be re-initialized on every rename of any sibling.

Troubleshooting Matrix

Symptom Likely Cause Corrective Action
IDB is re-initialized after a rename Source FB is still set to Optimized block access Open FB properties, disable Optimized block access, recompile, schedule one re-init download
IDB is re-initialized after adding a tag in the spare region Spare region was exhausted, or the tag was added at the end of Static and pushed the boundary Insert the new tag in the middle of the spare region, or expand the spare region during a planned outage
HMI loses connection to renamed tag HMI tag is bound to the absolute address; symbolic name was regenerated but HMI cache is stale Update the HMI connection in TIA Portal and re-download the HMI project
Compiler error: cannot change block access while instance DBs exist Online blocks exist with the old layout Delete the online instance DBs first (during an outage) and reload with the new access mode
Online shows a different structure than offline Project was not fully compiled after the rename Project > Compile all > Software (rebuild), then compare offline/online

Related Configuration: Retention and Remanence

Standard block access does not change the retention behavior of the IDB. The Retain and Non-volatile column in the FB Static section must be configured per variable as in optimized mode. After a power cycle, retained statics come back with their last values; non-retained statics come back with their initial values. When a re-initialization is unavoidable, retain-attribute variables are also wiped, which is the dominant source of the process upset. A robust mirror DB with its own retention settings is the standard mitigation.

The Optimized / Standard block access switch is a one-way trip in some TIA Portal versions for in-service projects. Always document the chosen access mode per FB family in the project standards. Mixing modes within a project is legal but increases the risk of an unexpected re-initialization during a routine FB edit.

Why does renaming a static in a TIA Portal S7-1500 FB force an instance DB re-initialization?

When the source FB uses Optimized block access, the compiler is allowed to relocate each static to a new byte offset on every interface change. The resulting IDB has a different structure, and the next download must re-initialize it to repopulate the new layout. Switching the source FB to Standard block access and reserving spare variables fixes the offsets and lets renames remain symbolic-only.

Where is the property that controls IDB behavior in TIA Portal?

The Optimized block access property lives in the FB block properties > Attributes (or General > Block access depending on TIA version). It must be changed on the source FB; editing the property on the instance DB itself has no effect because the IDB inherits the layout from the FB.

Does Download without reinitialization work for instance DBs?

No. The Download without reinitialization function in TIA Portal applies only to shared data blocks with optimized access. Instance DBs - whether optimized or standard - are always re-initialized when their structure changes. The only way to avoid the re-init on a rename is to use Standard block access and reserve spare variables.

How many spare variables should I reserve in the FB Static section?

A practical rule of thumb is 4 Bool + 2 Byte + 2 Word + 2 DWord + 4 Real (~24 bytes) for small utility FBs, scaling up to 16 Bool + 8 Byte + 8 Word + 8 DWord + 16 Real + 2 STRING[32] for large sequencer FBs. Document the convention in the FB header and replenish the reserve during a planned outage when usage exceeds 75 percent.

Does this technique work on S7-1200 CPUs as well?

Yes, on S7-1200 CPUs from firmware V4.0 onward, TIA Portal exposes the same Optimized / Standard block access switch on FBs. The spare variable strategy works identically. Earlier S7-1200 firmware versions have edge cases; always perform the rename-and-verify procedure on the target firmware before deploying the technique in a live system.

Back to blog