CNC Data Structures and Global Access

The CNC objects available in the project are compiled in function blocks of type SMC_OUTQUEUE or SMC_CNC_REF. (This does not happen when the compile method FILE is used.) When the project is compiled, the created CNC data is managed internally in the SMC_CNC_Data function blocks. For compile mode SMC_OutQueue, each CNC element is represented by a SMC_OUTQUEUE function block. For compile mode SMC_CNC_REF, a CNC element is represented by SMC_CNC_REF. While the IEC program is processed, the function blocks are instantiated and populated with values that can be processed in IEC programs. All of these POUs are contained in SM3_CNC.

Global access to CNC data

During initialization, the type and number of generated objects are ascertained from the CNC program. All of these objects are listed together in an global data structure that is declared implicitly. Objects of type SMC_OUTQUEUE are listed in the global data object g_CNCQueueManager with the property Count and the method GetOutQueue(int n). Objects of type SMC_CNC_REF are listed in the global data object g_CNCProgManager with the property Count and the method GetProgram(int n). The user can now access it in an IEC program.

Example

Access to data objects of the structure SMC_OUTQUEUE

PROGRAM CNCManageQueue
VAR
    pCNC_OutQueue : POINTER TO SMC_OUTQUEUE;
    n: INT;
    i: INT;
END_VAR

n := g_CNCQueueManager.Count;
FOR i:= 0 to n-1 DO
    pCNC_OutQueue := g_CNCQueueManager.GetOutQueue(I);
    (* calculate pCNC_OutQueue *)
END_FOR

Access to data objects of the structure SMC_CNC_REF

PROGRAM CNCManageRef
VAR
    pCNC_Ref: POINTER TO SMC_CNC_REF;
    n: INT;
END_VAR

n := g_CNCProgManager.Count;
FOR i:= 0 to n-1 DO
    pCNC_Ref := g_CNCProgManager.GetProgram(I);
    (* calculate pCNC_Ref *)
END_FOR

See also