How to Implement Custom PCS 7 APL Faceplates with APL_OP_BUTTON Operating Mode Switching and SCL Authorization Logic

How to Implement Custom PCS 7 APL Faceplates with APL_OP_BUTTON Operating Mode Switching and SCL Authorization Logic

To implement custom PCS 7 APL faceplates with operational mode switching, configure your custom SCL function block with operator command inputs (.AutModOp, .ManModOp, .OosOp) marked with attribute S7_m_c := 'true'. Define internal double-word permission inputs (OS_Perm) and outputs (OS_PermLog), using SCL 'AT' overlays to map individual mode authorization bits. In WinCC Graphics Designer, place the APL_OP_BUTTON object, link its permission tag to .OS_PermLog, and connect the mode status bits to .Status1 so the faceplate dynamically identifies the current state. Finally, register the button's object name inside the faceplate's stUser configuration object to enforce user authorization levels dynamically.

Table of Contents

Architecture of PCS 7 APL Custom Faceplates and Mode Switching

The SIMATIC PCS 7 Advanced Process Library (APL) provides a standardized, ergonomic human-machine interface (HMI) framework. When developing custom function blocks (such as specialized drives, dosing skids, or complex multi-stage valves) that integrate seamlessly into PCS 7, engineers frequently utilize APL faceplate components such as the APL_OP_BUTTON object and standard operating windows (e.g., @pg_apl_oa_binary105.PDL).

In the APL design philosophy, mode switching (Automatic, Manual, and Out of Service) requires coordinated interaction between three layers:
1. Automation Station (AS) SCL Code: The function block evaluates operational commands (AutModOp, ManModOp, OosOp), checks interlocks, enforces operator authorizations (OS_Perm), and updates internal status words (Status1, OS_PermLog).
2. WinCC Tag Management and AS-OS Engineering: Outputs and inputs tagged with S7_m_c := 'true' are compiled into WinCC OS tags with appropriate structure prefixes.
3. WinCC Faceplate Graphics and C-Scripts: The faceplate reads status words to color-code buttons, displays active operating modes, and calls standard C-actions (such as opening @pg_apl_oa_binary105.PDL) when an operator clicks an operating button. If configuration links are misaligned, buttons will either remain permanently greyed out or appear active simultaneously without responding to user clicks.

SCL Function Block Interface and S7_m_c Attribute Requirements

To enable WinCC faceplates to read status and send mode commands, specific block inputs and outputs must be declared in SCL with the S7_m_c (SIMATIC S7 Monitoring and Controlling) attribute:

FUNCTION_BLOCK FB1850
TITLE = 'Custom Motor with APL Mode Control'
{ S7_m_c := 'true'; S7_blockview := 'big' }
AUTHOR : 'EngTeam'
FAMILY : 'APL_CUST'

VAR_INPUT
    AutModOp { S7_m_c := 'true' } : BOOL := FALSE; // 1 = Operator switches to Auto mode
    ManModOp { S7_m_c := 'true' } : BOOL := FALSE; // 1 = Operator switches to Manual mode
    OosOp    { S7_m_c := 'true' } : BOOL := FALSE; // 1 = Operator switches to Out of Service
    ModLiOp  { S7_m_c := 'true' } : BOOL := FALSE; // 0 = Operator mode, 1 = Interconnected mode
    AutModLi : BOOL := FALSE;                      // Interconnected Auto command
    ManModLi : BOOL := FALSE;                      // Interconnected Manual command
    OS_Perm  { S7_m_c := 'true' } : DWORD := 16#FFFFFFFF; // Operator permission input
END_VAR

VAR_OUTPUT
    Status1    { S7_m_c := 'true' } : DWORD := 16#00000000; // APL Status word 1
    OS_PermLog { S7_m_c := 'true' } : DWORD := 16#FFFFFFFF; // Effective operator permission
    AutAct     { S7_m_c := 'true' } : BOOL := FALSE;        // 1 = Auto mode active
    ManAct     { S7_m_c := 'true' } : BOOL := TRUE;         // 1 = Manual mode active
    OosAct     { S7_m_c := 'true' } : BOOL := FALSE;        // 1 = Out of service active
END_VAR

When an operator clicks a mode selection button in the faceplate, WinCC momentarily sets the corresponding *ModOp tag to 1. In the AS execution cycle, the block resets the command after processing.

Mapping OS_Perm and OS_PermLog with SCL AT Views

The OS_Perm double word allows engineers to enable or disable specific operator actions from the CFC chart or supervisory logic. The effective permission is output on OS_PermLog, which the faceplate reads to activate or deactivate buttons.

To manipulate individual bits cleanly without error-prone bit-masking in SCL, declare an AT view on OS_Perm and OS_PermLog:

VAR_INPUT
    OS_Perm { S7_m_c := 'true' } : DWORD := 16#FFFFFFFF;
    OS_Perm_Bits AT OS_Perm : STRUCT
        Bit0_Auto   : BOOL; // Bit 0: 1 = Operator can switch to Auto
        Bit1_Manual : BOOL; // Bit 1: 1 = Operator can switch to Manual
        Bit2_OOS    : BOOL; // Bit 2: 1 = Operator can switch to Out of Service
        Reserved    : ARRAY [3..31] OF BOOL;
    END_STRUCT;
END_VAR

VAR_TEMP
    dwStatus1 : DWORD;
    stStatus1 AT dwStatus1 : STRUCT
        Occupied   : BOOL;
        AutoMode   : BOOL; // Bit 1: 1 = Auto active
        ManualMode : BOOL; // Bit 2: 1 = Manual active
        OosMode    : BOOL; // Bit 3: 1 = Out of Service active
        Spare      : ARRAY [4..31] OF BOOL;
    END_STRUCT;
END_VAR

// Logic:
stStatus1.AutoMode := AutAct;
stStatus1.ManualMode := ManAct;
stStatus1.OosMode := OosAct;
Status1 := dwStatus1;
OS_PermLog := OS_Perm; // Pass through or mask based on interlock conditions

This ensures that bit positions in Status1 and OS_PermLog match the exact expectations of APL faceplate scripts.

Configuring APL_OP_BUTTON and Operating Area Scripts in WinCC

In WinCC Graphics Designer, when configuring custom faceplates based on @pg_apl_template.PDL or copying standard faceplate views (such as @pg_apl_pidconl_standard.PDL):
1. Button Object Properties:
* Select the APL_OP_BUTTON instance (often named csoStMode).
* In the Properties window under Permission, configure PermissionTag to point to .OS_PermLog. If operator permissions are not restricted, set PermissionTag to empty or 0.
* Under Links, connect BinLink 1 to .AutModOp, BinLink 2 to .ManModOp, and BinLink 3 to .OosOp.
2. Dynamic Mode State (csoStMode):
* Link the status property of csoStMode to tag .Status1. The APL C-script evaluates bits 1, 2, and 3 of Status1 to display the active mode text ('Auto', 'Manual', 'Out of Service') and toggle button styling.
3. Registering in stUser:
* The faceplate contains a non-visual configuration object named stUser.
* Open the properties of stUser and ensure that the object name of your APL_OP_BUTTON is listed in its property fields. This links the button to the active user authorization level (e.g., Authorization Level 5: Process Controlling, or Level 6: Higher-Ranking Process Controlling).
4. Diagnostic Script Debugging with APDIAG:
* If buttons do not open @pg_apl_oa_binary105.PDL or fail to toggle modes, open apdiag.exe located in C:\Program Files (x86)\Siemens\WinCC\uTools\apdiag.exe.
* In APDIAG, select Output Window and enable runtime script tracing. C-script execution errors, missing tag names, or syntax faults will output directly to the diagnostics window.

Summary of APL Faceplate Mode Parameters and Link Properties

The table below summarizes the required block parameters and their corresponding WinCC faceplate links for APL mode switching.

Parameter NameData TypeDirectionS7_m_cDescription / APL Link PropertyAutModOpBOOLInputtrueOperator command: Switch to Automatic. Linked to BinLink 1.ManModOpBOOLInputtrueOperator command: Switch to Manual. Linked to BinLink 2.OosOpBOOLInputtrueOperator command: Switch to Out of Service. Linked to BinLink 3.OS_PermDWORDInputtrueOperator permissions input configured in CFC chart.OS_PermLogDWORDOutputtrueEffective operator permission mask. Linked to PermissionTag.Status1DWORDOutputtrueStatus word 1. Bits 1..3 indicate active mode for csoStMode.AutActBOOLOutputtrueOperational feedback: Automatic mode currently active.ManActBOOLOutputtrueOperational feedback: Manual mode currently active.OosActBOOLOutputtrueOperational feedback: Out of Service mode currently active.

Verification

To verify correct operation of the custom APL faceplate:
1. Compile the CFC chart containing the custom block, perform an AS download, and execute an OS Compilation (Changes only).
2. Open WinCC Runtime on an OS Client or ES. Click the custom block icon to open the custom faceplate.
3. Verify that the current operating mode ('Manual' or 'Auto') is displayed correctly on the csoStMode button.
4. Click csoStMode to open the standard mode selection window (@pg_apl_oa_binary105.PDL).
5. Select 'Auto' mode and confirm. Observe in the CFC chart that AutAct becomes TRUE, ManAct becomes FALSE, and the faceplate button updates its text and visual highlight to 'Auto'.
6. Run apdiag.exe and confirm that zero C-script runtime errors or missing tag warnings occur during faceplate opening and mode toggling.

Limitations and Operational Precautions

  • Never modify original Siemens @pg_*.PDL files directly in the @Default_Templates folder; always save custom faceplates with a unique prefix (e.g., @pg_custom_*.PDL) to prevent system updates from overwriting changes.
  • Ensure all tags referenced in C-scripts exist in the WinCC Tag Management database; missing tags cause script execution delays and freeze the WinCC graphics runtime engine.
  • Mode commands (AutModOp, ManModOp, OosOp) must be reset to FALSE by the SCL block logic after one cycle; failing to reset them causes continuous mode overwriting.
  • Check that user authorization levels assigned in the WinCC User Administrator match the authorization level configured on the faceplate buttons.

Engineer FAQ

Why are all mode buttons active simultaneously on my custom faceplate?

When all mode buttons appear active or selected at the same time, the faceplate script is failing to read the .Status1 tag or the bit offsets in .Status1 do not match standard APL expectations. In standard APL faceplates, specific bit positions represent Manual, Auto, and Out of Service. If .Status1 is zero or unlinked, the script cannot evaluate the current state and defaults to showing all states.

What does the 'stUser' object do in an APL faceplate?

The stUser object is an invisible configuration control within APL faceplates that monitors Windows user logons via SIMATIC Logon. When a user logs in, stUser checks their authorization level in WinCC User Administrator and dynamically enables or disables operator controls (like APL_OP_BUTTON) based on user rights.

How do I troubleshoot script errors when clicking faceplate buttons?

Launch apdiag.exe from C:\Program Files (x86)\Siemens\WinCC\uTools\apdiag.exe. Open the Output Window (Output Window > Set Focus) and click the problematic button in WinCC Runtime. APDIAG will display the exact script function name, line number, and error code (such as error 1007001 for tag not found).

Technical References

Related Articles

Related Tags

  • APL
  • Faceplate Design
  • APL_OP_BUTTON
  • SCL Programming
  • apdiag
6 respuestas