Function and Persistence of Bit Memory Variables in PCS 7 SFC Types

Function and Persistence of Bit Memory Variables in PCS 7 SFC Types

In SIMATIC PCS 7 SFC Types, Bit Memory variables are internal static flags stored within the SFC instance's dedicated Data Block (DB). They execute as part of the SFC state machine cyclically within the calling Organization Block (typically OB35). Bit Memory values persist across sequence step transitions, holds, and resumes; they are never wiped during normal operation unless explicitly overwritten by an SFC step action or reset to default upon a cold CPU restart or full program download.

Table of Contents

Executive Summary

Sequential Function Chart Types (SFC Types) in SIMATIC PCS 7 enable standardized, modular procedural automation across complex process equipment. When designing sequencers, engineers frequently require intermediate flags to track transient process events, record whether specific branches completed, or store interlock bypass permissions across multiple steps. In the SFC Type editor, these flags are defined under the 'Characteristics' tree as 'Bit Memory'.

A common uncertainty among automation engineers is the lifecycle and persistence of Bit Memory: does a saved flag survive if an operator pauses or holds the sequence? Does it reset upon step transitions or CPU transitions? This guide details the memory allocation architecture of Bit Memory variables, examines their behavior across operational state transitions (Hold, Resume, Abort), and outlines best practices for deterministic state tracking in PCS 7.

Architecture and Fundamental Mechanics

The memory model of SFC Types is deeply tied to the Step 7 data block execution environment:

  1. Storage in Instance Data Blocks: When an SFC Type is compiled, the compiler produces an S7 Function Block (FB). When an instance of this SFC Type is placed in a CFC chart, Step 7 allocates an Instance Data Block (DB). Every attribute declared in the SFC Type characteristics—including inputs, outputs, setpoints, timers, and Bit Memory—is allocated a fixed physical address within the static (STAT) variable area of that instance DB.

  2. Cyclic Execution: During controller runtime, the SFC instance FB is invoked cyclically by an Organization Block (e.g., OB35 at 100 ms). During each scan, the SFC engine evaluates the active step's actions and transition conditions. Any write operation to a Bit Memory variable (e.g., BitMemory_1 := TRUE) writes directly into the instance DB's static data memory.

  3. Persistence Across Operational States:
    - Step Transitions: When the sequencer advances from Step N to Step N+1, static variables in the DB are untouched. The value stored in Bit Memory remains identical.
    - Hold and Resume Sequences: If an operator or safety interlock forces the sequence into HOLDING or HELD state, the CPU continues scanning the instance DB. The value stored in Bit Memory is fully retained. When the sequencer transitions through RESUMING back to RUNNING, the saved value is 100% available.
    - CPU Warm Restart: During an S7-400 warm restart (RUN -> STOP -> RUN without memory reset), static DB variables configured as retentive retain their last values.
    - Reset Triggers: Bit Memory resets to its configured default value ONLY under three circumstances: (a) An SFC step action explicitly writes a new value, (b) A full program compilation and download of the instance DB is performed, or (c) A cold CPU restart / memory reset (MRES) occurs.

Step-by-Step Implementation Procedure

Follow these steps to declare, use, and manage Bit Memory variables in PCS 7 SFC Types:

  1. Open the SFC Type in Edit Mode:
    - In SIMATIC Manager, open your Master Data Library or project Charts folder.
    - Double-click the target SFC Type to open the SFC Editor.

  2. Declare the Bit Memory Characteristic:
    - In the left-hand navigation pane, expand the 'Characteristics' folder.
    - Right-click 'Bit Memory' and select 'Insert Object' (or press Insert).
    - In the properties dialog:

    • Name: Assign a descriptive technological name (e.g., Dose_Completed_Flag or Agitator_Was_Started).
    • Data type: BOOL.
    • Initial value: FALSE (0).
    • Comment: Document the operational purpose of the flag.
    • Click 'OK'.
  3. Assign Value in Step Actions:
    - In the SFC sequencer topology, open the step where the condition originates (e.g., Step_Dosing_Complete).
    - Open 'Object Properties' and navigate to the 'Termination' (or 'Initialization') tab.
    - Add an action line:
    Dose_Completed_Flag := TRUE
    - Click 'Apply' and 'Close'.

  4. Evaluate Bit Memory in Subsequent Transitions:
    - Open a downstream transition (even several steps later or within an alternative branch).
    - In the transition condition editor, insert an evaluation line:
    Transition_Check: Dose_Completed_Flag = TRUE
    - Combine with other process conditions as needed.

  5. Implement Deterministic Reset Logic:
    - Always ensure your sequence explicitly clears internal flags when the sequence completes or resets.
    - In the final step of the sequencer (or within the COMPLETING or ABORTING sequencer), add a reset action in the 'Initialization' tab:
    Dose_Completed_Flag := FALSE
    - This guarantees the flag does not linger in an active state when a new batch or sequence run starts.

  6. Save, Compile, and Synchronize:
    - Save the SFC Type and execute 'SFC > Compile'.
    - In SIMATIC Manager, execute 'Options > Charts > Update Block Types...' to propagate the updated instance DB structure to all chart instances.

Verification

  1. In the CFC Editor, open a chart containing an instance of the SFC Type and switch to Test Mode (Online).
  2. Open the SFC instance: observe the step sequencer advancing.
  3. Verify that when the sequence passes the initialization step, Dose_Completed_Flag switches from 0 to 1.
  4. Trigger an intentional Hold command (via faceplate or test input): observe the sequence entering HELD state. Confirm in the online variable table that Dose_Completed_Flag remains 1.
  5. Issue a Resume command: verify that the sequencer resumes execution and successfully advances past transitions evaluating Dose_Completed_Flag = TRUE.
  6. Let the sequence finish: verify that the cleanup step resets the flag back to 0.

Limitations and Operational Precautions

Do not use Bit Memory for safety-critical interlocks that must survive controller power cycling without battery backup; safety interlocks must be hardwired into fail-safe CFC logic. If an SFC Type is modified by adding or removing characteristics, performing a download in RUN (CiR) may be restricted if the total instance DB size exceeds available reserved work memory. Verify all engineering tools and licensing options through an authorized Siemens distributor or the Siemens Industry Mall.

Engineer FAQ

Will my Bit Memory value be erased if the sequence enters HELD state?

No. Bit Memory is a static variable inside the instance Data Block. Pausing, holding, or resuming the sequencer does not clear or alter its value.

What is the difference between Bit Memory and an internal Step flag?

Step flags (such as Step.X or Step.TI) are active only while that specific step is executing. Bit Memory retains its value indefinitely across any number of subsequent steps until explicitly overwritten.

Can Bit Memory be accessed from external CFC charts?

Bit Memory declared strictly as internal characteristics is private to the SFC Type. If external CFC blocks need to read or write the flag, declare it under 'Inputs/Outputs' or 'Control Strategies' instead of Bit Memory.

What happens to Bit Memory during a CPU warm restart?

During a warm restart (RUN -> STOP -> RUN), retentive DB memory is preserved, meaning Bit Memory retains its pre-stop value unless reset in startup OB100.

Can I declare multiple Bit Memory variables in a single SFC Type?

Yes. You can declare dozens of individual Bit Memory boolean flags to manage diverse branches and sequential conditions within the SFC Type.

Technical References

Related Articles

Related Tags

  • SFC Type
  • Bit Memory
  • Static Variables
  • Instance DB
  • Sequence Hold
  • PCS 7 V9.1
20 respuestas