Developing Custom APL Blocks in S7-SCL - System Attributes, Automatic Block Icons, and Faceplate Binding in SIMATIC PCS 7

Developing Custom APL Blocks in S7-SCL - System Attributes, Automatic Block Icons, and Faceplate Binding in SIMATIC PCS 7

To create automatic block icons and functional faceplates for custom S7-SCL blocks adhering to the SIMATIC PCS 7 Advanced Process Library (APL) style, engineers must define mandatory S7 system attributes in the SCL source. The block header requires { S7_m_c := 'true' }, visualized elementary parameters require { S7_m_c := 'true' }, and composite structures require { S7_xm_c := 'Value,true;ST,true;' }. After compiling the SCL block and running AS-OS compilation, a corresponding block icon configured with matching block type and index must be added to @PCS7TypicalsV8.pdl (or @PCS7Typicals...), and customized faceplates must reference instance tags using relative dot-notation.

Table of Contents

APL Architecture Principles for Custom Block Development

Developing custom function blocks in SIMATIC PCS 7 that visually and functionally harmonize with the Advanced Process Library (APL) requires adhering to standard APL engineering conventions.

APL blocks separate process execution in the AS from visualization in the OS:
1. AS Controller Algorithm: Written in S7-SCL, executing in cyclic interrupt OBs (e.g., OB32 or OB35), processing control logic and exposing structured input/output variables.
2. OS Process Image: Created automatically during AS-OS compilation (Compile OS), which reads block interface attributes and generates WinCC tag structures.
3. WinCC Block Icons and Faceplates: Embedded graphics in process screens that display current status and open multi-view faceplates upon operator selection.

Mandatory S7 System Attributes in S7-SCL Source Code

To enable SIMATIC Manager and WinCC to recognize custom blocks for HMI transfer, the SCL source must contain explicit system attributes:

FUNCTION_BLOCK FB1500
TITLE = 'Custom_Motor_Control'
{ S7_m_c := 'true';
  S7_tasklist := 'OB100,OB35';
  S7_alarm_ui := 'true' }
AUTHOR : 'Author'
FAMILY : 'USER_LIB'
VERSION : '1.0'

VAR_INPUT
  // Elementary parameter exposed to WinCC
  AutoOn { S7_m_c := 'true' } : BOOL := FALSE;

  // APL-compliant structured analog signal (Value + Signal Status)
  SpExt { S7_m_c := 'true'; 
          S7_xm_c := 'Value,true;ST,true;' } : STRUCT
            Value : REAL := 0.0;
            ST    : BYTE := 16#80; // Good signal status
          END_STRUCT;
END_VAR

VAR_OUTPUT
  // Output signal monitored on WinCC faceplate
  Running { S7_m_c := 'true' } : BOOL := FALSE;
END_VAR

Without the { S7_m_c := 'true' } and { S7_xm_c := ... } attributes, the AS-OS compilation wizard ignores the variables, and WinCC generates no corresponding runtime tags.

Configuring Block Icons in PCS7Typicals and Automatic Generation

To enable the Create/update block icons function in SIMATIC Manager:
1. Open @PCS7TypicalsV8.pdl (or a project-specific typicals file like @PCS7TypicalsUser.pdl) in WinCC Graphics Designer.
2. Copy an existing APL block icon representing a similar device (e.g., a valve or motor icon).
3. Under the block icon's Properties -> System:
- Set type: @Custom_Motor_Control/1 (format: @<BlockFamily_or_Name>/<IconIndex>).
- Set servername: PCS7 Custom_Motor_Control Control or APL_Default.
4. Save the typicals file.
5. In SIMATIC Manager, select the OS station and execute Options -> Plant Hierarchy -> Create/update block icons to automatically instantiate the icon on process screens.

Faceplate Layout and Relative Tag Dynamic Binding

Faceplates are composed of standard modular Picture Description Language (.pdl) files dynamically linked via WinCC Picture Windows:

Faceplate File ComponentStandard File Name TemplateFunctional ContentDynamic Linkage SyntaxOverview Header@PG_CustomBlock_Overview.pdlAlarm banner, lock status, operating modeDirect internal structure tagsStandard View@PG_CustomBlock_Standard.pdlPrimary operator controls, start/stop, setpointsRelative dot-notation (e.g., .Running, .AutoOn)Parameter View@PG_CustomBlock_Parameter.pdlTuning parameters, monitoring times, limitsRelative dot-notation (e.g., .TI, .Gain)Alarm View@PG_CustomBlock_Alarm.pdlBlock-specific chronological alarmsUses WinCC AlarmControl filtered by TagPrefix

By prefixing all dynamic tags inside the faceplate PDL with a dot (e.g., .Running), WinCC automatically prepends the block instance TagPrefix assigned when the block icon is clicked.

Verification

To confirm that the custom SCL block, block icon, and faceplate operate correctly:
1. Compile the S7-SCL source file and verify compilation completes with 0 errors and 0 warnings.
2. Instantiate the custom block inside a test CFC chart, assign inputs, and compile CFC.
3. Execute AS-OS compilation; open WinCC Explorer Tag Management and confirm the instance tag structure appears under the S7 Named Connections channel.
4. Run Create/update block icons; open the target process mimic in Graphics Designer and verify the block icon was generated with correct coordinate tags.
5. Activate WinCC Runtime, click the block icon, and verify that the custom faceplate opens, displays live AS data, and responds to operator commands without script runtime errors.

Limitations and Operational Precautions

Never edit default Siemens template files like @PCS7TypicalsV8.pdl directly without maintaining backup copies. The manufacturer recommends copying typical icons into a user file named @PCS7TypicalsProject.pdl. Direct edits to Siemens standard templates will be overwritten during OS Project Editor execution or PCS 7 Service Pack updates.

Engineer FAQ

What is the difference between S7_m_c and S7_xm_c?

S7_m_c is assigned to elementary data types (BOOL, REAL, INT) to expose them to WinCC. S7_xm_c is used on composite STRUCT variables to specify which internal structure elements (e.g. Value, ST) should be transferred to WinCC.

Why did 'Create/update block icons' skip my custom block in CFC?

Ensure that the block instance in CFC has the 'OCM possible' (Operator Control and Monitoring) property checked in its Object Properties, and that the block type name matches the @<Type>/<Index> string in @PCS7Typicals.

Why must dynamic tags in faceplate PDLs begin with a dot?

The leading dot instructs WinCC to treat the tag as a relative path. When the faceplate opens, WinCC assigns the block instance hierarchy (TagPrefix), prepending it to create the full tag path (Chart1/Block1.Running).

Can custom blocks use Alarm_8P for diagnostic messaging?

Yes. Add the attributes { S7_server := 'alarm_8p' } and { S7_a_type := 'alarm_8p' } to an internal ID parameter, and call system function block SFB35 ALARM_8P within the SCL algorithm.

Technical References

Related Articles

Related Tags

  • S7-SCL
  • APL Styleguide
  • Block Icons
  • Custom Faceplates
  • TagPrefix
6 respuestas