Controlling a Cam Drive with a Virtual Time Axis

 

Refer to the sample project PLCopenMulti.project in the installation directory of CODESYS.

This example demonstrates how to implement a periodic cam on a linear drive. The example also demonstrates how to use the tappet function.

  1. Insert a cam named Example in the device tree below Applica­tion. Open the cam in the editor.

  2. Define a tappet in the Tappet tab.

    • X: 8.0

    • Positive pass: Invert

    • Negative pass: Invert

  3. Insert a virtual drive named Drive in the device tree below Soft­Motion General Axis Pool. For this axis, select the axis type Modulo with a modulo value of 360.

  4. Insert another virtual drive named Virtual. For this axis, select the axis type Modulo with a modulo value of 10.

  5. 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

  6. Insert a function block and assign the variable power1 to it. The function block is used for switching on the Drive.

    Configure the inputs as follows:

    • Axis: Drive

    • Enable: TRUE

    • bRegulatorOn: TRUE

    • bDriveStart TRUE

  7. Insert a function block and assign the variable power2 to it. The function block is used for switching on the Virtual.

    Configure the inputs as follows:

    • Axis: Virtual

    • Enable: TRUE

    • bRegulatorOn: TRUE

    • bDriveStart TRUE

  8. Insert a function block and assign the variable MoveVirtual to it. The function block 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

  9. Insert a function block and assign the variable TableSelect to it. The function block 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

  10. Insert a function block and assign the variable CamIn to it. The function block 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

  11. Insert a function block and assign the variable Tappet to it. The function block 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.

  12. The sample project provides a visualization for checking the indi­vidual function blocks and the position of the axes.

  13. Add the call of the MOTION_PRG program to the task MainTask.

  14. Load the project to the controller and start it.

See also