CNC Example 06: Using Path3D with SoftMotion CNC
See the CNC06_File_3DPath.project
sample project in the installation directory of CODESYS under ..\CODESYS SoftMotion\Examples
.
This example extends the previous example CNC05_File
. It demonstrates a possible application of the Path3D visualization element with CODESYS SoftMotion CNC.
Extending the program CNC_File to CNC_File_Path3D
Open the Library Manager and add the
SM3_CNC_Visu
library.Create an instance of
SMC_PathCopierFile
inCNC_PreparePath
and call it at the beginning of the path processing (iState=0
).Programming:
In the Visualization visualization, replace the previously used graphical display of the position with the Path3D element.
Change the properties of the Path3D element:
:CNC_prepare_path.pcf.vs3dt
Insert the Frame visualization element.
Reference the ControlPanel visualization from the
VisuElem3DPath
library. This element is used for controlling the camera position of the element.In the declaration of the
CNC_PreparePath
program, create an instance ofVisuStruct3DControl
(VisuElem3DPath
library):vc: VisuStruct3DControl;
.This instance forms the data interface between the Path3D element and the camera control panel.
Change the properties of the Path3D element:
:CNC_PreparePath.vc
Change the properties of the ControlPanel element:
:CNC_PreparePath.vc
Compile, download, and start the application.
The Path3D element shows the path. You can control the camera position from the panel.
Add an instance of the
SMC_PositionTracker
function block in theCNC
program. Create a memory for tracing the current track (the last traveled positions).pt: SMC_PositionTracker;
pointbuffer_pt: ARRAY [0..1000] OF VisuStruct3DPathPoint;
Insert a call of the instance:
SMC_PositionTracker
into theInterpolation
actionCFC:
Link the path data to the Path3D element. Change the properties of the Path3D element:
:CNC.pt.vs3dt
Go online and start the application.
The Path3D element displays the last interpolated path also to the path.
Configure other properties of Path3D. For example, configure the processed path elements to be displayed in gray:
:Gray