10 Sample Programming
10-90
NJ/NX-series CPU Unit Motion Control Userās Manual (W507)
// The axis parameters are set. When setting the parameters is completed, InitFlag is changed to TRUE.
IF InitFlag=FALSE THEN
// 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;
END_IF;
// If a minor fault level error occurs in the MC Common Error Status variable, the error handler for the device is
executed.
// Program the FaultHandler according to the device.
IF _MC_COM.MFaultLvl.Active=TRUE THEN
FaultHandler();
END_IF;
// If StartPg and WriteCamData are TRUE, the values in the cam data variable are changed.
// The phases and displacements are set in CamProfile[100] to CamProfile[109].
// When the changes to the cam data variable are completed, WriteDone is changed to TRUE.
IF StartPg=TRUE
AND WriteCamData=TRUE THEN
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;
END_IF;
// If the changes to the cam data variable are completed, the Set Cam Table Properties instruction is executed.
IF WriteDone=TRUE THEN
Set_Cam_Ex := TRUE;
END_IF;
//MC_SetCamTableProperty
SET_CAM(
CamTable := CamProfile0,
Execute := Set_Cam_Ex,
Done => Set_Cam_D,
EndPointIndex => Set_Cam_Epi,
MaxDataNumber => Set_Cam_Mdn,
Busy => Set_Cam_B,
CommandAborted => Set_Cam_Ca,
Error => Set_Cam_Err,
ErrorID => Set_Cam_ErrID
);
ST Programming
Set_Cam_B
Set_Cam_Ca
Set_Cam_Err
Set_Cam_ErrID
Set_Cam_D
Done
Error
CommandAborted
CamTable
Busy
ErrorID
Execute
SET_CAM
MC_SetCamTableProperty
CamTable
CamProfile0 CamProfile0
Set_Cam_Mdn
MaxDataNumber
Set_Cam_Epi
EndPointIndex
WriteDone
If the changes to the cam data variable are completed, the Set Cam Table Properties instruction is executed.