Distance-Based Ramping
The BasicMotion_CamIn_StartModes.project sample project described here is located in the installation directory of CODESYS under the ..\CODESYS SoftMotion\Examples directory.
This example shows how to use the StartMode input of the MC_CamIn function block. This input is used to configure how the slave axis is synchronized with the master axis when MC_CamIn is started.
Basically, there are three possible ways:
The slave axis immediately follows the trajectory specified by the cam and the master axis. Depending on the start status of the slave axis, this can lead to a jump in position, velocity, and/or acceleration of the slave axis.
StartMode:absolute,relativeThe slave axis synchronizes as quickly as possible while maintaining the predefined velocity, acceleration, deceleration, and jerk limits.
StartMode:ramp_in,ramp_in_pos,ramp_in_negA master position is specified in the cam where the slave axis should follow the trajectory as specified by the cam and the master axis. Synchronization takes place over a configurable distance from the master axis.
StartMode:ramp_in_dist
For more information about the MC_CamIn function block, see: MC_CamIn (FB)
Structure of the application
The application consists of a PLC_PRG program and a Trace. Moreover, there are four virtual axes: the master axis Master and the three slave axes SlaveAbsolute, SlaveRampIn, and SlaveRampInDist. And there is the cam Cam.
In the PLC_PRG program, three instances of MC_CamIn are executed with the StartMode input set differently:
ciSlaveAbsolutewithStartMode = absoluteciSlaveRampInwithStartMode = ramp_inciSlaveRampInDistwithStartMode = ramp_in_dist
The function block instances control the corresponding virtual axes SlaveAbsolute, SlaveRampIn, and SlaveRampInDist. The master axis is moved at a constant velocity using an MC_MoveVelocity instance.
The trajectories of the three slave axes and the Active and InSync outputs of the MC_CamIn instances can be tracked in the trace.
All MC_CamIn instances are started when the master axis exceeds position 40:
The
SlaveAbsoluteaxis immediately jumps to the set values defined from the cam. The correspondingMC_CamIninstance is immediatelyActiveandInSync.The
SlaveRampInaxis synchronizes while maintaining the commanded dynamic limits. The correspondingMC_CamIninstance is immediatelyActive. From master position~114, the slave axis follows the trajectory specified by the cam and the master axis and theMC_CamIninstance reportsInSync.The
SlaveRampInDistaxis first remains stationary until the master axis has approached theMasterSyncPositionof 120 up to theMasterStartDistanceof 60 configured on theMC_CamIn instance. Then synchronization begins and theMC_CamIninstance reportsActive. When the master axis reaches theMasterSyncPositionof120, the slave axis follows the trajectory specified by the cam and the master axis and theMC_CamIninstance reportsInSync.
Commissioning
Build the application and download it to a controller.
Start the trace and the application.
In the trace, you can track the movement of the virtual axes.