Skip to content
Contact Get Started

PLC & Structured Text

The control logic runs as a soft-PLC inside the Runtime. It is written in IEC 61131-3 Structured Text, to the third edition of the standard, with its object-oriented extensions. This page does not re-teach the language. It covers what is specific to the platform: how the PLC fits into it, and what it commands.

Motion and the PLC run together in the real-time tasks, and each owns a different thing:

  • Motion owns the trajectories and the execution of a part program.
  • The PLC owns the conditions under which motion is allowed to run: the safety chain, the enables, the interlocks and the state model.

The logic you write is where the second half lives: emergency stop and safety chains, axis enables, sequencing, and the state machine that ties them together. On a machine tool the sequencing covers the tool changer, the spindle and coolant; on another kind of machine it covers whatever that machine does instead.

Logic is organised with global variable lists (GVLs) and user-defined types (DUTs), shared across program units:

VAR_GLOBAL
CmdEnable : BOOL;
CmdReset : BOOL;
CurrentState : E_MachineState;
END_VAR

A GVL holds the live state, and the same variables are what the HMI binds to and what is watched while debugging. All of it is authored in the Development System, which compiles it into the binary the Runtime loads.

PLC logic does not move an axis directly. It commands motion through a library of PLCopen function blocks, which ship with the Development System as Structured Text source. Motion is driven the same way it is on any PLCopen-conformant controller.

GroupBlocks
Power, state and parametersMC_Power, MC_Reset, MC_Stop, MC_Halt, MC_ReadStatus, MC_ReadMotionState, MC_ReadAxisInfo, MC_ReadAxisError, MC_ReadParameter / MC_WriteParameter, MC_ReadBoolParameter / MC_WriteBoolParameter
Single-axis motionMC_MoveAbsolute, MC_MoveRelative, MC_MoveAdditive, MC_MoveVelocity, MC_Home, MC_SetPosition, MC_SetOverride, MC_ReadActualPosition / MC_ReadActualVelocity / MC_ReadActualTorque
Coordinated motionMC_GroupEnable / MC_GroupDisable, MC_MoveLinearAbsolute, MC_MoveLinearRelative, MC_GroupHalt, MC_GroupStop, MC_GroupReset
Building a groupMC_AddAxisToGroup, MC_RemoveAxisFromGroup, MC_UngroupAllAxes
CammingMC_CamTableSelect, MC_CamIn, MC_CamOut
Manual motionMC_Jog

A CNC channel is not a separate system with its own interface. It is commanded from Structured Text through function blocks of the same family, so starting a part program and starting a coordinated move are written the same way:

What it doesBlocks
Channel stateMC_ChannelEnable / MC_ChannelDisable, MC_ChannelReset, MC_ChannelReadStatus, MC_ChannelReadError
Running a programMC_CycleStart, MC_CycleStop, MC_FeedHold, MC_FeedResume, MC_SetChannelOverride
Getting back on the pathMC_BlockSearch, MC_ExecuteRepos
Run optionsMC_SetSingleBlock, MC_SetBlockDelete, MC_SetOptionalStop, MC_SetDryRun, MC_SetMachineLock, MC_SetOperationMode
Calling a subprogramMC_ExecuteSubprogram