Implementing Auto-Resetting Operator Pushbuttons in SIMATIC PCS 7 - OpTrig vs Custom SCL Logic
In SIMATIC PCS 7, resetting a block input parameter (VAR_INPUT or VAR_IN_OUT) from inside a CFC chart compiled as a Block Type is structurally restricted because CFC does not support circular internal output-to-input writebacks. To implement an operator pushbutton that resets itself automatically after execution, use the standard PCS 7 operator trigger block OpTrig (FB111 / FB1866). Alternatively, write a custom function block in Structured Control Language (SCL) where the input parameter tagged with S7_m_c := 'true' is evaluated and reset to FALSE directly within the block algorithm.
Table of Contents
- The CFC Chart-as-Block-Type Parameter Assignment Restriction
- Why Circular Writebacks Fail in CFC Graphic Compilations
- The Standard PCS 7 Solution: OpTrig (FB111 / FB1866)
- Comparison Table: OpTrig Standard Block vs Custom SCL Auto-Reset
- Step-by-Step Procedure to Implement Auto-Resetting Operator Triggers
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
The CFC Chart-as-Block-Type Parameter Assignment Restriction
When developing reusable automation modules, engineers frequently create a CFC chart and compile it as a Block Type (Chart -> Compile -> Chart as Block Type):
* The Pushbutton Requirement:
An operator clicks a reset or start pushbutton on a WinCC faceplate. The button sets a boolean parameter in the controller to 1. Once the action executes, the parameter must automatically return to 0 without requiring the operator to release or toggle the button.
* The Programming Conflict in CFC:
In SCL, resetting an input is trivial (IF ResetCmd THEN ResetCmd := FALSE; END_IF;).
However, in a CFC chart compiled as a Block Type:
* Inputs (VAR_INPUT) are read-only buffers inside the chart.
* Attempting to connect an internal block output back to a chart input pin creates an illegal recursive connection that the CFC compiler rejects with structural syntax errors.
Why Circular Writebacks Fail in CFC Graphic Compilations
CFC calculates task execution orders using directed acyclic graphs (DAGs). Connecting the output of an internal logic gate (e.g., an AND or R_TRIG block) back to a top-level chart input represents an algebraic loop. While standard CFC charts can break loops using previous-cycle buffers, the Chart as Block Type generator requires strict input-to-output parameter pipelines to generate a valid STEP 7 Function Block interface.
The Standard PCS 7 Solution: OpTrig (FB111 / FB1866)
Siemens provides standard operator trigger blocks specifically designed for this function:
* The OpTrig Block (APL OpTrig01 FB1866 / Classic FB111):
* Designed to interface with WinCC pushbuttons.
* Contains an input In with the system attribute S7_m_c := 'true'.
* When an operator sets In = 1 from WinCC, OpTrig outputs a 1-scan cycle pulse on Out (or Out.Value).
* At the conclusion of the execution scan, OpTrig automatically clears In back to 0 internally, ready for the next command.
* Eliminates custom script writebacks and provides standard block icons and faceplates.
Comparison Table: OpTrig Standard Block vs Custom SCL Auto-Reset
The table below compares operator trigger implementations in PCS 7:
Step-by-Step Procedure to Implement Auto-Resetting Operator Triggers
- Method 1: Utilizing Standard OpTrig in CFC (Recommended):
* Open the target CFC chart.
* In the catalog under Libraries -> PCS 7 APL -> OPERATE, locateOpTrig01(FB1866) or classicOpTrig(FB111).
* DragOpTrig01into the chart.
* ConnectOut.Valueto your control block's reset or start trigger input.
* Compile CFC (Changes only) and compile OS.
* In WinCC Graphic Designer, place the standardOpTrig01block icon or bind a button directly toOpTrig01.In#Value. - Method 2: Creating an Auto-Resetting SCL Block:
If custom multi-function logic is required, write an SCL block source:
```pascal
FUNCTION_BLOCK "FB250_CustomTrigger"
TITLE = 'Auto-Reset Operator Trigger'
AUTHOR : 'CUSTOM'
FAMILY : 'OPERATE'
VERSION : '1.0'
VAR_INPUT
ResetCmd { S7_m_c := 'true' } : BOOL := FALSE;
InterlockActive : BOOL := FALSE;
END_VAR
VAR_OUTPUT
PulseOut : BOOL := FALSE;
END_VAR
BEGIN
// Evaluate command and auto-reset input
IF ResetCmd AND NOT InterlockActive THEN
PulseOut := TRUE;
ResetCmd := FALSE; // Self-resetting command
ELSE
PulseOut := FALSE;
END_IF;
END_FUNCTION_BLOCK
``
3. **Compile and Instantiate**:
Compile the SCL source. Drag the resultingFB250` into your CFC chart and perform an OS compile.
Verification
To verify that auto-resetting pushbuttons operate properly:
1. Open the CFC chart online in test mode.
2. In WinCC OS Runtime, click the reset pushbutton.
3. Observe the CFC chart: verify that PulseOut transitions to TRUE for one execution cycle.
4. Verify that the input parameter (ResetCmd or In) immediately returns to FALSE without requiring a second click.
5. Rapidly click the button multiple times and confirm that each click produces a clean, isolated pulse without latching.
Limitations and Operational Precautions
- WinCC Button Script Traps: Avoid using WinCC C-scripts that set a bit on mouse down and reset it on mouse up. If the operator drags the mouse cursor off the button before releasing, the mouse up event never fires, leaving the bit latched high in the controller indefinitely. Always use controller-level auto-resetting logic.
- Scan Cycle Pulse Duration: A 1-scan cycle pulse lasts only a few milliseconds (the duration of the cyclic OB, e.g., 100 ms). If the downstream receiver is located in a slower OB or an external PLC over a network, use a pulse stretching timer (
TimerP). - Licensing Disclaimer: Utilizing standard Advanced Process Library components requires valid PCS 7 engineering and runtime licensing verified via Automation License Manager.
Engineer FAQ
Technical References
- SIMATIC Process Control System PCS 7 Advanced Process Library Manual (A5E39140321-AB)
- SIMATIC S7-SCL for S7-300 and S7-400 Programming Manual (A5E00850741-08)
- SIMATIC PCS 7 CFC for S7 Configuration Manual (A5E35802288-AB)
Related Articles
- Managing the CFC Block Catalog in SIMATIC PCS 7 - Importing Timers, SCL Sources, and Library Synchronization
- Preserving Controller Data in SIMATIC PCS 7 - CFC Readback Rules, OCM Attributes, and Runtime Backup Strategies
- Implementing Multi-Instance Faceplate Popups in SIMATIC PCS 7 WinCC - Dynamic TagPrefix and C-Script Window Allocation
Related Tags
- OpTrig
- CFC Block Type
- Auto Reset Input
- SCL Programming
- Pushbutton Trigger
- APL Blocks