Integrating ALARM_8P Messages and Loop-In Capabilities in Custom PCS 7 SCL Blocks

Integrating ALARM_8P Messages and Loop-In Capabilities in Custom PCS 7 SCL Blocks

To integrate alarm generation and APL-compliant 'Loop-In' capabilities (jumping directly from the WinCC alarm list to the associated CFC chart or faceplate) into custom S7-SCL function blocks in PCS 7, the block must instantiate the system function block ALARM_8P (SFB 35). In the SCL source code, declare a message identifier input parameter of type DWORD with system attributes 'S7_server := alarm_archiv' and 'S7_a_type := alarm_8p' (typically named EV_ID). Declare discrete message triggers (SIG_1 to SIG_8 as BOOL) and associated process values (SD_1 to SD_10 for analog values embedded in message texts). In runtime code, call ALARM_8P on signal state changes. When compiled into CFC, PCS 7 automatically allocates unique message numbers to EV_ID, and OS compilation automatically generates the 8 message templates and Loop-In cross-references in WinCC Alarm Logging.

Table of Contents

Executive Summary

While the SIMATIC PCS 7 Advanced Process Library provides comprehensive function blocks for most process control scenarios, unique chemical recipes, OEM skid packages, and proprietary mathematical algorithms often necessitate custom S7-SCL function blocks. To achieve seamless operational parity with native APL blocks, custom blocks must participate fully in the PCS 7 alarm management ecosystem. By implementing system function block ALARM_8P within the SCL code, annotating formal parameters with Step 7 message attributes, and mapping associated process values, engineers enable automated message number generation, timestamped event logging, and one-click 'Loop-In' navigation from WinCC alarm banners.

Architecture and Fundamental Mechanics

The PCS 7 messaging architecture coordinates alarm detection in the AS controller with historical event display on the OS Server:

  1. The ALARM_8P Mechanism (SFB 35):
    * ALARM_8P is an integrated system function block in S7-400 and CPU 410-5H operating systems.
    * It monitors up to 8 binary signal inputs (SIG_1 through SIG_8) within a single block call.
    * When any signal changes state (0 -> 1 for incoming alarm, 1 -> 0 for outgoing alarm), ALARM_8P captures high-resolution controller timestamps and packages the event with up to 10 associated dynamic process values (SD_1 to SD_10, such as analog temperatures or batch IDs).
    * The AS transmits this package directly to the WinCC OS Server via raw alarm telegrams across the plant bus.
  2. STEP 7 Compiler Attributes for Message Handling:
    * In S7-SCL, declaring message parameters requires special compiler pragmas:
    • EV_ID : DWORD; // S7_server := 'alarm_archiv'; S7_a_type := 'alarm_8p'
    • The pragma S7_server := 'alarm_archiv' signals to the STEP 7 project manager that this parameter holds a system message identifier.
    • The pragma S7_a_type := 'alarm_8p' instructs the message number allocator to assign a block of 8 consecutive message numbers in the project's central message database.
  3. Loop-In Architecture in WinCC:
    * When the OS is compiled, the WinCC message generator extracts the block's plant hierarchy path (e.g., Plant/Area1/Unit2/CustomBlock1) and the chart name.
    * In WinCC Alarm Logging, each generated message record is populated with the block's instance tag name and the @PCS7_LoopIn function pointer.
    * When an operator selects an active alarm in the WinCC alarm banner and clicks the 'Loop-In' button, WinCC reads the origin path and opens the corresponding process picture or launches CFC in read-only test mode centered on the faulty block.

Step-by-Step Implementation Procedure

Follow these programming and engineering procedures to implement ALARM_8P in a custom SCL block:

  1. Declare Message Parameters in S7-SCL:
    * In the SCL source file, define the formal input parameters:
    ```scl
    FUNCTION_BLOCK FB_CustomControl
    TITLE = 'Custom Controller with Alarms'
    AUTHOR : 'Engineer'
    FAMILY : 'Custom'
    NAME : 'CustomFB'
    VERSION : '1.0'

    VAR_INPUT
    // Message Identifier for ALARM_8P
    EV_ID : DWORD := 16#00000000;
    // S7_server := 'alarm_archiv';
    // S7_a_type := 'alarm_8p';

    // Alarm Triggers
    Alm_HighTemp : BOOL := FALSE; // Signal 1
    Alm_LowFlow : BOOL := FALSE; // Signal 2
    Alm_Interlock: BOOL := FALSE; // Signal 3

    // Associated Analog Value
    PV_In : REAL := 0.0;
    END_VAR
    2. **Declare the ALARM_8P Instance in Static Memory**: * In the `VAR` (static) declaration section, declare the multi-instance call for `ALARM_8P`:scl
    VAR
    inst_Alarm8P : ALARM_8P;
    END_VAR
    3. **Invoke ALARM_8P in the Algorithm**: * In the executable body of the function block, call the instance:scl
    BEGIN
    // Call ALARM_8P to evaluate signal states
    inst_Alarm8P(
    EN_R := TRUE,
    ID := 16#EEEE, // Standard internal communication ID
    EV_ID := EV_ID,
    SIG_1 := Alm_HighTemp,
    SIG_2 := Alm_LowFlow,
    SIG_3 := Alm_Interlock,
    SIG_4 := FALSE,
    SIG_5 := FALSE,
    SIG_6 := FALSE,
    SIG_7 := FALSE,
    SIG_8 := FALSE,
    SD_1 := PV_In // Associated analog value
    );
    END_FUNCTION_BLOCK
    `` 4. **Configure Message Texts in STEP 7**: * Compile the SCL source code into an executable FB. * In SIMATIC Manager, right-click the compiled FB in the block folder and select **Special Object Properties > Message...**. * The Message Configuration dialog opens, displaying the 8 message rows: * Row 1 (SIG_1): Set Message Class to **Alarm - High**, Message Text toTemperature High: @1%f@ °C. * Row 2 (SIG_2): Set Message Class to **Warning - Low**, Message Text toFlow Low: @1%f@ m3/h. * Click **Save**. 5. **Instantiate Block in CFC and Compile OS**: * Place the custom block into a CFC chart. * Notice that CFC automatically assigns a unique hexadecimal number toEV_ID. * Wire process signals toAlm_HighTemp,Alm_LowFlow, andPV_In`.
    * Compile the S7 Program and perform an OS Compile.
    * The OS compiler automatically creates the 8 message records in WinCC Alarm Logging.

Verification

Download the program to the AS controller and activate WinCC Runtime. Trigger an alarm condition on the custom block (e.g., set Alm_HighTemp = TRUE). In the WinCC Alarm List, verify that the alarm appears instantly with the correct timestamp, message text, and embedded PV_In value. Select the alarm line and click the Loop-In button in the alarm toolbar; verify that WinCC navigates directly to the process graphic containing the block icon or opens the CFC chart centered on the custom block.

Limitations and Operational Precautions

Ensure that the ID parameter on ALARM_8P is set to 16#EEEE. Using 16#0000 or arbitrary values can disrupt internal S7 communication routing. Do not call multiple ALARM_8P blocks with the identical EV_ID; each ALARM_8P instance must possess its own unique EV_ID parameter.

Engineer FAQ

What does the parameter ID := 16#EEEE mean in ALARM_8P?

16#EEEE is the standardized default channel ID used by PCS 7 and STEP 7 to route messages across the AS-OS communication interface.

How many process values can be associated with an ALARM_8P message?

ALARM_8P supports up to 10 associated values (SD_1 through SD_10), which can be inserted into message texts using formatting placeholders like @1%f@ or @2%d@.

Can I call two ALARM_8P instances in one function block?

Yes. If a custom block requires 16 alarms, you can declare two instances (inst_Alarm1, inst_Alarm2) with separate message IDs (EV_ID_1, EV_ID_2).

Why did CFC assign 0 to EV_ID initially?

In the SCL source, EV_ID defaults to 0. When placed into a CFC chart, the CFC compiler's message number allocator automatically assigns the permanent unique project message ID.

Technical References

Related Articles

Related Tags

  • ALARM_8P
  • SFB 35
  • S7-SCL
  • Custom Blocks
  • Loop-In
  • WinCC Alarm Logging
20 respuestas