Example "Create Planar movers and move based on coordinates (MoveX, MoveY)"
Using this short guide you will create a TwinCAT project that contains a Planar mover and moves it in a simple way.
Creating a Planar mover
- See Configuration.
- 1. Create a Planar mover for this example.
- 2. Put “Parameter (Init)” into simulation mode (
TRUE). The parameter is hidden and only becomes visible if the "Show Hidden Parameters" checkbox is activated.
Creating a PLC
- See preliminary steps Creating a PLC.
- 1. Use MAIN to create the mover(s) ("MC_PlanarMover") as follows.
- This/these represent(s) the mover(s) in the MC Configuration.

- 2. Create a Planar mover, a state variable for a state machine and a target position for a travel command of the mover, as shown below.
PROGRAM MAIN
VAR
mover : MC_PlanarMover;
state : UDINT;
target_x : LREAL := 1000;
target_y1 : LREAL := 500;
target_y2 : LREAL := 1000;
END_VAR- 3. Then program a sequence in MAIN.
- This program code activates the mover and moves it to position x=100 and y=100. The movement of the y-axis is first started at position 50 and as soon as the position of the X-axis is >=50, the movement of the Y-axis is aborted and post-started at position 100.
CASE state OF
0:
mover.Enable(0);
state := 1;
1:
IF mover.MCTOPLC.STD.State = MC_PLANAR_STATE.Enabled THEN
state := 2;
END_IF
2:
mover.MoveX(0, target_X, 0); // New default value syntax
mover.MoveY(targetPosition := target_Y1, refSys := 0); // New default value syntax
state := 3;
3:
IF mover.MCTOPLC.SET.SetPos.x >= 500.0 THEN
mover.MoveY(0, target_Y2, 0, 0););
state := 4;
END_IF
END_CASESending the command
- 4. To send the command, you must call the mover cyclically with its update method after END_CASE:
mover.Update();When creating the PLC, a symbol of the "PLC Mover" is created, which can then be linked to the mover instance in the MC project.
- 1. To build, use the path PLC > Untitled1 > Untitled1 Project > Build.
- Subsequently, the Planar mover in the “MC Project” (double-click) can be linked with the Link To PLC... button on the Settings tab.


Activating and starting the project
- 1. Activate the configuration via the button in the menu bar
. - 2. Set the TwinCAT system to the "Run" state via the button
. - 3. Log in the PLC via the button in the menu bar
. - 4. Start the PLC via the Play button in the menu bar.
At the end of the state machine (state=4), the mover is in the desired position.

Coordinate-based movements in X, Y and C coordinates can be executed side by side and can be aborted in motion, like all coordinate-based movements. The same applies to the corresponding relative and velocity commands (e.g. MoveRelativeX or MoverVelocityY). The 2D collision avoidance during these movements is correspondingly dynamic and is described in another example from the Planar Group.