Recovering Corrupted S7 Block Folders and Resolving CFC Compilation Failures in PCS 7

Recovering Corrupted S7 Block Folders and Resolving CFC Compilation Failures in PCS 7

When a CFC compilation aborts abnormally with numerous errors and wipes the offline 'blocks' folder in SIMATIC Manager (reporting 'Block folder not found. Please insert a block folder'), the project's internal relational database has been left in an unlinked intermediate state. In PCS 7, the CFC compiler deletes previously generated blocks before recreating them; if compilation crashes due to an orphaned runtime group, the blocks remain absent. To recover: 1. Perform a project reorganization using 'File -> Save As... with Reorganization (slow)'; 2. Restore standard system blocks (SFCs/SFBs) from the Standard Library into the offline block folder; 3. In CFC, open the Runtime Editor, delete any orphaned runtime groups in OB36/OB1; and 4. Execute a full CFC compilation ('Entire program' with 'Generate module drivers').

Table of Contents

Executive Summary

During control software development in SIMATIC PCS 7 V8.x or V9.x, an engineer may modify execution timing by inserting or moving runtime groups between Organization Blocks (e.g. from cyclic OB1 to timed interrupt OB36) in the CFC Runtime Editor. If this modification is interrupted or leaves incomplete task pointers, initiating a CFC compilation can trigger dozens of cascading errors (e.g. 68 errors and 3 warnings). A subsequent compilation attempt fails completely with the alarming error 'Block folder not found. Please insert a block folder', and inspection of the S7 program reveals that all compiled blocks have disappeared from the offline container. This article explains the two-phase block generation pipeline in CFC, clarifies why aborted compilations leave block containers empty, and provides a verified step-by-step recovery procedure.

Architecture and Fundamental Mechanics

CFC Compilation Pipeline, Runtime Group Architecture, and Block Container Recovery Mechanics:

  • The CFC Compilation and Block Generation Pipeline:
  • In SIMATIC PCS 7, the continuous function charts (CFCs) are the master technological design repository, not the offline block container.
  • When an engineer triggers Chart -> Compile -> Chart as Program:
    • Step 1 (Validation & Cleanup): The compiler inspects chart syntax, task allocation, and runtime group ordering. It cleans the offline blocks container by deleting previously compiled CFC-generated blocks (DBs, FCs, and system coordination calls).
    • Step 2 (Code Generation): The compiler parses all technological blocks, builds instance DBs, generates module drivers, and assembles the executable machine code into OBs.
  • Failure Vulnerability: If Step 1 completes its deletion routine and Step 2 abruptly crashes due to an unhandled exception (such as an empty, unassigned, or corrupt runtime group in OB36), the compilation aborts mid-flight. The offline block container is left empty, and internal pointers between the S7 program and the database become corrupted.

  • Runtime Group Pointer Corruption:

  • Right-clicking an OB in the Runtime Editor and selecting 'Insert runtime group' creates an unlinked organizational container.
  • If left unconfigured, nameless, or referencing an invalid reduction ratio/phase offset, the runtime group generator encounters a null pointer during sequence sorting, triggering fatal compiler exceptions.

  • Why the Physical Controller Remains Safe:

  • Because the compilation aborted prior to downloading, the physical S7-400 CPU continues running the last valid compiled program in its load and work memory.
  • The corruption is strictly confined to the offline engineering database on the Engineering Station.

  • Restoration Strategy:

  • Because CFC charts retain all functional block instances, parameters, and interconnections, the entire executable program can be reconstructed from scratch once the runtime group defect is repaired and database integrity is restored via Reorganization.

Step-by-Step Implementation Procedure

  1. Reorganize the Project Database (Clean Orphaned Locks):
    * In SIMATIC Manager, close all open CFC charts, Hardware Configuration, and NetPro editors.
    * Select File -> Save As....
    * In the Save dialog, check the box With Reorganization (slow).
    * Specify a new project name or temporary directory and click OK.
    * This process purges corrupted temporary index files, reindexes the dBase structure, and repairs the internal S7 program container.

  2. Verify and Recreate the Offline Block Folder:
    * Open the reorganized project in SIMATIC Manager.
    * Navigate to the S7 Program under the CPU.
    * If the Blocks container is missing, right-click the S7 Program folder -> Insert New Object -> Block Folder.
    * Open the Standard Library (File -> Open -> Libraries -> Standard Library -> System Function Blocks).
    * Copy essential system functions (SFC0 through SFC108, SFB0 through SFB37) into the newly restored Blocks folder.

  3. Repair the Runtime Editor Defect in CFC:
    * Open any CFC chart in the project.
    * Open the Runtime Editor by selecting Options -> Runtime Editor (or press Ctrl+Shift+R).
    * Expand OB1 and OB36 in the left tree.
    * Search for any empty, highlighted green, unassigned, or newly inserted runtime groups that contain zero blocks or invalid attributes.
    * Right-click the defective runtime group and select Delete.
    * Ensure all active technological blocks are assigned to valid, established runtime groups.

  4. Execute a Full CFC Compilation:
    * In the CFC editor, select Chart -> Compile -> Chart as Program....
    * Select Entire Program (do NOT select 'Changes only').
    * Check Generate module drivers.
    * Check Update sampling time.
    * Click OK to execute compilation.
    * The compiler reconstructs all instance DBs, generates driver blocks, and populates the offline block folder with 100% clean code.

  5. Re-establish Online Consistency:
    * Once compilation completes with 0 errors, open the Blocks folder to confirm that all DBs, FCs, and OBs are present.
    * Compare offline and online block timestamps before downloading to verify safe controller synchronization.

Verification

  1. In SIMATIC Manager, browse the Blocks folder under the S7 Program; confirm that all technological blocks, driver DBs, and system OBs appear with valid byte sizes and comments.
  2. In CFC, trigger another compilation with 'Changes only'; verify that compilation finishes with 0 Errors and 0 Warnings.
  3. Switch CFC to Test Mode (Ctrl+F); verify that online monitoring of live CPU tags resumes without communication faults.

Limitations and Operational Precautions

Executing 'Entire program' compilation invalidates the online/offline block checksums for delta downloading. If the CPU cannot accept a STOP during production, an Entire Download cannot be executed immediately. However, if the offline charts were not functionally changed other than deleting the orphaned runtime group, careful comparison may allow syncing without stopping the process. Always archive the project (File -> Archive) prior to reorganizing or deleting system containers.

Engineer FAQ

Why did a bad compile delete all the blocks in my S7 program?

Because the CFC compiler wipes previously generated blocks in Phase 1 before rebuilding them in Phase 2. If Phase 2 crashes, the blocks remain deleted.

Is my running PLC affected if offline blocks disappear?

No. The running CPU operates out of its internal load and work memory; an aborted offline compilation does not alter the physical controller.

What does 'Save As with Reorganization (slow)' do?

It purges deleted database records, resolves broken relational pointers, and rebuilds the internal STEP 7 project file structure.

How do I fix the 'Block folder not found' error?

Reorganize the project or manually re-insert a Block Folder under the S7 Program, copy SFBs/SFCs from the Standard Library, and recompile CFCs.

Can I recover my logic if all compiled blocks are deleted?

Yes, because all logic resides in the CFC charts, which are the technological master. Compiling 'Entire Program' recreates all blocks completely.

Technical References

Related Articles

Related Tags

  • CFC Compilation
  • Corrupt Blocks
  • Runtime Editor
  • OB36
  • Reorganization
  • Block Folder
  • S7 Program
  • PCS 7 V8.2
20 respuestas