Overview: Why DB Actual Values Disappear After Download
Data Blocks (DBs) in SIMATIC S7-300 and S7-400 controllers carry two distinct value sets that are easy to confuse in everyday commissioning work:
- Initial values (Startwerte) — the values declared in the offline DB source that are loaded into the work memory the first time the DB is created, when the CPU performs a cold restart, or when a re-initialize is forced. They are part of the offline block definition.
- Actual values (Aktualwerte) — the live values in the CPU's work memory, which diverge from initial values as soon as the program writes to them, an HMI panel modifies a tag, or a recipe block updates structure elements.
When a programmer edits an offline DB (for example, to add a tag, change a data type, or correct a comment) and then downloads it, STEP 7 writes the offline actual values over the running online actual values. If the live field values were never mirrored back into the offline project before the edit, the operator loses weeks or months of accumulated process state on the next cold restart, on a power cycle, or on the very download that performed the edit. This article consolidates the documented STEP 7 V5.x and TIA Portal procedures to back up DB actual values, explains the retentive behavior of S7-300 and S7-400 versus S7-1200, and documents the runtime mechanisms (SFCs, recipes, file I/O) for situations where pure block-level copy is not enough.
Initial Values vs Actual Values — Why the Distinction Matters
The STEP 7 DB editor displays two columns for every tag: Initial Value and Actual Value. The initial value column is editable in the offline project and is what the CPU loads when the block is first inserted into work memory. The actual value column is read-only offline; it becomes the current online value the first time the program writes to the tag, and from then on it follows the live process state.
Two rules determine which value set wins on a download:
- Downloading a DB overwrites the CPU work memory with the offline actual values currently stored in the PG/PC project. If the offline actual values still match the live online actual values (because nobody edited the DB since the last upload), the download is a no-op from a data standpoint.
- If the offline DB was edited in the meantime, STEP 7 still uploads the offline actual values, not the initial values, on download. Initial values are only used if the DB is freshly inserted into the offline project, or if the CPU performs a full memory reset, or if the DB is created at runtime with SFC22 CREAT_DB and the
NON_RETAINattribute is set.
Understanding the second rule prevents a common misconception: editing the DB source (adding tags) does not automatically reset the existing tag values. Only newly added tags take their initial values; existing tags keep whatever the offline actual value column held at the time of the download. This is why the discipline of "upload first, then edit" is the cornerstone of safe DB modification.
Retentivity Fundamentals for S7-300 and S7-400 CPUs
Unlike the S7-1200, the S7-300 family (CPU 31x, including the 315-2DP, 6ES7 315-2AFxx) and the S7-400 family treat all tags inside a Data Block as retentive by default. The practical implications are:
- Retentive tags retain their last actual value across POWER OFF → POWER ON, provided the CPU has the hardware support it needs (an MMC for S7-300, a backup battery for S7-400).
- Bit memory (M), timers (T), and counters (C) that are configured as retentive in the hardware configuration also retain their values across power cycles. The remainder of M, T, and C is reset to 0 on restart.
- Instance DBs (DBs tied to a specific FB through their declaration) inherit the retentive settings of the multi-instance DB if the FB is multi-instance capable.
The retentive area size on the S7-300 is configurable in the hardware configuration. For a CPU 315-2DP, the default retentive ranges are typically 16 M bytes, 0 T, and 0 C; the remaining 8 M bytes (or whatever is configured) reset to 0 on warm restart. S7-400 retentive areas are larger and are split between battery-backed RAM and the load memory on the MMC, depending on the CPU's memory model.
Comparison: S7-300/400 vs S7-1200 Retentivity
| Property | S7-300 / S7-400 | S7-1200 |
|---|---|---|
| Default retentivity of DB tags | All tags retentive by default | Non-retentive unless explicitly declared as Set in IDB / Retain in the PLC tag table or DB declaration |
| Maximum retentive area | Limited by work memory size and MMC capacity (megabyte range) | 2 KB maximum of total retentive M, DB, and IEC counter/timer area |
| Block-level download | Individual block download supported in STEP 7 V5.x (and TIA Portal for S7-300/400) | Full program download in TIA Portal — partial block download not supported |
| Edit / download impact | Editing and downloading a single DB does not re-initialize the rest of the program | Any code change requires CPU STOP and full project download; non-retentive values are reset |
| Online → offline copy of values | Supported for DBs and M markers via online view copy | Supported via Snapshot of actual values in TIA Portal |
| Restart behavior | Cold / warm / hot restart with full retention if conditions met | No warm restart concept; full power-on reinitialization |
The 2 KB retentive ceiling on the S7-1200 is the dominant reason why S7-1200 users see DB value loss after every download, while S7-300/400 users with MMCs in place typically do not. The 2 KB figure is documented in the S7-1200 system manual and in the TIA Portal help for the Retain memory area configuration.
Prerequisites
- STEP 7 V5.5 SPx (or compatible) project with the S7-300/S7-400 station opened. TIA Portal V13+ may also be used; menu paths differ but the underlying mechanism (online-to-offline block copy) is the same.
- An online connection to the target CPU via MPI, PROFIBUS DP, or Ethernet (CP 343-1 Lean/Advanced for S7-300, CP 443-1 for S7-400). Set the PG/PC interface to the correct bus type under Options → Set PG/PC Interface.
- The CPU is in RUN or RUN-P. The online-to-offline copy does not require STOP, but placing the CPU in STOP avoids race conditions where the program writes to a tag while STEP 7 is reading it.
- The PG/PC has read/write access to the offline project, either in the STEP 7 project tree or on the engineering station's filesystem.
- For S7-300: a working MMC inserted in the CPU slot and not write-protected. The CPU's diagnostic buffer shows "MMC not inserted" or "MMC write-protected" if these conditions are not met.
STEP 7 Procedure: Copy Online DB to Offline (Preserve Actual Values)
The canonical method to back up the actual values of DBs and bit memories is to copy the online block from the CPU into the offline project. The procedure below is documented in the official Siemens Support entry How can you back up the actual values of DBs and markers? (Entry ID 18778977).
- In the SIMATIC Manager, open the project containing the S7-300 station.
- Select
View → Online(or pressCtrl+F11) to switch to the Online view of the project tree. The online tree shows the running blocks and their actual values. - Navigate to
S7 Program → Blocksin the Online tree. The block icons are colored to indicate online status: a checkered pattern means the offline and online block differ. - Right-click the target DB (for example, DB100) and choose
Copy. Alternatively, select it and useCtrl+C. - Switch back to the Offline view (
View → OfflineorCtrl+F11). - Navigate to the matching S7 program in the offline tree, right-click the
Blocksfolder, and choosePaste. The online block (with its live actual values) overwrites the offline block. - Save the project with
File → Save(orCtrl+S).
After this sequence, any subsequent edit to the offline DB starts from the live actual values. When the next download occurs, the offline actual values match the online actual values, so the download is a no-op from a data standpoint even if the source structure was modified.
Bulk Upload Using "Upload to PG"
- With the project open and online, select the
S7 Programnode in the offline view. - Choose
PLC → Upload to PG(or right-click →PLC → Upload Station to PG). This mirrors the entire online program, system data (SDB), and block actual values into the offline project. - Confirm the prompt to overwrite the offline project (or save the upload as a new station in the same project, which is the safer option for an exploratory backup).
Snapshot via Monitor/Modify Tag Table
For M markers, timers, and counters that are not carried in a DB, the same Monitor/Modify tag table can be opened in Online view, the live values copied, and the corresponding cells in the offline VAT (Variable Table) updated. The VAT itself is not retentive — it is a display / forcing tool — but pasting the values into the offline VAT and saving creates a recoverable record of the live state that can be re-applied via Modify after a download.
Editing a DB Without Losing Actual Values
The recommended sequence for a DB change in a running plant is:
- Connect online to the CPU and switch to the Online view.
- Copy the DB from Online → Offline (procedure above). Save the project.
- Open the offline DB in the LAD/FBD/STL editor and make the intended changes (add tags, change a data type, fix a comment). The actual value column is preserved for tags that were not modified.
- Compile the program (
Program → Compilein SIMATIC Manager, or the equivalent in TIA Portal) to verify the block is consistent. - Download only the modified DB to the CPU. In SIMATIC Manager, drag the DB from the offline tree to the online tree, or right-click and choose
Download. The CPU accepts the new structure and the unchanged tags keep their previous actual values. - Monitor the DB in the Online view and verify the actual values match expectation before considering the change closed.
This is the workflow assumed by the S7-300/400 architecture: incremental, block-level changes are supported, so the entire program does not need to be re-initialized for a minor DB edit. The S7-1200 lacks this support, which is why its users resort to recipe files or external storage for persistent state.
Runtime Save and Restore Using SFCs
For long-term persistence beyond what the MMC provides, or for structures that must survive a CPU memory reset, the application can write the DB contents to a file on the MMC and read them back at startup. The relevant system blocks and library functions are:
| SFC / SFB | Function | Typical Use |
|---|---|---|
| SFC20 BLKMOV | Block move; copies a contiguous memory area | Copy DB region to a temporary buffer for serialization |
| SFC22 CREAT_DB | Creates a DB in work memory at runtime | Generate dynamic DBs from recipe data; with NON_RETAIN attribute, the DB is reinitialized on restart |
| SFC23 DEL_DB | Deletes a DB from work memory | Clean up dynamic DBs; only works on DBs created by SFC22 |
| SFC24 TEST_DB | Tests whether a DB exists | Precondition check before SFC22 / SFC23 |
| SFC51 RDSYSST | Reads system status lists | Diagnostics; not used for data persistence |
| Standard Library → Recipe / Data Log FBs | Recipe management and CSV log on MMC | Save user-defined structures to MMC as CSV / binary and restore on demand |
The simplest reusable pattern is to invoke the Recipe functionality from the STEP 7 Standard Library. The recipe FB writes a structured record to a file on the MMC, and the corresponding read FB restores it on cold start. A typical implementation calls the write FB from OB1 on a user-triggered event (operator panel button, HMI tag edge), and the read FB from OB100 (warm restart) so the data is available before OB1 starts the cyclic program.
Pattern: Save DB to File on Demand
- Define a UDT (User-Defined Type) matching the structure to persist, for example
UDT100 "RecipeRecord". - Create a static DB,
DB200 "ActiveRecipe", with one array element ofUDT100. - Insert the RecipeWrite FB from the Standard Library into OB1. The FB's
RECIPE_DBinput isDB200, theFILE_NAMEinput is the symbolic path on the MMC (e.g.,'/RECIPES/RCP_A.REC'), andREQis driven from an HMI tag or a one-shot edge in the program. - Monitor the FB's
DONE,ERROR, andSTATUSoutputs. OnERROR, raise an operator message via SFC52 WR_USMSG.
Pattern: Restore DB on Warm Restart
- Insert the RecipeRead FB into OB100. The inputs match the write FB:
RECIPE_DB = DB200,FILE_NAME = '/RECIPES/RCP_A.REC'. - Do not access
DB200from OB1 until the RecipeRead has setDONE = TRUE. The standard pattern uses a global marker, e.g.,M0.0 "RecipeLoaded", set by the FB'sDONEoutput, and gates the rest of the program with anA M0.0/SPBsequence. - Verify the read by computing a simple checksum (e.g., a CRC over the UDT body) and storing it in the file as a trailer.
MMC-Backed Retentive Storage Details
For the S7-300 family, the MMC is the load memory and the persistence store. MMCs are available in several capacity variants (typically 16 KB, 64 KB, 256 KB, 1 MB, 2 MB, 4 MB, and 8 MB) under the 6ES7 952-1 order number family. Refer to the SIMATIC S7-300 system manual for the precise order number matrix compatible with the target CPU — older CPU 31x models only accept a subset of MMC sizes.
The DB actual values are mirrored from work memory to the MMC transparently; the application does not need to issue a save call for standard retentive DBs. The mirror happens in the CPU firmware as part of the standard memory management. The only situations where the application must explicitly save are:
- DBs created with SFC22 and the
NON_RETAINattribute — these do not persist across restart. - DBs allocated in a non-standard memory region (e.g., a custom memory layout via SFC59 / SFC60) that bypass the standard retentive mechanism.
- Long-term archival of process recipes that must survive a CPU replacement or a full memory reset.
Retentivity Configuration in STEP 7
To explicitly set which M markers, timers, and counters are retentive on an S7-300 CPU:
- Open the hardware configuration (HW Config).
- Select the CPU in the rack (e.g., CPU 315-2DP in slot 2).
- Open
Properties → Retentive Memory(German:Remanenz). - Enter the number of retentive M bytes, T counters, and C timers. The remainder of the M, T, C area resets to 0 on warm restart.
- Save and download the hardware configuration. A hardware download typically requires the CPU to be in STOP, so plan a brief process interruption.
DB retentivity is not configured in this dialog; the entire DB retains by default unless the DB is created as non-retentive. To create a non-retentive DB, the application uses SFC22 CREAT_DB with the NON_RETAIN attribute set in the input parameters. Static DBs declared in the offline project are always fully retentive on S7-300/400.
Verification After Download
- In Online view, open the DB and select
Monitor/Modify. Compare the displayed actual values against the values recorded before the download. - Trigger a STOP → RUN transition via the PG (
PLC → Operating Mode → STOPthenRUN), or a power cycle on S7-300 with MMC. Confirm the actual values are still present after restart. - Check the diagnostic buffer of the CPU (
PLC → Diagnostic Buffer) for events such as Re-initialization, OB not loaded, or Memory reset, which would indicate the DB was rebuilt from initial values rather than retained actual values. - Verify the MMC is inserted, not write-protected, and not full. The diagnostic buffer entries MMC not inserted or MMC write-protected point to a configuration problem.
- For S7-400: verify the backup battery in the power supply module is healthy. The diagnostic buffer raises Battery fault well before the battery is exhausted; replace proactively based on the diagnostic indicator, not the actual failure event.
Troubleshooting Matrix
| Symptom | Likely Cause | Action |
|---|---|---|
| DB actual values reset after download | Edited DB offline and downloaded — offline values overwrote online | Re-upload the DB from online before editing, or copy online → offline first per the procedure above |
| All values lost on power cycle (S7-300) | No MMC, MMC write-protected, or MMC defective | Insert / replace MMC; unwrite-protect; check status under PLC → MMC → Display |
| Some M markers lost, others retained | Retentive M range configured smaller than the markers used in the program | Increase retentive M count in HW Config → CPU → Retentive Memory; redownload HW config |
| Cannot upload DB — online shows different version | Time stamp or interface mismatch between online and offline | Use PLC → Compare Blocks to identify divergence; re-upload only matching blocks or perform a full Upload to PG |
| S7-1200 user: 2 KB retentive limit hit | Too many tags marked Retain | Move non-essential state to M markers or to a recipe file on the SIMATIC Memory Card |
| DB recreated on every restart | DB created with SFC22 NON_RETAIN, or deleted by SFC23 in OB100 | Audit OB100 / startup OBs for SFC22 / SFC23 calls; remove or replace with the persistence pattern |
| Recipe FB reports error STATUS = 80A1 / 80B1 / 80C1 | File not found, write-protected MMC, or file system full | Check MMC free space under PLC → MMC → Display; verify the directory exists; check write-protect tab on the MMC |
| Values change between Upload to PG and project save | Application wrote to the DB between the upload and the save | Place CPU in STOP before the upload, or repeat the upload and save in immediate succession; verify with a checksum |
Migrating the Procedure to TIA Portal
For stations programmed in TIA Portal (V13 and later, with the S7-300/400 add-on installed), the equivalent procedure is:
- In the project tree, right-click the Program blocks folder of the target device and choose Go online.
- Open the Online view of the program blocks. The online blocks are shown alongside the offline blocks for comparison.
- Drag the target DB from the online view to the offline view, or right-click and choose Snapshot of actual values (TIA Portal V16+). The DB's online actual values overwrite the offline actual values.
- Save the project (
Ctrl+S).
For S7-1200 stations in TIA Portal, the same Snapshot of actual values function exists, but the retentive semantics differ. The snapshot is a one-time data capture, not a substitute for declaring tags as Retain in the PLC tag table. A tag that is not declared Retain will still reset to its initial value on the next power cycle or full download, regardless of how recent the snapshot is.
FAQ
Are all DB tags retentive on an S7-300 / S7-400 by default?
Yes. On S7-300 (CPU 31x, including the 315-2DP) and S7-400 CPUs, every tag inside a standard instance or shared DB retains its last actual value across power cycles, provided the S7-300 has a working MMC inserted or the S7-400 has a healthy backup battery. No explicit Retain attribute is required.
Why do my S7-1200 DB values disappear on download?
The S7-1200 requires a full program download in TIA Portal and re-initializes all non-retentive tags on each restart. Only tags explicitly marked Retain (or stored in the Retain IEC area) survive, and the total is capped at 2 KB. Use a recipe on the SIMATIC Memory Card to persist larger structures.
What is the fastest way to snapshot the actual values of a DB?
Switch to the Online view in SIMATIC Manager, copy the DB to the offline project, and save. Future edits will start from the live actual values. The detailed procedure is documented in Siemens Support Entry 18778977.
Does the S7-300 retain data without an MMC?
No. S7-300 CPUs (CPU 31x and C7-6xx) require an MMC for retentivity. Without an MMC, a power cycle or STOP → RUN with memory reset erases all DBs, M markers, timers, and counters. The S7-400 retains data via the backup battery in the power supply module even without an MMC.
Can I write DB initial values at runtime?
You cannot modify the initial value set of an existing static DB online — initial values are part of the offline block definition. To re-baseline initial values from the live actual values, copy the online DB to the offline project in STEP 7; the live values become the new initial values for the next download. For runtime DBs created with SFC22 CREAT_DB, the INITIAL_VALUES input parameter can be sourced from a buffer filled with current actual values.
What happens to a recipe file when the MMC is swapped?
The recipe file is a regular file on the MMC filesystem. If the new MMC is empty, the recipe read FB returns STATUS = 80A1 (file not found) and the application falls back to initial values. To migrate a recipe, copy the file from the old MMC to the new one via the PG (S7-MMC card reader) or via a TIA Portal card management operation.