-

PLC Data Structures

Overview

Multiple Data structs are synchronized between Compass NC on the PC, and the iCube Controller. While many are used internally for Compass NC operations (e.g., motion processing, NC state information, etc.), others are available for aiding integration to the machine, or for status information on the HMI created with Compass Designer.

NameData TypeDescription
NcStateData NcState Global, Retained. Data Type defined in CompassComms library
HmiData HMIStatusData Global. Data Type defined in CompassComms library
MotionCommands MotionCommandBlockCircularBuffer Global. Data Type defined in CompassComms library
MachineCommands MachineCommandCircularBuffer Global. Data Type defined in CompassComms library


Additional Data Structs used for Compass operation and interaction.

NameData TypeDescription
HMI_Command ControllCommand Global. Data Type defined in CompassToolbox library
MachineControl ControllCommand Global. Data Type defined in CompassToolbox library
M_Code M_CodeArray Global. Data Type defined in CompassToolbox library
AxesMap IntArray Global.
LastExecutedSegmentData
SegmentDataStruct
Global. Data Type defined in CompassToolbox library

NcStateData (NcState)

NcState represents the current G-Code modal state as data to read for integration into the machine’s logic. Compass NC to read data from the PLC.

NameData TypeDescription
MachineStateMachineState

CycleActive BOOL Indicates that G-code program is running

CycleHold BOOL Indicates that G-code program is paused

AtParserBlockingCommand BOOL G-code program is momentarily paused waiting for a feedback from PLC.
PLCPLC Data struct for writing and reading PLC variables during G-code file execution.

DINTS Array[100] 100 DINT type PLC variables for writing and reading during G-code file execution.

LREALS Array[100] 100 LREAL type PLC variables for writing and reading during G-code file execution.

BYTES Array[100] 100 BYTE type PLC variables for writing and reading during G-code file execution.

G31 G31 Axes positions recorded after G31 move
ModalStateGCodeState ModalState/GModalGroup saved in the PLC

MotionState MotionMode Current Motion Mode (G0, G1, G2, G3)

PlaneState PlaneMode Current Plane (G17, G18, G19)

FeedState FeedMode Current Feed Mode (G93, G94)

DistanceState DistanceMode Current Distance Mode (G90, G91)

UnitsState UnitsMode Current Units (G20, G21)

CutterDiameterCompState CutterDiameterCompensation Cutter Diameter Compensation State (G40, G41, G42)

ToolLengthOffsetState ToolLengthOffset Current Tool Length Offset State (G43, G44, G49)

ScalingState ScalingMode Current Scaling State (G50, G51)

CoordinateSystemState CoordinateSystem Current Coordinate System Offset Mode (G54  - G59)

ExactStopControlState ExactStopControlMode Current Modal Exact Stop State (G61, G64)

MacroProgramModalState MacroProgramModalMode Not implemented

SpindleSpeedState SpindleSpeedMode Not implemented

CoordinateRotationState CoordinateRotationMode Current Coordinate Rotation State (G68, G69)

HmiData (HMIStatusData)

Machine Status data sent to Compass NC.

NameData TypeDescription
HasPower BOOL Indicates that all servo motors were properly powered up, enabled and ready for motion.
CycleActive BOOL Indicates that G-code program or MDI is running
CycleHold BOOL Indicates that G-code program is paused
ResettingBuffers BOOL Indicates that communication channels are being reset.
FileLineNumber LINT G-code File line number which is currently being executed or providing motion.
TCPVelocity LREAL Current gantry velocity in cartesian coordinate system.
AxesData AxisDataArray Axes status and positioning data
Strings Array[10] 10 STRING type variables for writing to PLC or displaying on HMI.
Integers Array[100] 100 INT type variables for writing to PLC or displaying on HMI.
Doubles Array[100] 100 DOUBLE type variables for writing to PLC or displaying on HMI.
Bytes Array[100] 100 BYTE type variables for writing to PLC or displaying on HMI.

MotionCommands (MotionCommandBlockCircularBuffer)

Motion Commands sent to PLC during G-code processing / execution.

NameData TypeDescription
BlocksArray[8192]

PositionX LREAL Calculated Target position for X axis

PositionY LREAL Calculated Target position for Y axis

PositionZ LREAL Calculated Target position for Z axis

PositionTangent LREAL Calculated Target position for Tangent axis

PositionAux1 LREAL Calculated Target position for Auxiliary axis

M LREAL Modal M argument value

S LREAL Modal S argument value

T LREAL Modal T argument value

H LREAL Modal H argument value

P LREAL Modal P argument value

Velocity LREAL Calculated sub-segment Speed

Acceleration LREAL Calculated sub-segment Acceleration

TransitionParameter LREAL Corner Transition Mode value

SegmentDuration LREAL Calculated sub-segment duration

ProfiledFeedrate LREAL Calculated max speed of motion G-code command.

BlockVelocity LREAL Speed requested by G-code processor.

IOValue LREAL Not used

FileLineNumber LINT G-code file line number

BlockNumber LINT Assigned block number

Command Command Current Command (move, rapid move, dwell, stop, etcv.)

BufferMode BufferMode Velocity Blending setting (default BlendingLow)

TransitionMode TransitionMode Corner Transition Mode setting (default TmMaxCornerDeviation)

SpareDint DINT Not Used

Dwell TIME Dwell command dwell duration

InputLocation DINT Not used

OutputLocation DINT Not Used

Eol BOOL Indicates the last command of the current file line (End Of Line)

VarAssignment PlcVarAssignment Value and operation for PLC variable reading/writing

GCodeState GCodeState Current G-code Modal State

AxesFlags AxesFlags Indicates which axes are allowed motion

MachineCommands (MachineCommandCircularBuffer)

The received Machine Command list is processed in Y_C_CommandProcessor and an appropriate HMI_Command struct bit is updated.

NameData TypeDescription
CommandsArray[100]

Action MachineAction Machine Action Command 

Value LREAL Machine Action command value

HMI_Command (ControlCommand)

The received and processed Machine Command bit. The intention behind this struct is to separate HMI commands from PLC actions. The value of these HMI_Command bits should be passed to the appropriate MachineControl struct bits utilizing a necessary logic.



NameData TypeDescription
ServosOn BOOL Indicates that a "Servo ON" button was pressed on HMI
CycleStart BOOL Indicates that a "Cycle Start" button was pressed on HMI
CycleResume BOOL Indicates that a "Cycle Resume" button was pressed on HMI
CycleStep BOOL Indicates that a "Single Step" button was pressed on HMI
CycleHold BOOL Indicates that a "Hold" button was pressed on HMI
CycleStop BOOL Indicates that a "Cycle Stop" button was pressed on HMI
JogStop BOOL Indicates that a Jog button was released
SetFeedRateMultiplier BOOL Indicates that Feed Rate Multiplier value was updated on HMI
SetJogVelocity BOOL Indicates that Jog Velocity value was updated on HMI
SetJogAcceleration BOOL Indicates that Jog Acceleration value was updated on HMI
JogXPositive BOOL Indicates that a Jog X+ button was pressed
JogXNegative BOOL Indicates that a Jog X- button was pressed
JogYPositive BOOL Indicates that a Jog y+ button was pressed
JogYNegative BOOL Indicates that a Jog Y- button was pressed
JogZPositive BOOL Indicates that a Jog Z+ button was pressed
JogZNegative BOOL Indicates that a Jog Z- button was pressed
JogAux1Positive BOOL Indicates that a Jog Aux+ button was pressed
JogAux1Negative BOOL Indicates that a Jog Aux- button was pressed
JogTangentPositive BOOL Indicates that a Jog Tangent+ button was pressed
JogTangentNegative BOOL Indicates that a Jog Tangent- button was pressed
ClearAlarms BOOL "Clear Alarms" button was pressed
FeedrateMultiplier LREAL HMI Feed Rate Multiplier Value
JogVelocity LREAL HMI Jog Velocity value
JogAcceleration LREAL HMI Jog Acceleration value
JogEnable BOOL Jog Axis function is being executed
JogAxisNumber UINT Selected Jog Axis Number
JogDirection BOOL Calculated Jog direction
ResetNetworkBuffers BOOL Reset communication command was sent from HMI


MachineControl (ControlCommand).

The intention behind this struct is to separate HMI commands and physical inputs from the PLC actions. The value of these MachineControl bits should be set by an appropriate logic processing HMI_Commands and physical inputs (Operator panel button presses) in the MachineControlLogic POU and then using these bits to execute appropriate PLC logic. The struct is identical to HMI_Command data type.


Image



M_Code(M_CodeArray).

Compass Processor activates the corresponding M_Code array Active bit after processing an M-command.

NameData TypeDescription
Active BOOL NC sets to 1 when active. PLC resets to 0 when acknowledged
M_Value LREAL Active M-code number
S_Value LREAL S argument value from the M-code line
T_Value LREAL T argument value from the M-code line
H_Value LREAL H argument value from the M-code line
P_Value LREAL P argument value from the M-code line



AxesMap(IntArray).

An array used for properly mapping Virtual Group axes to the Real Group axes. Currently Compass is set up for controlling 5 axes (X, Y, Z, Aux1, Tangent), Virtual Group is set up accordingly and should not be modified. The actual axes on the machine might differ so using this array you can disable non existing axes and properly point virtual axes to the real axes.


NameData TypeDescription
AxesMap[1] INT Virtual X axis
AxesMap[2] INT Virtual Y axis
AxesMap[3] INT Virtual Z axis
 AxesMap[4] INT Virtual Aux1 axis
 AxesMap[5] INT Virtual Tangent axis

Example:

Homag router Real axis group is set up for 4 axes (5 including X prime):

Image

RealC axis is used as a Tangent axis, so the AxisMap is set up like this:

Image


LastExecutedSegmentData(SegmentDataStruct)

Data from the last executed segment or the segment actively providing motion. Used for troubleshooting or displaying File Line number on the HMI.

NameData TypeDescription
FileLineNumber LINT File Line number of the currently executed G-code
BlockNumber LINT Block Number assigned by G-Code processor
SegmentSpeed LREAL Calculated sub-segment speed
BlockSpeed LREAL Calculated segment
S LREAL S Argument value from the G-code line
TargetPosition VectorArray Sub-segment target position
ModalState GCodeState Segment Modal State


 


This is the latest version of Compass Online help and the content may refer to features not available in previously released versions of Compass.

Copyright © 2026 YASKAWA America, Inc.