PACFramework

2.1. General Concepts of Using Control Modules (CM)

Within the framework, regardless of the type of technological process controlled by the IACS, typical instrumentation objects are defined at the Control Module (CM) level across at least three levels:

The place of CM in the equipment hierarchy is described in more detail in Equipment Hierarchy in PAC Framework.

image-20220218134725035

This section covers the general rules for working with CMs.

For each CM object, the following are defined (replacing the abbreviation CM with the class or level abbreviation):

Examples:

Examples:

Examples:

Example:

// Calling the processing function for an analog process variable
"AIVARFN"(CHCFG := "SYS".CHAI["VAR".T101_TT100.CHID], 
          AIVARCFG := "VAR".T101_TT100, 
          AIVARHMI := "AIH".T101_TT100);

2.1.2. General Structure of CM (CM_CFG) and CM_BUF

Each structure should include:

Example DIVAR_CFG structure (LVL1 process variable):

image-20220221095137985

Example VLVD_CFG structure (LVL2 actuator):

image-20220221095557458

The CM_BUF structural type generally includes all fields of the structural types corresponding to the CMs it interacts with, making it universal.

2.1.3. CM_HMI Structure

Basic Structure

Alternative Structure

For process variables and channels, an alternative structure without CM_HMI.CMD is proposed, as the only command from the HMI is to load into the buffer. All other commands are handled via the buffer.

A 32-bit word can be used when 16 bits are insufficient, and the platform has no bit field restrictions.

image-20220221101010489

2.1.4. Handling Commands (CMD)

Example of CM_CFG.CMD bit commands for an actuator:

image-20220221142906006

2.1.5. Status and Mode Word (STA)

Alternative CM_HMI.STA (for LVL0 and LVL1) includes the STA and a read-to-buffer command bit (X15).

Common STA bits:

Using CM_HMI.STA and CM_BUF.STA as INT/UINT words reduces I/O points and simplifies alarm handling in SCADA/HMI.

Example of CM_CFG.STA bit structure:

image-20220221143346889

2.1.6. Working with CM_BUF

Buffer initialization occurs upon a read command (CM_HMI.CMD = 16#0100) or when bit X15=1 in CM_HMI.STA. The buffer receives all CM_CFG data.

Buffer occupation is checked:

#INBUF := (#AIVARCFG.ID = "BUF".VARBUF.ID) AND (#AIVARCFG.CLSID = "BUF".VARBUF.CLSID);

If true:

Configuration data changes in the buffer only update within the buffer. Sending CM_CFG.CMD = 16#0101 writes configuration data from the buffer to CM_CFG.

2.1.7. CM_FN Function

Each function interacts externally through CM_CFG, CM_HMI, CM_BUF, and receives the ID. Other interface variables depend on the function.

Interface Variable Type Purpose Note
CM_CFG INOUT structure for CM_CFG  
CM_HMI INOUT structure for CM_HMI  
CM_BUF INOUT structure for CM_BUF may be called directly if global
PLCCFG INOUT structure for CM_PLC may be called directly if global

Functions should be called in every cycle of the main cyclic task (MAST, OB1, etc.)! Multi-tasking rules depend on the platform and task specifics.

Practical Recommendations:

1) Each CM structure (except LVL0) should include STEP1 (UINT), T_STEP1 (UDINT), T_PREV for step-wise execution based on time.

Example:

#dT := "SYS".PLCCFG.TQMS - #AIVARCFG.T_PREV;
#AIVARCFG.T_PREV := "SYS".PLCCFG.TQMS;
#AIVARCFG.T_STEP1 := #AIVARCFG.T_STEP1 + #dT;
IF #AIVARCFG.T_STEP1 > 16#7FFF_FFFF THEN 
    #AIVARCFG.T_STEP1 := 16#7FFF_FFFF;
END_IF;

2) When using bit-packed STA, use internal variables for unpacking/packing, enabling edge detection.

Example:

#STA := #AIVARCFG.STA;
#BRK := #STA.BRK;
...
#INBUF := (#AIVARCFG.ID = "BUF".VARBUF.ID) AND (#AIVARCFG.CLSID = "BUF".VARBUF.CLSID);
#CMDLOAD := #AIVARHMI.STA.%X15;
...

Example of PLC general alarm logic:

#ALM := (#LOLO OR #HIHI) AND NOT #BAD;
IF #ALM THEN 
    "SYS".PLCCFG.ALM1.ALM := true; 
    "SYS".PLCCFG.CNTALM := "SYS".PLCCFG.CNTALM + 1;
    IF NOT #AIVARCFG.STA.ALM THEN 
        "SYS".PLCCFG.ALM1.NWALM := true; 
    END_IF;
END_IF;

Each CM_FN corresponds to a CM class. It is convenient to implement all class functions within one function, using CLSID, ID, or PRM for subclass handling, similar to polymorphism and inheritance.

See Concept of Object Classification and Customization for details.

To section