IM151-8 Retentive DB Reinitialization Fix in TIA Portal V13 SP1
Engineers maintaining a Siemens ET 200S station built around the IM151-8 PN/DP CPU often hit a wall the first time they try to extend a retentive parameter data block (DB). The DB was carefully populated from an HMI, marked Retain, and downloaded successfully. The next time a single new BOOL is appended to the structure, the program is recompiled, downloaded, and the controller silently overwrites every tag with its initial value. Production loses 100+ tuning parameters, recipes, calibration constants, or machine counters in one download cycle. This article documents the root cause, the exact conditions under which the failure occurs, and the engineering options available inside TIA Portal V13 SP1 (and newer) before a migration to a newer CPU family is approved.
1. Problem Statement
The reported symptom on the IM151-8 (article numbers 6ES7151-8AB01-0AB0, 6ES7151-8AB02-0AB0, and the fail-safe variant 6ES7151-8FB01-0AB0) is reproducible:
- A retentive DB of type global DB is used as a parameter container. HMI tags point directly into the DB. The operator sets roughly 100 parameters through the panel.
- After commissioning, the engineer adds a single new variable (for example, a BOOL
bNewMode) anywhere in the DB declaration. The project is compiled and downloaded to the IM151-8. - On the next CPU start, the entire DB is overwritten with the initial values declared in the offline project. All operator entries are lost. The TIA Portal Watch table confirms the data is gone.
- Even changing only the symbolic name of an existing variable, without touching its type or its position in the declaration, triggers the same reinitialization because the recompile produces a different STRUCT footprint.
The behavior is reproducible regardless of whether the download is performed from TIA Portal V13, V13 SP1, V14, V15, or any newer release, as long as the IM151-8 target is configured with the S7-300/400-compatible compiler (the default for that CPU). The issue is independent of the firmware version of the IM151-8 (V3.x firmware is current for the 6ES7151-8AB02-0AB0 variant).
2. Root Cause: Standard Block Access vs. Optimized Block Access
Every DB in S7-300/400 (and the IM151-8, which is functionally a distributed S7-300 CPU on an ET 200S head-end) is compiled with a fixed, absolute memory layout. The block footer contains a retain area definition that maps each retentive tag to an absolute bit/byte offset in the load memory image. When the offline and online declarations match, the CPU's startup routine copies the previously stored retain image into the work memory. When the offline footprint differs from the online footprint, the CPU cannot reconcile the retain image with the new offsets, so it discards the retain image and reinitializes all tags to their declared initial values.
The relevant compiler options are:
| Block access mode | Available on IM151-8 | Behavior on DB change | Default in TIA V13 SP1 |
|---|---|---|---|
| Standard block access (S7-300/400 compatible) | Yes | Any structural change reinitializes the entire DB | Yes (only option) |
| Optimized block access (symbolic, S7-1500 style) | No | Structural changes preserve the existing values where possible | Not selectable |
Because the IM151-8 firmware only supports the legacy S7-300/400 access mode, every change to a global DB - adding, removing, retyping, or even renaming a tag - alters the compiled footprint and triggers a full reinitialization of the DB on download. The PLC does not perform a field-by-field merge.
Siemens documents this constraint in the Siemens FAQ 67655611: "Loading data blocks without reinitializing". The FAQ states explicitly: "With S7-300/400 (Standard Block Access) a download of a changed data block causes the block to be reinitialized." It also confirms that an S7-1500 CPU with optimized block access does not have this limitation.
3. Affected Hardware, Firmware, and Software Matrix
| CPU / Station | Article number | Firmware | Compiler mode | Subject to reinitialization |
|---|---|---|---|---|
| IM151-8 PN/DP | 6ES7151-8AB01-0AB0 | V2.x | Standard | Yes |
| IM151-8 PN/DP | 6ES7151-8AB02-0AB0 | V3.x | Standard | Yes |
| IM151-8 PN/DP FO (fiber optic) | 6ES7151-8AB03-0AB0 | V3.x | Standard | Yes |
| IM151-8F PN/DP (fail-safe) | 6ES7151-8FB01-0AB0 | V2.x | Standard | Yes |
| S7-300 CPUs (all) | 6ES7 31x-xxxxx | any | Standard | Yes |
| S7-400 CPUs (all) | 6ES7 41x-xxxxx | any | Standard | Yes |
| ET 200S CPU (IM151-7) | 6ES7151-7AA20-0AB0 | any | Standard | Yes |
| S7-1200 (V1.x - V4.x) | 6ES7 21x-xxxxx | any | Optimized | No (different mechanism) |
| S7-1500 | 6ES7 5xx-xxxxx | any | Optimized | No |
| ET 200SP CPU (1510SP / 1512SP) | 6ES7510-1DJ01-0AB0, 6ES7512-1DK01-0AB0 | V1.x+ | Optimized | No |
The complete ET 200S system manual (Siemens manual A5E00171327) confirms that the IM151-8 CPU operates as an S7-300-compatible controller with 128 KB of work memory (64 KB code, 64 KB data), 64 KB of load memory, up to 1023 data blocks, and 8 KB of bit memory. There is no firmware option that enables optimized block access on this CPU.
4. TIA Portal V13 SP1 Specific Behavior
TIA Portal V13 SP1 was released in August 2015 and added support for ET 200SP, additional S7-1500 CPU variants, and several HMI runtime improvements. Per the official V13 SP1 readme, all projects created in V12 SP1 or V13 can be upgraded and continue to compile on V13 SP1, but improvements to the compiler and offline/online comparison made some projects recompile with different internal layouts even when the user did not touch the DB. This is relevant because:
- If you upgrade an existing V12 SP1 or V13 project that already contains a retentive DB and immediately download it to the IM151-8 after the upgrade, expect a reinitialization even though the DB declaration was not edited.
- The Go online > Compare offline/online tool in V13 SP1 highlights structural changes to DBs in red; review the comparison before initiating any download that includes a recompiled DB.
- The V13 SP1 readme also clarifies that the Snapshot and Reload snapshot tools in the watch table are the supported mechanism for capturing online values and re-applying them after a reinitialization - the procedure is documented in the TIA Portal online help under Editing watch tables > Snapshot of monitored values.
Reference: Compatibility of PLC programs from versions prior to V13 SP1 (Siemens readme).
5. Diagnostic Matrix: Why the Snapshot Tool Sometimes Fails
| Symptom | Likely cause | Verification |
|---|---|---|
| Watch table shows values, Snapshot works, but Reload snapshot is greyed out after download | The DB online structure differs from the snapshot structure; the tool refuses to write to an incompatible block | Open the DB online and compare STRUCT with the offline declaration; any mismatch will disable reload |
| Snapshot reload appears to succeed but values revert to initial values on the next STOP/RUN | The DB has Retain = false on the new tags, or the entire DB is not configured as retentive | Check the DB properties > Attributes > Retain; every new tag must be marked retain for its area to be preserved |
| Renaming a single tag wipes all values | Renaming changes the compiled footprint even when the type and offset are unchanged | Avoid renaming. Use a comments field instead. |
| Only newly added tags are zeroed, old values remain | Only the new tags fall outside the previous retain area map | Mark the new tags as Retain in the DB declaration |
| All values lost on TIA V13 SP1 upgrade download | Compiler changed block checksum and load memory layout | Take a snapshot, then perform the upgrade download, then reload the snapshot |
6. Workaround A: Snapshot and Reload via Watch Table
This is the procedure explicitly referenced in the V13 SP1 online help. It is reliable as long as the DB online structure still matches the offline structure at the moment of reload - which fails if the DB was already downloaded with the new structure. The proper sequence is:
- Open the project in TIA Portal V13 SP1, expand Watch and force tables in the project tree.
- Create a new watch table named
WT_DB_Parameter. Drag the entire DB symbol (e.g."DB_Parameter") into the watch table; TIA Portal will expand all tags and create one row per element. - Go online. Confirm that the displayed values match the live values on the HMI.
- Click the camera icon (Create snapshot of monitored values) on the watch table toolbar. The snapshot is stored as a column inside the watch table.
- Do not download the modified project yet. The snapshot is held in the watch table, not in the PLC.
- Make the required DB change (for example, add a new BOOL at the end of the STRUCT). Compile the project.
- Download the project to the IM151-8. Accept the prompt that the DB will be reinitialized. The CPU restarts the relevant OB and the DB now contains initial values only.
- Stay online. In the watch table, select the snapshot column. Right-click and choose Reload snapshot to online (the lightning-bolt / "do it now" button). The values are written back to the PLC one row at a time.
- Open the DB online view and verify that the operator values are restored. Confirm on the HMI.
- Save the watch table with the snapshot column to disk; this becomes your restore sheet for the next commissioning.
7. Workaround B: Pre-Allocated Spare Variables
The most reliable long-term mitigation is to never modify the DB footprint again. Allocate a generous block of spare variables when the DB is first created:
- Open the DB in the project tree. In the declaration table, add a section named
spare_BOOLwith, for example, 64 entries ofBOOLinitialized tofalse. - Add a section
spare_INTwith 32 entries ofINTinitialized to0, and a sectionspare_REALwith 32 entries ofREALinitialized to0.0. - Add a section
spare_STRINGwith 8 entries ofSTRING[80]initialized to empty strings. - For every variable that will be needed in the future (modes, alarms, recipe indices, scaling factors), reserve additional
BOOL,INT,REALentries up front and document their intended use in the Comment column. - Mark the entire DB as Retain. All tags inherit the retain property by default; verify in the DB properties.
- Save and download. The DB now contains hundreds of slots. Future modifications use the reserved slots and never touch the declaration; the compiled footprint stays identical, the retain image is preserved.
This approach is widely used in S7-300/400 field engineering. The trade-off is a slightly larger memory footprint (64 BOOL = 64 bytes, 32 INT = 64 bytes, 32 REAL = 128 bytes) and a structured-comment overhead in the declaration. For a parameter container DB this overhead is negligible compared to the cost of losing tuned values.
8. Workaround C: Separate Parameter and Process DBs
Decouple the parameter container from the rest of the program. Instead of putting all parameters into one DB, use three DBs:
-
DB_Param_Current- the active working parameters. Non-retentive. Re-declared freely without losing values, because values are re-loaded fromDB_Param_Storedat startup. -
DB_Param_Stored- the retentive backup. The DB is declared once and never modified after commissioning. Retain = true. Contains a fixed STRUCT of BOOL/INT/REAL slots pre-allocated for the entire life of the machine. -
DB_Param_Struct- the working copy used by the program logic. Populated fromDB_Param_Storedin OB100 (startup) and re-written toDB_Param_Storedon operator save events.
The implementation pattern in SCL (Structured Control Language) inside OB100 is:
// OB100 - Startup
FOR i := 1 TO MAX_PARAM DO
DB_Param_Struct.values[i] := DB_Param_Stored.values[i];
END_FOR;
DB_Param_Struct.checksum := DB_Param_Stored.checksum;
And on a "Save" operator button, copy in the opposite direction. The engineer can now extend DB_Param_Current and DB_Param_Struct freely; only DB_Param_Stored must remain frozen. Since DB_Param_Stored is never edited after commissioning, the retain area is preserved across every download.
9. Workaround D: HMI Recipe or Parameter Container
Move the parameter values out of the PLC altogether. WinCC Professional, WinCC Comfort/Advanced, and most TIA-integrated HMI panels (KTP, TP, MP, Comfort) support a Recipe or Parameter Container object. Configure the recipe to read from and write to the HMI's own storage rather than the PLC. The PLC never holds the persistent values:
- In the HMI project, add a new Recipe under Recipes in the project tree.
- Define the recipe elements, one per parameter. Point each element to a tag in the PLC's working DB.
- Configure the recipe to store its data record on the HMI's internal flash or on a USB stick. Set the storage location to Local file system or External storage medium.
- On HMI startup, the panel automatically loads the saved recipe and writes the values into the PLC working tags.
- On operator save, the panel reads the values from the PLC working tags and stores them to its own memory.
This approach is independent of the PLC's retain mechanism. The PLC program can be re-downloaded, the DB can be re-declared, and the HMI re-loads the recipe on the next power-up. The trade-off is that the operator must save explicitly after each parameter change, and the PLC's working DB is non-retentive by design.
10. Workaround E: S7-1500 or ET 200SP CPU Migration
For new machines or major retrofits, migrate the controller to an S7-1500 or an ET 200SP CPU (1510SP / 1512SP). Both families support optimized block access, which is the default in TIA Portal V13 SP1 and later. With optimized access:
- The DB retain area is stored symbolically. The CPU performs a name-based reconcile on download; new tags are added with their initial values, renamed tags keep their value, and only tags whose type or position is genuinely incompatible lose their value.
- Renaming a variable does not trigger a re-initialization of the DB.
- Adding a variable to the end of the STRUCT does not reset existing values.
- Only changing the data type of an existing tag (e.g. INT to DINT) wipes that specific tag's value.
Migration paths from IM151-8 to ET 200SP CPU 1512SP (6ES7512-1DK01-0AB0) are documented in the Siemens migration guide and supported in TIA Portal's Change device function. The wiring concept on the ET 200S backplane is not directly reusable; plan for an ET 200SP station with the appropriate I/O modules.
11. TIA Portal V13 SP1 Compatibility and Migration Notes
- Projects created in TIA Portal V12 SP1 or V13 can be opened in V13 SP1 with no manual conversion. Compiler improvements may produce slightly different internal representations; expect a re-initialization on the first download after upgrade even without DB changes.
- Projects created in V13 SP1 can be opened in V14, V15, V15.1, V16, V17, V18, and V19 without conversion loss. Downgrading from V14 to V13 SP1 is not supported.
- Hardware support packages (HSPs) for newer IM151-8 firmware versions are available in the Siemens HSP library and must be installed separately. The IM151-8 PN/DP article 6ES7151-8AB02-0AB0 requires HSP for V13 SP1 or the device will not appear in the hardware catalog.
- The Optimized block access check box on DB properties is present in V13 SP1 for the IM151-8 target but is greyed out; the option is reserved for S7-1200/1500 targets only.
See the TIA Portal V13 SP1 readme for the full compatibility statement.
12. Verification Procedure After a Download
- Open the project in TIA Portal V13 SP1 and go online to the IM151-8.
- Open the parameter DB and switch to the Online view. Confirm that every tag is at its initial value (not the operator-entered value).
- Open the watch table
WT_DB_Parameter. Confirm the Reload snapshot button is active. - Click Reload snapshot to online. The button shows the lightning-bolt icon and writes each row back to the PLC.
- Wait for the "all values written successfully" status message in the inspector window.
- Open the DB online view again and verify that operator values are restored. Cross-check the HMI screen.
- Cycle power on the IM151-8. Wait for restart. Verify that values persist (this confirms the retain area is correctly mapped).
- Document the snapshot in the project (save the watch table) for the next maintenance event.
13. Long-Term Recommendation
For green-field projects, do not specify a new IM151-8 station. The CPU is at end of life and the retain-area limitation forces expensive procedural safeguards. For new ET 200S systems, specify the ET 200SP CPU 1512SP (6ES7512-1DK01-0AB0) or the S7-1511-1 PN (6ES7511-1AK02-0AB0) depending on the I/O density. For existing IM151-8 fleets, deploy the pre-allocated spare-variable pattern and a documented snapshot-reload procedure for the maintenance crew. Migrate to S7-1500 during the next major retrofit, and use that opportunity to enable the Optimized block access check box on all DBs - the retain-area headache disappears permanently.
FAQ
Why does adding a single BOOL to a retentive DB zero the entire block on the IM151-8?
The IM151-8 compiles every global DB with standard (S7-300/400-compatible) block access. Any change to the STRUCT layout - including a renamed tag - changes the compiled footprint and the retain area map. The CPU cannot reconcile the new map with the on-line retain image, so it discards the retain data and reinitializes the DB. The same behavior applies to all S7-300/400 and ET 200S CPUs.
Does the TIA Portal V13 SP1 Snapshot/Reload tool recover all DB values after a reinitialization?
Yes, provided the snapshot was taken before the download and the DB online structure still matches the offline structure. Create a watch table, drag the entire DB into it, go online, click the camera icon to create a snapshot, perform the download, and then click the lightning-bolt "Reload snapshot" button to write the values back. New tags added at the end of the DB will not be in the snapshot, which is the desired behavior.
Is there a way to disable the reinitialization on the IM151-8?
No. The IM151-8 firmware does not support optimized block access, which is the only mode that allows incremental retain updates. The "Optimized block access" check box in the DB properties is greyed out for IM151-8 targets in all TIA Portal versions including V13 SP1. The only durable fix is to migrate the CPU to S7-1500, ET 200SP CPU, or S7-1200 (V4.x) where optimized block access is the default.
Does renaming a variable really wipe the entire DB on the IM151-8?
Yes, in TIA Portal V13 SP1. Renaming a tag causes the compiler to regenerate the STRUCT descriptor, which changes the compiled block checksum and the retain area map. The CPU treats the block as new and reinitializes it. Use a comment column to document variable purposes instead of renaming existing tags once the DB is in production.
Where can I find the official Siemens statement on this limitation?
Siemens documents the behavior in FAQ entry 67655611 under the title "Loading data blocks without reinitializing". The FAQ confirms that S7-300/400 with Standard Block Access always reinitializes on a changed DB, and that the S7-1500 with Optimized Block Access does not. The TIA Portal V13 SP1 readme at the Siemens documentation portal also covers the behavior under the compatibility section.