10-89
10 Sample Programming
NJ/NX-series CPU Unit Motion Control Userās Manual (W507)
10-2 Basic Programming
Samples
10
10-2-18 Updating the Cam Table End Point Index
This sample increases the valid number of data points by 10 in a cam table with a maximum number of
data points of 110 and a valid number of data points of 100. It also updates the end point index.
* The array elements ARRAY[0..N] are set with the Cam Editor in the Sysmac Studio. The range of the array is 0 to
109 in this sample.
10-2-18 Updating the Cam Table End Point Index
Main Variables Used in the Programming Samples
Variable name Data type Default Comment
CamProfile0 ARRAY[0..109] OF
_sMC_CAM_REF
--- This is a cam data variable with a maximum
number of data points of 110.* It contains
100 valid cam data points and 10 null cam
data points.
WriteCamdata BOOL FALSE This variable is used to start changing the
cam data. It is changed to TRUE to start
editing.
WriteDone BOOL FALSE This variable is used to indicate when the
changes to the cam data are completed. It
changes to TRUE when the changes to the
cam data are completed.
Ladder Diagram
InitFlag
1
2
3
4
5
StartPg
1
2
3
4
5
6
7
WriteCamData
_MC_COM.MFaultLvl.Active
EN
FaultHandler
FaultHandler
FOR Index := UINT#100 TO UINT#109 DO
PhaseData:=PhaseData+REAL#1.0;
DistanceData:=DistanceData+REAL#3.0;
CamProfile0[Index].Phase:=PhaseData;
CamProfile0[Index].Distance:=DistanceData;
END_FOR;
WriteDone:=TRUE;
If a minor fault level error occurs in the MC Common Error Status variable, the error handler for the device
(FaultHandler) is executed. Program the FaultHandler according to the device.
// The phases and displacements for null cam data are set.
PhaseData:=REAL#99.0;
DistanceData:=REAL#250.0;
// The Initialization Completed Flag is changed to TRUE.
InitFlag := TRUE;
The axis parameters are set. When setting the parameters is completed, InitFlag is changed to TRUE.
If StartPg and WriteCamData are TRUE, the values in the cam data variable are changed.
Phases and displacements are set for CamProfile[100] to CamProfile[109].
When the changes to the cam data variable are completed, WriteDone is changed to TRUE.