Implementing Warm Restart (OB100) Logic in Custom PCS 7 Function Blocks
To implement warm restart (startup) behavior in a custom PCS 7 Function Block (FB), program initialization logic within the block using the 'S7_tasklist' attribute set to 'OB100', or detect the first execution cycle using an internal static boolean run-up flag ('BoRunUp'). In SCL, evaluate whether the block is executing in the startup organization block (OB100) using SFC6 ('RD_SINFO') or by resetting a static 'FirstRun' flag at the end of the initial cyclic scan, ensuring that internal state variables, alarms, and outputs are initialized to safe default values.
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
Custom Function Blocks developed for SIMATIC PCS 7 must integrate cleanly with the operating system startup sequence to avoid issuing false alarms, asserting erroneous interlock trips, or maintaining uninitialized pointer states when the CPU transitions from STOP to RUN. In standard S7-400 and CPU 410-5H architectures, initialization is executed in Organization Block 100 (OB100 - Warm Restart). This article explains how PCS 7 handles warm restart, how to use system function SFC6 (RD_SINFO) and SCL attributes (S7_tasklist), and how to structure robust initialization routines for custom technological blocks.
Architecture and Fundamental Mechanics
CPU Startup Execution and PCS 7 Block Run-Up Mechanics:
- S7-400 Startup Organization Blocks:
OB100: Warm Restart (standard startup in S7-400 and CPU 410-5H where non-retentive DB contents are reset, and retentive memories are retained).OB101: Hot Restart (not supported on S7-400/CPU 410 in PCS 7).OB102: Cold Restart (complete memory reset to initial load values).- PCS 7 Tasklist Mechanism (
S7_tasklist): - By assigning the system attribute
S7_tasklist := 'OB100, OB3x'in the block header, the CFC chart compiler automatically inserts an instance call of the FB into both OB100 and the specified cyclic interrupt OB (e.g., OB35 - 100ms). - When OB100 executes, the block runs once before cyclic tasks begin.
- Detecting Startup via SFC6 (
RD_SINFO): - Within the block code, calling SFC6 reads current OB execution info (
TOP_SI). - If
TOP_SI.NUM = 100, the block is currently executing inside OB100, allowing conditional execution of reset routines. - The Static 'FirstRun' Pattern:
- Alternatively, blocks can declare a static boolean
statFirstRun : BOOL := TRUE;. - During the first cyclic scan in OB3x, the block detects
statFirstRun = TRUE, executes initialization logic, and setsstatFirstRun := FALSE.
Step-by-Step Implementation Procedure
Programming Warm Restart in a Custom SCL Block:
- Define Block Header Attributes in SCL:
scl FUNCTION_BLOCK FB2001 TITLE = 'Custom_Motor_Control' AUTHOR : 'Engineer' FAMILY : 'UserLib' // Directs CFC to insert block into OB100 and cyclic OB { S7_m_c := 'true'; S7_tasklist := 'OB100' } VAR_INPUT // Input parameters END_VAR VAR_OUTPUT // Output parameters END_VAR VAR statRunUp : BOOL := TRUE; // Run-up active flag statCycleCount : INT := 0; END_VAR - Read Execution Info using SFC6 (
RD_SINFO):
```scl
VAR_TEMP
retVal : INT;
top_si : STRUCT
NUM : BYTE;
// other info
END_STRUCT;
start_si : STRUCT
// start info
END_STRUCT;
END_VAR
retVal := RD_SINFO(TOP_SI := top_si, START_UP_SI := start_si);
IF top_si.NUM = 100 THEN
// OB100 Initialization Routine
statRunUp := TRUE;
// Reset internal states, clear timers, initialize outputs
RETURN;
END_IF;
``
3. Implement Cyclic Run-Up Suppression:
- In the normal cyclic scan (OB35), evaluatestatRunUp:
* Suppress process alarm generation for a configured number of cycles (e.g.,RunUpCycles := 3) to allow field bus transmitters to establish valid values.
* Once elapsed, clearstatRunUp := FALSE`.
4. Compile and Insert into CFC:
- Compile the SCL source into an FB.
- Drag the FB into a CFC chart. Notice that CFC automatically schedules the block in both OB100 and OB35 under the chart run sequence.
Verification
To verify warm restart execution:
1. In SIMATIC Manager, check CFC -> Edit -> Run Sequence. Confirm the block instance appears under both OB100 and OB35.
2. Place the CPU in STOP, then switch to RUN.
3. In CFC test mode, verify that internal states were initialized to their specified defaults and that no spurious alarm pulses were emitted during the transition.
Limitations and Operational Precautions
Operational precautions:
- Do not call long wait loops, communication blocks, or acyclic read/write functions (e.g., SFC58/59) inside OB100; OB100 must complete quickly to prevent CPU watchdog timeouts.
- Ensure that outputs assigned in OB100 are not immediately overwritten before field output modules finish their power-up cycle.
- If modifying an existing block interface (adding inputs/outputs), remember that a full compilation and download in STOP will be required unless handled via download in RUN rules.
Engineer FAQ
What is the purpose of OB100 in SIMATIC PCS 7?
OB100 executes once during CPU warm restart to initialize data blocks, timers, and function blocks before cyclic OBs commence.
How does CFC know to insert my block into OB100?
By specifying the block attribute { S7_tasklist := 'OB100' } in the SCL source code header.
What system function reads current OB execution info?
SFC6 (RD_SINFO), which populates the TOP_SI structure containing the active OB number.
Why should alarm generation be suppressed during run-up?
To prevent flood alarms caused by field instruments and transmitters establishing communication during CPU startup.
Can I use OB101 for hot restart in PCS 7?
No, S7-400 and CPU 410-5H controllers in PCS 7 do not utilize OB101 hot restart; warm restart (OB100) is standard.
Technical References
- SIMATIC S7-400 CPU Technical Data Manual
- SIMATIC Process Control System PCS 7 Advanced Process Library (APL)
- SIMATIC System Software for S7-300/400 System and Standard Functions
Related Articles
- APL Block Protection Architecture, SCL Source Availability, and Faceplate Migration in PCS 7
- Locating Real Number Comparator Blocks and Implementing CompAn02 in SIMATIC PCS 7
- Configuring Control Module Type (CMT) Interconnections, Technological I-Os, and SFC Linking in PCS 7
Related Tags
- OB100
- Warm Restart
- SCL Programming
- RD_SINFO
- S7_tasklist