Exporting and Importing Cams
The BasicMotion_CamExportAndImport.project sample project is located in the installation directory of CODESYS under ..\CODESYS SoftMotion\Examples.
The example shows how to export and import a cam.
Structure of the application
The application consists of the PLC_PRG program and a CamEditor cam.
PLC_PRGThe program consists of a simple state machine where a cam is created in IEC code in the
STATE_CREATE_CAMstate. For more information, see the following: Creating Cams Programmatically.Then this cam is exported in the
STATE_EXPORT_CAMstate using the SMC_WriteCAM function block and then imported in theSTATE_START_IMPORT_CAMstate using the SMC_ReadCAM function block.CamEditorThe cam does not have any meaning at first because it is not used in the application. The exported cam from
PLC_PRGcan be imported into the cam editor. This is a manual step which is described in the following section.
Commissioning
Build the application and download it to a controller.
Start the application.
The
PLC_PRGprogram generates the cam and exports it to thePlcLogicdirectory of the controller.You can also display and edit the exported cam in the cam editor. To do this, open the
CamEditorcam and import the cam using the Read Cam Online File command.After you have made changes, you can export the modified cam using the Write Cam Online File command. This cam can be read into the IEC code with the
SMC_ReadCAMfunction block and used in the application.