Controlling a Cam Drive with a Virtual Time Axis
See the PLCopenMulti.project
sample project in the installation directory of CODESYS under ..\CODESYS SoftMotion\Examples
.
This example demonstrates how to implement a periodic cam on a linear drive. The example also shows how to use the tappet function.
Insert a cam named
Example
in the device tree below Application. Open the cam in the editor.Define a tappet on the Tappet tab.
X:
8.0
Positive pass:
Invert
Negative pass:
Invert
Insert a virtual drive named
Drive
in the device tree below SoftMotion General Axis Pool. For this axis, select the axis type Modulo with a modulo value of360
.Insert another virtual drive named
Virtual
. For this axis, select the Modulo axis type with a modulo value of10
.Create a MOTION_PRG program in CFC.
PROGRAM MOTION_PRG VAR power1, power2: MC_Power; TableSelect: MC_CamTableSelect; CamIn: MC_CamIn; Tappet: SMC_GetTappetValue; MoveVirtual: MC_MoveVelocity; END_VAR
Insert a box element and assign the variable
power1
to it. The box element is used for switching on theDrive
.Configure the inputs as follows:
Axis:
Drive
Enable:
TRUE
bRegulatorOn:
TRUE
bDriveStart
TRUE
Insert a box element and assign the variable
power2
to it. The box element is used for switching on theVirtual
drive.Configure the inputs as follows:
Axis:
Virtual
Enable:
TRUE
bRegulatorOn:
TRUE
bDriveStart
TRUE
Insert a box element and assign the variable
MoveVirtual
to it. The box element is used for moving the virtual master.Configure the inputs as follows:
Axis:
Virtual
Execute:
power2.Status
Velocity:
2
Acceleration
10
Deceleration
10
Direction
positive
Insert a box element and assign the variable
TableSelect
to it. The box element is used for selecting a cam.Configure the inputs as follows:
Master:
Virtual
Slave:
Drive
CamTable:
Example
Execute
TRUE
Periodic
TRUE
MasterAbsolute
TRUE
SlaveAbsolute
TRUE
Insert a box element and assign the variable
CamIn
to it. The box element implements the selected cam plate.Configure the inputs as follows:
Master:
Virtual
Slave:
Drive
Execute
power1.Status
MasterOffset:
0
SlaveOffset:
0
MasterScaling:
1
SlaveScaling:
1
StartMode:
absolute
CamTableID:
TableSelect.CamTableID
VelocityDiff:
1
Acceleration:
1
Deceleration:
1
TappetHysteresis:
1
Insert a box element and assign the variable
Tappet
to it. The box element checks the setting of the cam switch.Configure the inputs as follows:
Tappets:
CamIn.Tappets
iID:
1
bInitValue
FALSE
bSetInitValueAtReset:
FALSE
The tappet is defined as an inverting tappet. For this reason, its value is changed every 10 seconds.
The sample project provides a visualization for checking the individual function blocks and the position of the axes.
Add the call of the
MOTION_PRG
program to the task MainTask.Download the project to the controller and start it.
For more information, see: