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.
The division of authority
Section titled “The division of authority”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.
How a project is organised
Section titled “How a project is organised”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_VARA 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.
The motion library
Section titled “The motion library”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.
| Group | Blocks |
|---|---|
| Power, state and parameters | MC_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 motion | MC_MoveAbsolute, MC_MoveRelative, MC_MoveAdditive, MC_MoveVelocity, MC_Home, MC_SetPosition, MC_SetOverride, MC_ReadActualPosition / MC_ReadActualVelocity / MC_ReadActualTorque |
| Coordinated motion | MC_GroupEnable / MC_GroupDisable, MC_MoveLinearAbsolute, MC_MoveLinearRelative, MC_GroupHalt, MC_GroupStop, MC_GroupReset |
| Building a group | MC_AddAxisToGroup, MC_RemoveAxisFromGroup, MC_UngroupAllAxes |
| Camming | MC_CamTableSelect, MC_CamIn, MC_CamOut |
| Manual motion | MC_Jog |
The CNC channel is commanded the same way
Section titled “The CNC channel is commanded the same way”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 does | Blocks |
|---|---|
| Channel state | MC_ChannelEnable / MC_ChannelDisable, MC_ChannelReset, MC_ChannelReadStatus, MC_ChannelReadError |
| Running a program | MC_CycleStart, MC_CycleStop, MC_FeedHold, MC_FeedResume, MC_SetChannelOverride |
| Getting back on the path | MC_BlockSearch, MC_ExecuteRepos |
| Run options | MC_SetSingleBlock, MC_SetBlockDelete, MC_SetOptionalStop, MC_SetDryRun, MC_SetMachineLock, MC_SetOperationMode |
| Calling a subprogram | MC_ExecuteSubprogram |
Where to go next
Section titled “Where to go next”- Development System: where the logic is written and compiled.
- Simulation: running the logic with no target attached.
- The NEV Platform: how the PLC, motion and the CNC channel sit in the Runtime.