Implementing Auto-Resetting Operator Pushbuttons in SIMATIC PCS 7 - OpTrig vs Custom SCL Logic

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

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:

Feature / MetricStandard OpTrig (FB1866)Custom SCL BlockCFC Circular Feedback LogicImplementation EffortZero (Standard library block)Low (Simple SCL code source)Complex / UnreliableCompiler Compatibility100% Native APL compatible100% CompatibleFails in Chart as Block TypeExecution DurationExactly 1 controller scan cycleUser-configurable pulseUnpredictable scan delayWinCC Faceplate SupportStandard APL faceplate includedRequires custom faceplate or C-actionManual script requiredUpgrade SustainabilitySeamless across PCS 7 versionsRequires maintaining SCL sourceHigh risk of migration break

Step-by-Step Procedure to Implement Auto-Resetting Operator Triggers

  1. Method 1: Utilizing Standard OpTrig in CFC (Recommended):
    * Open the target CFC chart.
    * In the catalog under Libraries -> PCS 7 APL -> OPERATE, locate OpTrig01 (FB1866) or classic OpTrig (FB111).
    * Drag OpTrig01 into the chart.
    * Connect Out.Value to your control block's reset or start trigger input.
    * Compile CFC (Changes only) and compile OS.
    * In WinCC Graphic Designer, place the standard OpTrig01 block icon or bind a button directly to OpTrig01.In#Value.
  2. 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

Related Articles

Related Tags

  • OpTrig
  • CFC Block Type
  • Auto Reset Input
  • SCL Programming
  • Pushbutton Trigger
  • APL Blocks
8 respuestas