Chapter 8
Reference Moves
©
National Instruments Corporation
8-5
//
Wait for Find Reference to complete on the axis AND
also check
//
for modal errors at the same time
do
{
//
Read the current position of axis
err =
flex_read_pos_rtn
(boardID, axis,
&position);
CheckError;
//
Display the current position of axis
printf("\rAxis %d position: %10d", axis,
position);
//
Check if the axis has stopped because of axis
off or following
//
error
err =
flex_read_axis_status_rtn
(boardID, axis,
&axisStatus);
//
Check if the reference has finished finding
err =
flex_check_reference
(boardID, axis, 0,
&found, &finding);
CheckError;
//
Read the communication status register - check
the modal
//
error bit
err =
flex_read_csr_rtn
(boardID, &csr);
CheckError;
if
(csr & NIMC_MODAL_ERROR_MSG)
{
flex_stop_motion
(boardID,NIMC_AXIS1,
NIMC_DECEL_STOP, 0);//
Stop the Motion
err = csr & NIMC_MODAL_ERROR_MSG;
CheckError;
}
//
test for find reference complete, following
error, or axis
//
off status
}
while
(!(axisStatus & (NIMC_FOLLOWING_ERROR_BIT |
NIMC_AXIS_OFF_BIT)) && finding);
printf("\nAxis %d position: %10d", axis, position);
if
(found)
printf("\rAxis found reference");
else
printf("\rAxis did not find reference");
printf("\n\nFinished\n");
return
;//
Exit the Application