Preventing Data Block Value Resets After Recompilation and Creating Safe Defaults in STEP 7

Preventing Data Block Value Resets After Recompilation and Creating Safe Defaults in STEP 7

In SIMATIC PCS 7 and STEP 7 systems, recompiling data blocks (DBs) or downloading modified S7 programs frequently resets online operational values to 0.0 because the compiler reinitializes actual values with declared initial values. Engineers prevent operational setpoint loss and establish safe fallback values by populating the 'Initial Value' column in Data View, copying online actual values into initial values before compilation, or parameterizing non-zero defaults in CFC block declarations.

Table of Contents

Mechanics of Data Block Initialization: Initial Values vs. Actual Values

In SIMATIC S7-400 and CPU 410 controllers, data blocks (DBs) maintain two distinct layers of parameter definitions within the STEP 7 database:
* Initial Value (Declaration View): The default fallback value assigned to a variable during block creation (e.g., in SCL, STL, or the DB editor). If no initial value is explicitly entered, STEP 7 defaults numbers to 0 or 0.0.
* Actual Value (Data View): The live, operational value currently stored in the CPU's work memory and modified dynamically by HMI operator entries or PLC program logic.
* The Compilation Hazard: When a data block source is recompiled, or when an altered block interface forces a complete DB regeneration, STEP 7 rebuilds the data block using the declared Initial Values, overwriting existing online Actual Values.

Why Recompilation and Downloads Reset HMI Setpoints to Zero

In plants where an HMI/SCADA system writes operating setpoints (e.g., temperature setpoint 50.0 °C, pressure limit 10.0 bar) directly into an S7 data block:
* If the data block was created with default initial values of 0.0:
* Recompiling the DB or downloading the DB to the controller wipes out the operator's tuning setpoints, resetting the process to 0.0.
* In continuous chemical or thermal processes, resetting active setpoints to zero can cause immediate production trips, valve slam-shut events, or equipment thermal shock.

Step-by-Step Procedure to Define Safe Default Values in the DB Editor

To ensure that any future re-initialization resets the process to a known, stable "safe" operating value rather than zero:
1. Open SIMATIC Manager and locate the target Data Block.
2. Double-click the DB to open the LAD/STL/FBD - S7 Block Editor.
3. By default, the block opens in Declaration View. Switch to Data View:
* Select View -> Data View (or press Ctrl + 4).
4. Locate the column titled Initial Value.
5. For each critical setpoint, replace 0.0 with your verified safe process baseline (e.g., enter 50.0 for temperature setpoints or 1.0 for minimum flow).
6. Save the data block.
7. Now, if a complete CPU memory reset (MRES) or re-initialization occurs, the controller defaults to your safe operating value rather than absolute zero.

Copying Online Actual Values to Offline Initial Values Before Recompilation

When tuning parameters have been adjusted online over months of operation, engineers should capture those optimized values before recompiling:
1. In the DB editor, open the online data block:
* Select PLC -> Open Online Partner.
2. Select View -> Data View to inspect current live Actual Values.
3. Select Edit -> Initialize Data Block (or copy online values).
4. In STEP 7, use the feature:
* File -> Save As... to save the online DB with its current actual values over the offline project DB.
5. In the offline DB, execute Edit -> Initialize Data Block: this copies the current actual values directly into the Initial Value column, permanently preserving field tuning against future re-compilations.

CFC and APL Architectural Best Practices for Setpoint Retention

In standard SIMATIC PCS 7 Continuous Function Chart (CFC) programming:
* Avoid Raw DB Access: Never write WinCC HMI setpoints directly to unlinked instance DB offsets.
* CFC Block Pin Initial Values: In the CFC chart, double-click the block parameter pin (e.g., PIDConL.SP_Ext or SP_Int) and set the default value in the pin properties dialog.
* Delta Downloads: Always perform compilation in Changes Only mode. Delta downloads in RUN mode preserve instance data block actual values without resetting setpoints.

Verification

  • In the DB editor Data View, verify that the Initial Value column displays the designated safe default (e.g., 50.0).
  • In a test environment, execute Edit -> Initialize Data Block: confirm that the Actual Value column updates to 50.0 rather than 0.0.
  • Download the DB to the test controller: verify that the HMI faceplate displays the safe default setpoint immediately without manual intervention.

Limitations and Operational Precautions

  • Initializing a data block on a running production controller immediately overwrites active process variables; never execute DB initialization while a unit is actively operating.
  • If a block interface is modified (adding, deleting, or reordering variables), an S7 download will require re-initializing the DB in STOP mode or performing a Type Change in RUN (TCiR).
  • Always archive the multiproject before updating block interfaces to preserve historical actual value snapshots.

Engineer FAQ

  • What is the difference between Initial Value and Actual Value in STEP 7?
    Initial Value is the declared default fallback; Actual Value is the live operational variable in CPU memory.
  • Why do HMI setpoints reset to 0.0 after recompiling a data block?
    Recompilation rebuilds the DB using declared Initial Values, which default to 0.0 if not explicitly defined.
  • How do I switch the S7 Block Editor to view actual values?
    Select View -> Data View (or press Ctrl + 4) in the LAD/STL/FBD editor.
  • How can I save online tuned setpoints into the offline project?
    Open the online DB, copy actual values, and paste them into the offline Initial Value column before compiling.
  • Does compiling CFC charts in Changes Only mode reset block setpoints?
    No, delta compilation and delta download in RUN mode preserve existing instance DB actual values.
  • What command resets a DB's actual values to its initial values in the editor?
    The command Edit -> Initialize Data Block.
  • Can safe initial values be defined directly in SCL source code?
    Yes, assign default values in the variable declaration: SetPoint : REAL := 50.0;.
  • What happens to actual values during a CPU warm restart (CRST)?
    Retentive data block variables retain their actual values; non-retentive variables reinitialize to their initial values.
  • How do I make an S7 data block non-retentive?
    In DB properties, uncheck the Non-Retain attribute or configure DB retention in CPU hardware properties.
  • Does defining non-zero initial values consume additional controller memory?
    No, initial values are stored in load memory and consume zero additional work memory.

Technical References

  • SIMATIC STEP 7 V5.6 Programming with STEP 7 Manual (Data Blocks)
  • SIMATIC S7-SCL V5.6 for S7-300/400 Programming Manual
  • Siemens Industry Online Support Entry: Preventing Setpoint Loss on DB Recompilation (Entry ID 299982)
  • SIMATIC PCS 7 CFC for S7 / PCS 7 Manual

Related Articles

Related Tags

PCS 7, STEP 7, Data Blocks, Initial Value, Actual Value, Data View, Setpoint Retention, Recompilation, CFC, HMI

20 respuestas