Implementing Multi-State Operating Modes Using APL Faceplate Buttons in SIMATIC PCS 7

Implementing Multi-State Operating Modes Using APL Faceplate Buttons in SIMATIC PCS 7

In SIMATIC PCS 7 APL, standard button objects such as APL_OP_BUTTON3 in @PCS7ElementsAPL.pdl are engineered strictly for discrete binary operations (writing BOOL pulses to block inputs like AutModOp, ManModOp, or OosOp), rather than writing direct numeric integers (0, 1, 2) to a byte tag. To implement a 4-state operating mode in APL style, create dedicated binary command inputs on your custom CFC block (Mod0Op, Mod1Op, etc.) wired to an APL_OP_BUTTON structure, converting the pulse to the internal mode byte in SCL before auto-resetting. Alternatively, standard WinCC buttons can execute direct C/VBScript writes to a byte tag.

Table of Contents

Executive Summary

Process engineers designing custom equipment blocks (such as multi-position diverter valves, batch phase controllers, or multi-stage compressors) often require switching between multiple discrete operating modes (e.g., Mode 0: Closed, Mode 1: Manual Open, Mode 2: Auto, Mode 3: Maintenance). While the controller typically stores this state in an internal BYTE or INT tag, engineers frequently attempt to use APL_OP_BUTTON3 from @PCS7ElementsAPL.pdl to directly write numeric constants to that byte. This results in failure because standard APL operator buttons operate on discrete BOOL pulse mechanics. Conforming to APL architecture requires either implementing APL-compliant binary operator inputs with automatic block-level reset or deploying WinCC script actions that write bitmasks or raw byte values directly.

Architecture and Fundamental Mechanics

Analyzing multi-state mode switching requires understanding the difference between standard WinCC SCADA scripting and deterministic PCS 7 APL command processing.

1. APL Command Philosophy: Edge-Triggered Boolean Handshakes

In standard Siemens APL blocks (MotL, VlvL, PIDConL), multi-state modes are never commanded by writing raw numbers directly into internal state variables. Instead, the APL architecture enforces:
- Discrete Operator Inputs: Each mode possesses a separate BOOL input parameter (e.g., ManModOp, AutModOp, OosOp).
- Attribute Tagging: Each input is tagged with system attributes: S7_m_c = 'true', S7_xm_c = 'Value,true;', and Op_Level.
- Single-Cycle Handshake: When an operator clicks 'Auto', WinCC sets AutModOp = TRUE. In the next CPU scan cycle, the AS block detects the pulse, validates interlocks, updates the internal state byte Mode = 2, and immediately resets AutModOp = FALSE.
- This handshake ensures deterministic multi-client operation, prevents command freezing, and maintains compliance with PCS 7 Electronic Signature and Audit Trail.

2. The Structure of APL_OP_BUTTON3

The APL_OP_BUTTON3 object provides three discrete buttons within an aligned container. Each button has its own independent linking properties: BinLink1, BinLink2, BinLink3, linked to their respective BinAuthorizationLevel1..3. It is structurally incapable of writing 0, 1, 2 to a single byte variable without custom script modifications.

Step-by-Step Implementation Procedure

To implement a robust 4-mode selector conforming to PCS 7 APL conventions:

Method 1: The APL-Compliant Architecture (Recommended)

  1. Define Block Inputs in SCL:
    - In your custom SCL block, declare discrete operator inputs and the internal mode byte:
    scl VAR_INPUT Mode0_Op {S7_m_c := 'true'; S7_visible := 'true'} : BOOL; // Select Mode 0 (Off/Closed) Mode1_Op {S7_m_c := 'true'; S7_visible := 'true'} : BOOL; // Select Mode 1 (Manual Open) Mode2_Op {S7_m_c := 'true'; S7_visible := 'true'} : BOOL; // Select Mode 2 (Automatic) Mode3_Op {S7_m_c := 'true'; S7_visible := 'true'} : BOOL; // Select Mode 3 (Maintenance) END_VAR VAR_OUTPUT Mode_Act {S7_m_c := 'true'} : BYTE := 16#00; // Active Mode Byte END_VAR
  2. Implement Mode Logic and Auto-Reset in SCL:
    scl IF Mode0_Op THEN Mode_Act := 16#00; Mode0_Op := FALSE; // Self-resetting pulse ELSIF Mode1_Op THEN Mode_Act := 16#01; Mode1_Op := FALSE; ELSIF Mode2_Op THEN Mode_Act := 16#02; Mode2_Op := FALSE; ELSIF Mode3_Op THEN Mode_Act := 16#03; Mode3_Op := FALSE; END_IF;
  3. Configure Faceplate Buttons in WinCC:
    - In the custom faceplate PDL, place an APL_OP_BUTTON object configured with BinCount = 4 (or use @PG_APL_OA_Binary105.pdl).
    - Map BinLink1 to Mode0_Op, BinLink2 to Mode1_Op, BinLink3 to Mode2_Op, and BinLink4 to Mode3_Op.

Method 2: Direct WinCC Script Writing to Byte Tag (Alternative)

  1. In Graphics Designer, place four standard Windows Button objects (e.g., 'Mode 0', 'Mode 1', 'Mode 2', 'Mode 3').
  2. On the Mouse Click event of Button 1, write a C-Action:
    c #include "apdefap.h" void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) { SetTagByte(GetTagPrefix(lpszPictureName, "Mode_Act"), 0); }
  3. On Button 2, write SetTagByte(..., 1); on Button 3, write SetTagByte(..., 2); on Button 4, write SetTagByte(..., 3).

Verification

To verify proper mode switching operation:

  1. CFC Online Inspection:
    - Open the CFC chart online and monitor Mode_Act.
    - Click each mode button in the WinCC faceplate in sequence.
    - Confirm that Mode_Act transitions instantly to 00, 01, 02, and 03.
    - Verify that all ModeX_Op input variables remain FALSE after the command cycle executes.

  2. Interlock and Audit Trail Verification:
    - If Audit Trail or Electronic Signature is enabled, verify that operator mode transitions generate chronological operator audit entries in WinCC Alarm Logging.

Limitations and Operational Precautions

Operational limitations and precautions:

  1. Direct Byte Overwriting Risks: In Method 2, writing directly to Mode_Act bypasses AS interlocks. If an interlock prevents switching to Mode 2, a direct byte write forces the state regardless, unless complex AS validation logic overrides it.
  2. Multi-Operator Collisions: Writing discrete boolean pulses ensures that simultaneous operator actions across multiple OS Clients are serialized deterministically by the CPU scan cycle.
  3. Maximum Buttons in APL_OP_BUTTON: Standard @PG_APL_OA_Binary105.pdl supports up to 5 buttons. Projects requiring more than 5 modes require custom script redesign.
  4. Commercial Disclaimer: Verify all software libraries, engineering tools, and system components with an authorized Siemens distributor or the Siemens Industry Mall.

Engineer FAQ

Can APL_OP_BUTTON3 write numeric integer values directly?

No. APL_OP_BUTTON3 is designed solely to toggle or pulse discrete binary (BOOL) variables mapped to BinLink1 through BinLink3.

Why do standard APL blocks reset operator inputs back to FALSE?

Auto-resetting operator inputs ensures that commands act as single-cycle pulses. This prevents commands from remaining stuck high if a client disconnects.

How many buttons can be configured in a single APL_OP_BUTTON element?

Standard APL objects natively support up to 5 buttons by configuring the BinCount property and linking @PG_APL_OA_Binary105.pdl.

What is the disadvantage of using SetTagByte in WinCC C-scripts?

Directly writing to a byte tag bypasses AS-level interlock verification and makes it harder to implement standard PCS 7 operator prompt/confirmation dialogs.

Can I use radio buttons instead of APL_OP_BUTTON?

Yes, standard WinCC radio box controls can be bound to a byte tag, but they do not incorporate APL security, area authorization, or faceplate styling.

Technical References

Related Articles

Related Tags

  • APL_OP_BUTTON
  • Multi-State Modes
  • SCL Programming
  • WinCC Faceplate
  • APL Architecture
20 respuestas