How to Create a Program for Controlling the Axis Group
The following instructions describe how to create a program for controlling an axis group.
Requirement: A project has been created with an axis group, as specified in the How to Create an Axis Group chapter.
The program for controlling an axis group is created in the PLC_PRG
POU with CFC as the implementation language.
Open the
PLC_PRG
program in the editor.Drag the Box element to the editor.
Map the function block
SMC_GroupPower
to the box.Configure the function block according to the following image.
Explanation:
The function block activates all drives of the axis group.
The output
Status
indicates successful controller enable.
Create a function block of type
MC_GroupEnable
.This function block transfers control of the linked axes to the AxisGroup axis group.
Connect the
Status
output of theSMC_GroupPower
function block to theExecute
input of theMC_GroupEnable
function block.Explanation:
When all axis controllers are powered (
Status = TRUE
), control of the axes is transferred to the axis group.The
Done
output reports the success of the command.
Insert a
MC_MoveDirectAbsolute
function block for running the drive.Connect the
Done
output of theMC_GroupEnable
function block to theExecute
input of theMC_MoveDirectAbsolute
function block.Extend the program as follows:
Explanation:
The
MC_MoveDirectAbsolute
function block commands a PTP motion of the AxisGroup axis group.In the example, the kinematics are moved to the position (X = 10, Y= 20, Z = 30). This value is mapped to the
Position
input via theSMC_POS_REF
structure.The position is specified in the machine coordinate system (MCS). The coordinate system is selected by means of the
CoordSystem
input.
Starting the program
If the program has been created completely and it can be compiled without errors, then you can transfer it to the controller.
Start the CODESYS Control Win runtime system (
CODESYSControlService.exe
program in the"...\GatewayPLC"
directory).In the Communication Settings, set the connection path to your controller.
Click Online → Login.
Download the project to the controller.
Click
.In the editor, open the AxisGroup object.
The positions of the axes are displayed.
Click Debug → Start.
The positions of the axes change.