Motion Control in the PLC project
On this page you will find out how to implement motion control from the PLC project in accordance with PLCopen.
Opening the "Add Library" dialog
In order to be able to use motion control in accordance with PLCopen, you must add a reference to your PLC project.

- 1. Create a new PLC project.
- 2. Right-click the References folder [1] in the PLC project to which you wish to add a reference.
- A context menu opens.
- 3. Click the entry Add library… [2] in the context menu.
- The Add Library… dialog opens.
Selecting a library
Tc2_MC2 is the default library
- for motion control in accordance with PLCopen,
- PTP motion (Point to Point Motion) and
- axis management.

- The Add Library dialog is open.
- 1. Select the library that you wish to add to the PLC project.
- 2. To do this, switch the Add Library dialog to the Category View [1] if it is in a different view.
- 3. Expand the Motion subtree [2].
- 4. Expand the PTP subtree [3].
- 5. Select the Tc2_MC2 library [4].
- 6. Confirm your selection with the OK button [5].
- A reference to the Tc2_MC2 library [4] is created in the PLC project to which you wish to add this reference.
MC axis variable

The PLC axis variable MAIN.axis
has the data type AXIS_REF
.
The data type AXIS_REF:
- contains information about an axis,
- is an interface between the PLC and the NC and
- is given to the MC function blocks as a reference to an axis.
![]() | Refreshing the status data structure in The status data structure Calling the The status information does not change within a PLC cycle. After calling |
PROGRAM MAIN
VAR
axis: AXIS_REF;
END_VAR
axis.ReadStatus();
Simulation axis

[1]
| The local MC axis variable |
[2]
| The simulation axis Standard (Mapping via Encoder and Drive) is set as the NC axis under Axis Type.
|
[3] | The entry Link To I/O... remains empty for a simulation axis. |
MC_Power

The function block MC_Power switches the software enabling of an axis.
MC_Power: Inputs (excerpt)
| Sets the general software and controller enabling for an axis. Enabled if
|
| Sets the feed enabling for an axis for the positive travel direction. Enabled if
|
| Sets the feed enabling for an axis for the negative travel direction. Enabled if
|
| Influences the velocity of all travel commands as a percentage. It is |
MC_MoveAbsolute

- The function block MC_MoveAbsolute starts the positioning to an absolute target position and monitors the axis movement over the entire travel path.
MC_MoveAbsolute: Inputs (excerpt)
| A rising edge at this input executes the command.
|
| Absolute target position to be used for positioning.
|
| Maximum travel velocity. A positive value. |
Sample program for moving to a target position
The MAIN program shows a short example with which a target position is to be moved to.
PROGRAM MAIN
: Declaration
PROGRAM MAIN
VAR
axis: AXIS_REF;
fbAxisPower: MC_Power;
fbAxisMoveAbsolute: MC_MoveAbsolute;
bEnable: BOOL := FALSE;
fOverride: LREAL := 100;
bMove: BOOL := FALSE;
fTargetPosition: LREAL := 90;
fTargetVelocity: LREAL := 5;
END_VAR
PROGRAM MAIN
: Implementation
axis.ReadStatus();
fbAxisPower(
Axis:= axis,
Enable:= bEnable,
Enable_Positive:= bEnable,
Enable_Negative:= bEnable,
Override:= fOverride,
BufferMode:= ,
Options:= ,
Status=> ,
Busy=> ,
Active=> ,
Error=> ,
ErrorID=> );
fbAxisMoveAbsolute(
Axis:= axis,
Execute:= bMove,
Position:= fTargetPosition,
Velocity:= fTargetVelocity,
Acceleration:= ,
Deceleration:= ,
Jerk:= ,
BufferMode:= ,
Options:= ,
Done=> ,
Busy=> ,
Active=> ,
CommandAborted=> ,
Error=> ,
ErrorID=> );
MAIN: Local variables
| Instance of an MC axis. This instance can be linked with an NC axis.
|
| Instance variable of the MC_Power function block.
|
| Instance variable of the MC_MoveAbsolute function block.
|
| Switches the inputs
|
| Override value for the
|
| Positive edge switches the
|
| Target position value for the
|
| Target velocity value for the |