FUP to SCL Fundamentals¶
What Changes From FUP¶
In FUP/FBD, the execution order is often visible through networks and signal lines. In SCL, the execution order is the order of the statements in the file.
xboA := TRUE;
xboB := xboA;
xboA := FALSE;
After this code runs, xboB is TRUE and xboA is FALSE. The second assignment used the value
that existed at that point in the cycle.
Think in three layers:
| FUP/FBD habit | SCL equivalent |
|---|---|
| Network with contacts and coils | Boolean expression and assignment |
| Set/reset coil | Explicit IF ... THEN ... ELSE logic |
| Function block box | FB call with named parameters |
| Data structure view | STRUCT, UDT, DB, or FB static variables |
| Network comments | Short comments and REGION sections |
The PLC Scan¶
Most PCS logic runs cyclically:
- Inputs and internal state already have a value at the start of the block call.
- The block executes from top to bottom.
- Assignments update variables immediately for the following statements in the same call.
- Static variables keep their values for the next cycle.
- Temporary variables are recalculated every call.
This matters because SCL is not a drawing. If a variable is assigned twice, the later assignment wins for the final value.
xboValveOpenCommand := xboOperatorRequest;
IF xboEmergencyStopActive THEN
xboValveOpenCommand := FALSE;
END_IF;
This is a common and useful pattern: calculate the normal command first, then apply safety or interlock overrides later.
Block Interface¶
An SCL block usually has declaration sections before BEGIN.
FUNCTION_BLOCK "FB_SimplePumpControl"
{ S7_Optimized_Access := 'FALSE' }
VERSION : 0.1
VAR_INPUT
xboStartRequest : Bool;
xboStopRequest : Bool;
xboPumpHealthy : Bool;
END_VAR
VAR_OUTPUT
xboPumpRunCommand : Bool;
END_VAR
VAR
_xboRunLatched : Bool;
END_VAR
BEGIN
// Logic goes here.
END_FUNCTION_BLOCK
| Section | Lifetime | Typical use |
|---|---|---|
VAR_INPUT |
Provided by caller | Commands, feedback, configuration inputs |
VAR_OUTPUT |
Written by block | Commands, status, diagnostics |
VAR_IN_OUT |
Shared with caller | Larger structures that are read and written |
VAR |
Static, remembered | State, latches, timers, filters |
VAR_TEMP |
Temporary, one call | Intermediate calculations |
Do not store state in VAR_TEMP
A temporary variable is not a memory. Use VAR for values that must survive into the next PLC
cycle, such as state numbers, latched alarms, and timer instances.