Developing S7-SCL Custom Function Blocks with ALARM_8P and Faceplate Integration in SIMATIC PCS 7
Developing custom process control blocks in S7-SCL with full SIMATIC PCS 7 integration (similar to CEMAT C_MEASUR or APL MonAnL) requires implementing the system function block SFB 35 (ALARM_8P) for native alarm generation, embedding standard S7 system attributes for Operator Control and Monitoring (S7_m_c := 'true'), and defining alarm messaging structures via S7_alarm_ui := '1'. By declaring input/output parameters with proper engineering units, quality codes, and OCM attributes in SCL, the PCS 7 OS Compiler automatically transfers tags to WinCC, provisions Alarm Logging message lines, and links the block to standard or custom WinCC block icons and @pg_ faceplates during compilation.
Table of Contents
- Architecture of PCS 7 Compliant Custom SCL Blocks
- Embedding System Attributes for OCM and Alarm Integration
- Implementing ALARM_8P (SFB 35) in S7-SCL
- WinCC OS Compilation and Block Icon / Faceplate Mapping
- Comparison of Custom SCL Blocks vs Standard APL Blocks
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Architecture of PCS 7 Compliant Custom SCL Blocks
While standard PCS 7 libraries (APL, Industry Library, CEMAT) cover the majority of industrial equipment, specialized machinery or legacy migration often demands custom Function Blocks (FBs). In PCS 7, a custom block cannot be a simple mathematical function; it must behave as a fully integrated DCS process object.
A DCS-compliant SCL block must fulfill four mandatory criteria:
1. Deterministic Cyclic Execution: Executed within cyclic interrupt organization blocks (OB 30 to OB 38).
2. Operator Control and Monitoring (OCM): Exposes setpoints, actual values, and statuses to the WinCC OS Server using compiler pragmas.
3. Integrated Message Handling: Incorporates ALARM_8P to generate timestamped alarms synchronized to the controller clock.
4. Graphics Integration: Mates to an OS block icon and faceplate structure for operator interaction.
Embedding System Attributes for OCM and Alarm Integration
In S7-SCL, system attributes govern how the Step 7 CFC compiler and WinCC OS compiler process the block interface:
- Block-Level Attributes:
-{ S7_m_c := 'true' }: Flags the entire function block for OS transfer.
-{ S7_alarm_ui := '1' }: Informs the PCS 7 message configuration editor that this block contains configurable alarm messages.
-{ S7_tasklist := 'OB100' }: Automatically inserts the block into the startup organization block for initialization. - Parameter-Level Attributes:
-{ S7_m_c := 'true' }: Applied to individual input/output pins (e.g.,PV_Out,SP,Status1) to create WinCC tags.
-{ S7_unit := '°C' }and{ S7_string_0 := 'Off', S7_string_1 := 'On' }: Defines engineering units and state texts displayed on faceplates.
Implementing ALARM_8P (SFB 35) in S7-SCL
To deliver native alarm generation identical to APL blocks, instantiate SFB 35 inside the SCL block:
FUNCTION_BLOCK FB1500
{ S7_m_c := 'true'; S7_alarm_ui := '1' }
VAR_INPUT
PV_In : REAL; // Process Value
AH_Lim { S7_m_c := 'true' } : REAL := 100.0; // High Limit
MsgEvId { S7_server := 'alarm_archiv'; S7_a_type := 'alarm_8p'; S7_link := 'false' } : DWORD;
END_VAR
VAR_OUTPUT
PV_Out { S7_m_c := 'true' } : REAL;
AH_Act { S7_m_c := 'true' } : BOOL;
END_VAR
VAR
Alarm8P_Inst : ALARM_8P;
END_VAR
BEGIN
PV_Out := PV_In;
AH_Act := (PV_In >= AH_Lim);
// Call ALARM_8P on state change
Alarm8P_Inst(
EN_R := TRUE,
ID := 16#EEEE,
EV_ID := MsgEvId,
SIG_1 := AH_Act,
SIG_2 := FALSE,
SIG_3 := FALSE,
SIG_4 := FALSE,
SIG_5 := FALSE,
SIG_6 := FALSE,
SIG_7 := FALSE,
SIG_8 := FALSE,
SD_1 := PV_Out
);
END_FUNCTION_BLOCK
WinCC OS Compilation and Block Icon / Faceplate Mapping
Once compiled in SCL, the block integrates seamlessly into the PCS 7 toolchain:
- CFC Placement and Message Configuration: Drag the block into a CFC chart. Right-click the block, select Special Properties > Messages, and configure the message texts (e.g., 'Reactor Temp Too High - @1%f@ °C') and message classes (Alarm High, Warning, Tolerance).
- OS Compilation: Execute 'Compile OS'. The compiler creates the structure tags in WinCC Tag Management and automatically generates alarm lines in WinCC Alarm Logging.
- Block Icon and Faceplate Linking: In WinCC Graphics Designer, create or assign an icon in
@@PCS7Typicals.pdlwith attributetype = @FB1500(or custom name). Create matching faceplate PDL screens (@pg_FB1500_standard.pdland@pg_FB1500_view.pdl). When runtime starts, clicking the icon opens the custom faceplate with zero scripting required.
Comparison of Custom SCL Blocks vs Standard APL Blocks
The following table compares the characteristics of custom-authored SCL blocks versus native PCS 7 APL blocks:
| Engineering Dimension | Custom SCL Block (with ALARM_8P) | Native PCS 7 APL Block |
|---|---|---|---|
| Development Effort | High (Requires SCL coding and PDL design) | Zero (Pre-engineered and tested) |
| Process Object (PO) Billing | Consumes 1 AS RT PO if S7_m_c active | Consumes 1 AS RT PO per instance |
| Maintenance & Upgrades | Maintained by plant engineering team | Maintained and patched by Siemens |
| Alarm Timing & Timestamping | Millisecond resolution via ALARM_8P | Millisecond resolution via ALARM_8P |
| Know-How Protection | Optional; full source code accessible | Proprietary Siemens know-how protected |
| Driver Generator Support | Requires custom XML templates for drivers | 100% Native automatic driver interconnection |
Verification
Verify the custom SCL block in CFC and WinCC Runtime:
1. In CFC test mode, force PV_In above AH_Lim; verify that AH_Act transitions from 0 to 1.
2. Observe the WinCC OS alarm banner; verify that an Alarm High message appears instantly with the exact timestamp and associated value (SD_1).
3. Click the block icon in WinCC Runtime; confirm that the custom faceplate opens, displaying PV_Out and the active alarm state.
4. Acknowledge the alarm from the faceplate; verify that Alarm8P_Inst.ACK_UP resets and the alarm transitions to 'Acknowledged' in the alarm list.
Limitations and Operational Precautions
Never call ALARM_8P cyclically when signal states have not changed. While SFB 35 internally detects edges on SIG_1 to SIG_8, constantly triggering the function with unassigned message IDs can exhaust CPU communication buffers and trigger S7 diagnostic event 0x4540. Always ensure that every instance of the block receives a unique MsgEvId (Message Event ID), which is managed automatically by Step 7 when the block is placed into CFC.
Engineer FAQ
Why did the OS Compiler fail to generate alarms for my custom block?
Ensure that { S7_alarm_ui := '1' } is present in the block header and that the MsgEvId parameter possesses attributes { S7_server := 'alarm_archiv'; S7_a_type := 'alarm_8p'; S7_link := 'false' }. If these attributes are missing, the compiler ignores the alarm interface.
Can I use standard APL faceplates for my custom SCL block?
Yes, provided your custom block exposes the exact same parameter names, data types, and status bit masks (Status1, Status2, OS_Perm) expected by the standard APL faceplate.
What is the difference between SFB 35 (ALARM_8P) and SFB 33 (ALARM)?
SFB 35 (ALARM_8P) transmits up to 8 alarm signals and 10 associated dynamic values (SD_1 to SD_10) in a single network telegram, drastically reducing communication overhead compared to SFB 33 (ALARM), which handles only one signal.
Technical References
- SIMATIC S7-SCL for S7-300/400 Programming Manual
- SIMATIC Process Control System PCS 7 Programming Instructions for Blocks (A9B00057776)
- System Software for S7-300/400 System and Standard Functions (SFB/SFC Reference)
Related Articles
- Configuring ALARM_8P Message Texts and EventState Group Displays for Custom SCL Blocks in SIMATIC PCS 7
- Restoring Off-Screen and Hidden S7-SCL Development Windows in SIMATIC PCS 7 Engineering Stations
- Resolving Jump-Back Navigation and Faceplate Recall Errors for Custom APL Faceplates in SIMATIC PCS 7 WinCC
Related Tags
- S7-SCL
- ALARM_8P
- Custom Blocks
- Faceplates
- OS Compilation