Automatic Generation of OB80 and System Blocks via Driver Generation in PCS 7

Automatic Generation of OB80 and System Blocks via Driver Generation in PCS 7

In SIMATIC PCS 7, Organization Blocks such as OB80 (Time Error), OB82 (Diagnostic Alarm), and OB86 (Rack Failure) should not be manually created in the S7 Program's Blocks folder because the CFC Module Driver Generator automatically creates and deletes them during chart compilation. If S7-PLCSIM or an AS controller halts due to a missing OB80, it indicates that the program contains no active driver blocks. Inserting at least one standard PCS 7 channel driver block (such as Pcs7DiIn or Pcs7AnIn) connected to a valid symbolic hardware address and compiling CFC with 'Generate Module Drivers' checked automatically instantiates @CPU_RT and generates OB80 alongside all required diagnostic organization blocks.

Table of Contents

PCS 7 System Block Management vs Classic STEP 7 Programming

In traditional STEP 7 programming, software engineers manually create Organization Blocks (OB80, OB82, OB85, OB86, OB121, OB122) in the Blocks folder to handle processor interrupts, cycle overruns, and hardware faults. If an unhandled interrupt occurs and the corresponding error OB is missing, the CPU transitions immediately to STOP mode.

In SIMATIC PCS 7, manual management of system blocks is strictly prohibited and actively counteracted by the compiler. PCS 7 relies on a fully automated system generation concept: during CFC compilation, the Module Driver Generator evaluates the hardware configuration, determines what diagnostic handlers are required, and automatically writes the appropriate OBs into the Blocks folder while generating the internal system charts (@CPU_RT, @STW4_...). If an engineer manually inserts OB80, the compiler treats it as unmanaged code and deletes or overwrites it during the next compile.

The Role of the CFC Module Driver Generator and @CPU_RT

The core engine responsible for system stability in PCS 7 is the Module Driver Generator (s7jcfcax.exe). Its operation depends on technological channel drivers:

  1. Triggering Driver Generation: Driver generation is triggered when CFC charts contain standard APL or Basis Library channel driver blocks (Pcs7DiIn, Pcs7DiOu, Pcs7AnIn, Pcs7AnOu) whose hardware inputs are interconnected to symbols in the hardware configuration.

  2. Instantiating @CPU_RT: When channel drivers are detected, the compiler generates a dedicated hidden system chart named @CPU_RT. Inside @CPU_RT, the block CPU_RT monitors cyclic execution times and cycle overflows.

  3. Generating System OBs: To support CPU_RT and hardware monitoring, the compiler automatically generates OB80 (Cycle time exceeded), OB82 (Diagnostic interrupt), OB83 (Insert/remove module), OB85 (Priority class error), OB86 (Rack failure), OB100 (Warm restart), and OB121/OB122 (Programming/access errors).

System Organization Blocks and Driver Generation Matrix

The following table summarizes the system Organization Blocks generated automatically by PCS 7:

Organization BlockFunction / Interrupt DescriptionAutomated PCS 7 Handler BlockGeneration PrerequisiteOB80Cycle time exceeded / Time errorCPU_RT in @CPU_RTAt least 1 driver block with 'Generate Module Drivers'OB82Diagnostic interrupt (I/O wire break, fault)MOD_D1, MOD_HA, MOD_SWDistributed I/O modules configured in HW ConfigOB83Module removal and insertion (Hot-swap)MOD_D1, MOD_HAActive backplane bus modules configuredOB85Program execution error / Area length faultCPU_RT / OB_DIAG1Automated baseline generationOB86Subnet / Rack / Station failureRACK, MOD_D1PROFIBUS DP or PROFINET IO nodes configuredOB100Warm restart / Startup initializationStandard APL startup logicAlways generated by CFC compiler

Step-by-Step Procedure to Generate OB80 and System Charts

To correctly generate OB80 and eliminate S7-PLCSIM or controller halt errors:

  1. Insert a Standard Channel Driver Block:
    - In your CFC chart folder, open any chart (or create a temporary test chart).
    - From the PCS 7 Advanced Process Library (APL), drag a channel driver block—such as Pcs7DiIn (FB1871) or Pcs7AnIn (FB1869)—into the chart.

  2. Interconnect to a Hardware Symbol:
    - In HW Config, configure at least one digital or analog I/O module.
    - In the Symbol Table, assign a symbolic name (e.g., Spare_DI_1) to an input address (e.g., I 0.0).
    - In CFC, connect the PV_In pin of Pcs7DiIn to the symbolic address Spare_DI_1.

  3. Compile CFC with Generate Module Drivers Enabled:
    - In CFC, select Chart -> Compile -> Chart as Program.
    - Ensure the checkbox Generate module drivers is checked.
    - Select Scope: Entire program and click OK.

  4. Inspect Generated Blocks:
    - Open the S7 Program's Blocks folder in SIMATIC Manager.
    - Confirm that OB80, OB82, OB85, and OB86 are now present.
    - In the CFC chart tree, verify that system charts @CPU_RT and @STW4_... have been generated.

  5. Download to PLCSIM or Controller:
    - Download the program to S7-PLCSIM or the physical CPU. The CPU will now run continuously without stopping on time errors.

Verification

Verify system block operation:
1. Open S7-PLCSIM or connect online to the S7-400 CPU.
2. Open the CPU Diagnostic Buffer (PLC -> Module Information -> Diagnostic Buffer).
3. If a temporary cycle time overrun occurs, verify that the diagnostic buffer records 'Cycle time exceeded' but the CPU remains in RUN because OB80 executed and prevented a CPU halt.
4. In CFC, open the @CPU_RT chart online and observe live cycle execution time measurements on CPU_RT.

Limitations and Operational Precautions

  • Never Manually Insert OBs in PCS 7: Manually copying OBs into the Blocks folder corrupts compiler metadata and can cause unpredictable driver generation failures.
  • Cycle Time Limits: While OB80 prevents immediate CPU stoppage during occasional cycle overruns, recurring cycle overruns indicate CPU overload; adjust cyclic interrupt intervals (e.g., increase OB35 from 100 ms to 200 ms).
  • Advanced Process Functions (APF): When using APF or industry-specific add-ons, always ensure the underlying baseline PCS 7 APL hardware drivers are compiled before downloading APF blocks.

Engineer FAQ

Why does the CFC compiler delete OB80 after I manually insert it?

PCS 7 enforces strict automated lifecycle management of system blocks. If an OB is inserted manually without corresponding driver blocks, the Module Driver Generator deletes unmanaged blocks to prevent address conflicts.

What happens if OB80 is called twice in the same cycle?

If the CPU cycle time exceeds the configured maximum cycle time twice within the same cycle period, the CPU enters STOP mode regardless of OB80 presence to protect the process.

Can I edit the code inside OB80 in PCS 7?

No. The code inside OB80 is generated automatically by PCS 7 to invoke the @CPU_RT handler. Any manual edits will be overwritten during the next compile.

Where is the maximum scan cycle time configured?

In HW Config, double-click the S7-400 CPU, open the 'Cycle/Clock Memory' tab, and adjust the 'Scan cycle monitoring time' parameter (default: 6000 ms in PCS 7).

Technical References

Related Articles

Related Tags

  • OB80
  • Module Drivers
  • @CPU_RT
  • S7-PLCSIM
  • Time Error
6 respuestas