Constructing Status Words and Signal Status Logic for Custom APL Blocks in SCL
When creating custom technological function blocks in Structured Control Language (SCL) according to the PCS 7 APL Styleguide, status outputs such as Status1, Status2, and Status3 are structured as 32-bit double words (DWORD). Each bit represents a specific operational state, interlock condition, or mode. To construct these parameters in SCL without compiler errors, define an internal structured bit-mask or use the AT overlay statement to map individual boolean flags onto the DWORD, compute the consolidated worst signal status (ST_Worst), and assign the final DWORD to the OCM-attributed status output.
Table of Contents
- APL Styleguide Architecture for Status Words and Signal Status
- Defining Status Words in SCL Using Bit Overlays and Enums
- Calculating ST_Worst and Propagating Quality Codes
- Configuring Operator Control and Monitoring (OCM) Attributes
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
APL Styleguide Architecture for Status Words and Signal Status
The SIMATIC PCS 7 Advanced Process Library (APL) enforces strict design guidelines for all technological blocks (such as MonDiL FB1848, MotL FB1850, and PIDConL FB1874). Custom technological blocks programmed in Structured Control Language (SCL) must adhere to these standards to communicate seamlessly with standard APL block icons and faceplates.
In the APL framework:
* Status Words (Status1, Status2, Status3, Status4): 32-bit double words (DWORD) where individual bits represent discrete operational states, active operating modes (Auto/Manual/Out of Service), interlock trips, feedback statuses, and error conditions.
* Signal Status (ST): Each process input and output carries an 8-bit IEEE 754 quality code (BYTE).
* Worst Signal Status (ST_Worst): An aggregated byte output representing the poorest quality code among all active interconnected technological inputs.
* Operator Authorization (OS_Perm, OS_PermLog): Bit-encoded double words specifying operator permissions and tracking unauthorized operation attempts.
Defining Status Words in SCL Using Bit Overlays and Enums
In SCL, directly writing individual bits to a DWORD variable using bitwise shifts can become unwieldy and error-prone. The standard engineering practice recommended by the APL Styleguide is using the AT filter overlay:
VAR_OUTPUT
Status1 { S7_m_c := 'true' } : DWORD := 16#00000000;
ST_Worst { S7_m_c := 'true' } : BYTE := 16#80;
END_VAR
VAR
uStatus1 : STRUCT
bOccupied : BOOL; // Bit 0
bFeedbackOn : BOOL; // Bit 1
bFeedbackOff : BOOL; // Bit 2
bGroupError : BOOL; // Bit 3
bAutoAct : BOOL; // Bit 4
bManAct : BOOL; // Bit 5
bOosAct : BOOL; // Bit 6
bWarnAct : BOOL; // Bit 7
// Bits 8..31 defined accordingly
bReserved : ARRAY[8..31] OF BOOL;
END_STRUCT;
dwStatus1 AT uStatus1 : DWORD;
END_VAR
// Logic implementation in SCL execution body
uStatus1.bOccupied := Occupied;
uStatus1.bFeedbackOn := FbkRunOut.Value;
uStatus1.bAutoAct := AutAct;
uStatus1.bManAct := ManAct;
// Transfer consolidated DWORD to OCM-accessible output
Status1 := dwStatus1;
Listing 1: SCL overlay architecture for APL Status word construction.
Calculating ST_Worst and Propagating Quality Codes
The APL architecture requires custom blocks to continuously monitor the signal quality of inputs and set ST_Worst according to the standardized priority hierarchy:
16#0016#2816#6816#60 / 16#4816#80Table 1: APL Signal Status priority hierarchy evaluated by ST_Worst.
In SCL, evaluate inputs (e.g., In.ST) against the hierarchy: if any input has ST = 16#00, assign ST_Worst := 16#00; otherwise evaluate intermediate levels, defaulting to 16#80 when all signals are healthy.
Configuring Operator Control and Monitoring (OCM) Attributes
For the PCS 7 OS Compiler to automatically generate WinCC structure tags and link block icons to status words:
* Every status variable must include the compiler pragma { S7_m_c := 'true' }.
* Define parameter comments to document bit functions for maintenance engineers.
* When compiling the SCL source file in SIMATIC Manager, ensure Create block attributes is enabled in compiler settings.
* During OS compilation, WinCC creates structure elements <BlockInstance>.Status1, <BlockInstance>.ST_Worst, allowing faceplate C-scripts (APL_UpdatePermission, APL_SetFaceplateStatus) to parse bits automatically.
Verification
To confirm proper status word and faceplate operation:
- Compile the SCL source code into an executable FB: verify zero compiler warnings.
- Insert the custom FB into a test CFC chart and interconnect test inputs.
- Execute Options > Compile OS (Changes Only): confirm WinCC Tag Management creates matching structure tags.
- In WinCC Graphics Designer, connect a standard or customized APL block icon to the block instance.
- In runtime, toggle operational modes: confirm that
Status1bits toggle in real time and the block icon updates status colors and symbols without C-script errors inapdiag.exe.
Limitations and Operational Precautions
- Ensure bit numbering in SCL aligns with Siemens byte endianness: in S7 memory structures, Bit 0 of a DWORD corresponds to the least significant bit of the highest byte or lowest byte depending on struct packing; verify mapping against standard APL block definitions.
- Do not omit
ST_Worston blocks featuring faceplates; WinCC APL scripts queryST_Worstto render the quality badge (yellow exclamation or maintenance icon) on the block icon. - Modifying status word bit layouts after commissioning requires updating all connected faceplate scripts and compiling all associated OS pictures.
Engineer FAQ
Where can I find the complete bit mapping for APL blocks?
The complete bit assignment for Status1, Status2, Status3, and Status4 across all library blocks is documented in the SIMATIC PCS 7 Advanced Process Library Manual in the section titled 'Parameters of [BlockName]'.
Can I use INT instead of DWORD for Status outputs?
No. Standard APL faceplate C-scripts strictly expect 32-bit DWORD structure tags (Status1, Status2). Using INT causes script data type conversion failures and faceplate lockouts.
What pragma is needed to hide internal SCL variables from CFC?
Use the pragma { S7_visible := 'false' } to prevent internal parameters from cluttering the CFC block interface.
Technical References
- SIMATIC Process Control System PCS 7 Advanced Process Library (A5E35003921)
- SIMATIC PCS 7 APL Styleguide for Creating Custom Blocks (A5E02770535)
- SIMATIC S7-SCL V5.6 for S7-300/400 Programming Manual (A5E41662960)
- Siemens Industry Online Support: Developing Custom APL Blocks (Entry ID 109739941)
Related Articles
- Understanding APL Structured Data Types and Signal Status Propagation
- Renaming Customized Block Icons and Managing Typicals in PCS 7 Graphics Designer
- Monitoring Integer and Word Variables in PCS 7 APL: MonAnL Conversion and Formatting
- Configuring Button Visibility and Operator Control on APL OpDi03 Faceplates in PCS 7
Related Tags
- SCL
- APL Styleguide
- Status1
- ST_Worst
- DWORD
- Custom Blocks
- PCS 7