Controlling the Movement of Single Axes in CFC with a Visualization Template

 

Refer to the sample project PLCopenSingle2.project in the instal­lation directory of CODESYS.

Any of the other IEC implementation languages can also be used instead of ST, for example CFC here. This language demonstrates the start and interrupt mechanism of the function blocks. In addition, the different start modes for the function block MC_MoveAbsolute can be tested for rotatory axes

  1. Insert a virtual drive named Drive in the device tree below Soft­Motion General Axis Pool.

  2. Double-click the object to open its editor.

  3. Change the parameters to a rotary drive with a period of 360°.

    • Axis type: Modulo

    • Modulo value [u]: 360.0

  4. Create a MOTION_PRG program in CFC. Insert the function blocks MC_Power, MC_MoveAbsolute, and MC_MoveVelocity.

    We recommend that you initialize the function block inputs. Then you do not have to specify the values again and again later when starting this test application.

    PROGRAM MOTION_PRG
    VAR
            mcp: MC_Power := (Enable:=TRUE, bRegulatorOn:=TRUE, bDriveStart:=TRUE);
            mcmv: MC_MoveVelocity :=(Velocity:=100, Acceleration:=100, Deceleration:=100, Direction:=positive);
            mcma: MC_MoveAbsolute := (Position:=180, Velocity:=100, Acceleration:=100, Deceleration:=100, Direction:=positive);
    END_VAR

    _sm_img_example_single_axis_visu_1.png 

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

  6. Add a Visualization object to the application.

  7. Position the visualization templates VISU_NEW_MC_MoveAbso­lute, VISU_NEW_MC_MoveVelocity, VISU_NEW_MC_Power, and RotDrive in the visualization editor. Link these to the function block instances of MOTION_PRG.

    _sm_img_example_single_axis_visu_2.png

  8. Compile the project and download it to the PLC. Start the project.

  9. Open the visualization in the editor. Click the Enable input (MC_Power) and then the Execute input (MC_Move_Absolute).

    ⇒ The drive rotates.

  10. Open the Drive virtual axis in the editor.

    ⇒ In the Online part of the General tab, you see the axis motion.

  11. Experiment with the parameters of these function blocks. Change the parameters and observe the behavior.