Defining Block Contacts with S7_contact Attribute for SFC Types in SIMATIC PCS 7
To include a custom Function Block as a 'Block Contact' in a SIMATIC PCS 7 SFC Type, you must assign the system attribute 'S7_contact := \'true\'' to at least one of the block's input or output parameter declarations in its source code (e.g. SCL or LAD/FBD). The SFC Type editor scans the project block library specifically for blocks bearing this attribute. After recompiling the block source code, open the SFC Type, navigate to 'Options > Block Contacts' to update the catalog, and the custom block will be available under 'Characteristics > Block Contacts' for direct sequencer read and write operations.
Table of Contents
- Executive Summary
- Architecture and Fundamental Mechanics
- Step-by-Step Implementation Procedure
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Executive Summary
In SIMATIC PCS 7 (V8.0 through V9.1), object-oriented sequential programming using SFC Types relies on 'Block Contacts' (Bausteinkontakte) to interact directly with technological control modules (such as motors, valves, analog monitors, and custom algorithmic blocks). When engineers develop proprietary Function Blocks (FBs) in S7-SCL and attempt to include them inside an SFC Type, they frequently find that the custom block is missing from the 'Block Contacts' selection dialog. This article explains the internal mechanics of SFC Type block contacts, provides the required SCL attribute syntax, and outlines the synchronization procedure.
Architecture and Fundamental Mechanics
Architectural Mechanics of Block Contacts in SFC Types:
- Role of Block Contacts in Object-Oriented SFC Design:
- An SFC Type is a generic, reusable class template. It cannot contain hardcoded absolute connections to specific chart addresses.
- To manipulate field devices (e.g. starting a motor, opening a valve, or reading an interlock), the SFC Type defines an abstract interface called a Block Contact.
- Inside the sequencer steps and transitions, the engineer programs actions and conditions against the logical pins of the Block Contact (e.g.
Motor1.AutModLi = 1,Motor1.FbkRunOut = 1). -
When the SFC Type is instantiated on a CFC chart as an SFC Instance, the engineer simply connects the Block Contact interface to the physical block instance on the chart.
-
The
S7_contactAttribute Requirement: - The SFC Type editor does not display all arbitrary FBs from the block library in the Block Contacts catalog. Exposing every internal block would clutter the interface.
- To make an FB eligible as a Block Contact, STEP 7 requires the system attribute:
{ S7_contact := 'true' } - This attribute must be assigned to at least one I/O parameter in the block's declaration header.
-
Parameters intended for dynamic animation or OS visualization should also include
{ S7_dynamic := 'true' }. -
Catalog Synchronization:
- Recompiling an SCL source file registers the attribute in the block's compiled interface descriptor (
.s7f). - The SFC Type editor caches the block contact list; executing Options -> Block Contacts -> Update flushes the cache and integrates the newly declared block.
Step-by-Step Implementation Procedure
Step-by-Step Procedure to Declare and Integrate Block Contacts in SFC Types:
- Edit Custom Block Source Code in SCL:
- Open the SCL source file of your custom Function Block in the S7 Program Sources folder.
- Locate the I/O parameters you wish to access from the SFC sequencer.
- Assign the{ S7_contact := 'true' }attribute to one or more parameters. For example:
scl FUNCTION_BLOCK FB2500 TITLE = 'CustomDosingPump' VAR_INPUT StartAut { S7_dynamic := 'true'; S7_contact := 'true' } : BOOL; StopAut { S7_dynamic := 'true'; S7_contact := 'true' } : BOOL; FlowSp { S7_dynamic := 'true'; S7_contact := 'true' } : REAL; END_VAR VAR_OUTPUT Running { S7_dynamic := 'true'; S7_contact := 'true' } : BOOL; Fault { S7_dynamic := 'true'; S7_contact := 'true' } : BOOL; END_VAR - Compile SCL Source:
- In the SCL editor, select menu File -> Compile (Ctrl+B).
- Ensure the block compiles with 0 errors, generating the updated FB in the Blocks folder. - Update Block Contacts in SFC Type Editor:
- Open the target SFC Type in SIMATIC Manager.
- In the SFC Type menu, select Options -> Block Contacts....
- In the dialog, click the Update button.
- Verify that your custom block (e.g.FB2500 - CustomDosingPump) appears in the list of recognized technological blocks.
- Select the block and click OK. - Add Block Contact to SFC Characteristics:
- In the SFC Type tree window, open Characteristics -> Block Contacts.
- Right-click Block Contacts -> Insert New Technological Object.
- Name the block contact instance (e.g.Pump_Dosing).
- In Object Properties, select your custom block type from the Block Type dropdown. - Use in Sequencer Steps and Transitions:
- Open a step in the SFC sequencer -> open the Object Properties -> Actions tab.
- In the target list, browse toPump_Dosing.StartAut; assign the commandTRUE.
- Open the succeeding transition; configure the conditionPump_Dosing.Running = TRUE. - Update Block Types in CFC:
- Open any CFC chart -> select Options -> Block Types -> select the SFC Type and click Update....
Verification
Verification Procedure:
1. Editor Characteristic Check: In the SFC Type editor, verify that Pump_Dosing appears under Characteristics with all declared I/O pins visible.
2. CFC Interconnection Verification: Open the CFC chart where the SFC Type is instantiated. Verify that the SFC block icon displays the technological Block Contact pin group and can be interconnected to the custom pump block.
3. Test Mode Execution: Enter SFC Test Mode online; trigger the sequencer and confirm that the step action successfully writes to the custom block's StartAut input.
Limitations and Operational Precautions
Operational Precautions and Interface Update Rules:
- Parameter Access Scope: An SFC Type can only manipulate parameters explicitly declared with S7_contact := 'true'. Hidden internal parameters cannot be written directly by block contacts.
- Interface Timestamps: Modifying attributes on an existing block changes its interface timestamp. In standard S7-400 systems, updating block types requires an AS download in STOP unless using CPU 410 Type Change in RUN (TCiR).
- Standard APL Blocks: Standard APL blocks (MotL, VlvL, PIDConL) have S7_contact := 'true' pre-configured by Siemens out of the box.
Engineer FAQ
What attribute must be added to a custom block to make it a Block Contact?
The attribute { S7_contact := 'true' } must be added to at least one I/O parameter in the block source code.
Why doesn't my custom block appear in the SFC Type Block Contacts list?
Because none of the block's parameters possess the S7_contact := 'true' system attribute, or the SFC block contact catalog was not updated via 'Options -> Block Contacts'.
Where do I update the Block Contacts list in the SFC editor?
In the SFC Type editor menu under Options -> Block Contacts..., then click Update.
Can an SFC Type write to outputs of a block contact?
SFC steps typically write to inputs (commands) and read from outputs (feedbacks). However, if an output has S7_contact := 'true' and write access is enabled, it can be manipulated.
What attribute is recommended alongside S7_contact for dynamic variables?
The attribute { S7_dynamic := 'true' } is recommended to ensure parameters are updated dynamically in runtime views.
Technical References
- SIMATIC Process Control System PCS 7 SFC for S7 / S7-FH Manual
- SIMATIC S7-SCL for S7-300/400 Manual
- SIMATIC Process Control System PCS 7 Advanced Process Library (APL) Manual
Related Articles
- Enabling Test Mode in SFC and Distinguishing SFC Types from SFC Instances in PCS 7
- Managing S7-400 Local Data Stack Allocation and Resolving CFC Compilation Exhaustion
- Removing Locked Interconnections, Text References, and Un-deletable Links in CFC Charts
Related Tags
- SFC Type
- Block Contacts
- S7_contact
- S7-SCL
- Custom Blocks