10 Sample Programming
10-8
NJ/NX-series CPU Unit Motion Control Userās Manual (W507)
// Check that the Servo Drive is ready when StartPg is TRUE and turn ON the Servo for axis 0.
// If the Servo Drive is not ready, turn OFF the Servo for axis 0.
IF (StartPg=TRUE)
AND (MC_Axis000.DrvStatus.Ready=TRUE) THEN
Pwr_En:=TRUE;
ELSE
Pwr_En:=FALSE;
END_IF;
// If a minor fault level error occurs for axis 0, the error handler for the device (FaultHandler) is executed.
// Program the FaultHandler according to the device.
IF MC_Axis000.MFaultLvl.Active=TRUE THEN
FaultHandler();
END_IF;
// If ResetON is TRUE (i.e., when the external button is ON) and the command current velocity is zero, the error is
reset.
IF (ResetOn=TRUE)
AND (MC_Axis000.Status.ErrorStop=TRUE)
AND (MC_Axis000.Details.Idle=TRUE) THEN
Reset_Ex := TRUE; // Minor fault is reset.
END_IF;
// MC_Power
PWR(
Axis := MC_Axis000,
Enable := Pwr_En,
Status => Pwr_Status,
Busy => Pwr_Bsy,
Error => Pwr_Err,
ErrorID => Pwr_ErrID
);
// MC_Reset
RESET(
Axis := MC_Axis000,
Execute := Reset_Ex,
Done => Reset_D,
Busy => Reset_Bsy,
Failure => Reset_Fai,
Error => Reset_Err,
ErrorID => Reset_ErrID
);
ST Programming
Reset_Bsy
Reset_Fail
Reset_Err
Reset_ErrID
Reset_D
Done
Error
Failure
Axis
Busy
ErrorID
Execute
RESET
MC_Reset
Axis
MC_Axis000
MC_Axis000.Status.ErrorStop
MC_Axis000.Details.Idle
ResetON
If ResetON is TRUE (i.e., when the external button is ON) and the command current velocity is zero, the error is reset.