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
Examplein the device tree below Application. Open the cam in the editor.Define a tappet on the Tappet tab.
X:
8.0Positive pass:
InvertNegative pass:
Invert
Insert a virtual drive named
Drivein 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_VARInsert a box element and assign the variable
power1to it. The box element is used for switching on theDrive.Configure the inputs as follows:
Axis:
DriveEnable:
TRUEbRegulatorOn:
TRUEbDriveStart
TRUE
Insert a box element and assign the variable
power2to it. The box element is used for switching on theVirtualdrive.Configure the inputs as follows:
Axis:
VirtualEnable:
TRUEbRegulatorOn:
TRUEbDriveStart
TRUE
Insert a box element and assign the variable
MoveVirtualto it. The box element is used for moving the virtual master.Configure the inputs as follows:
Axis:
VirtualExecute:
power2.StatusVelocity:
2Acceleration
10Deceleration
10Direction
positive
Insert a box element and assign the variable
TableSelectto it. The box element is used for selecting a cam.Configure the inputs as follows:
Master:
VirtualSlave:
DriveCamTable:
ExampleExecute
TRUEPeriodic
TRUEMasterAbsolute
TRUESlaveAbsolute
TRUE
Insert a box element and assign the variable
CamInto it. The box element implements the selected cam plate.Configure the inputs as follows:
Master:
VirtualSlave:
DriveExecute
power1.StatusMasterOffset:
0SlaveOffset:
0MasterScaling:
1SlaveScaling:
1StartMode:
absoluteCamTableID:
TableSelect.CamTableIDVelocityDiff:
1Acceleration:
1Deceleration:
1TappetHysteresis:
1
Insert a box element and assign the variable
Tappetto it. The box element checks the setting of the cam switch.Configure the inputs as follows:
Tappets:
CamIn.TappetsiID:
1bInitValue
FALSEbSetInitValueAtReset:
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_PRGprogram to the task MainTask.Download the project to the controller and start it.
For more information, see: