Chapter 5
Straight-Line Moves
5-16
ni.com
CheckError;
//
Read the communication status register and
check the
modal //
errors
err =
flex_read_csr_rtn
(boardID, &csr);
CheckError;
// Check the modal errors
if
(csr & NIMC_MODAL_ERROR_MSG)
{
err = csr & NIMC_MODAL_ERROR_MSG;
CheckError;
}
//
Get the current time and check if time is over
for the
//
second segment
currentTime = timeGetTime();
if((currentTime - initialTime) >= moveTime2)
break;
Sleep (100); //
Check every 100 ms
}
while
(!(axisStatus) && !(axisStatus &
NIMC_FOLLOWING_ERROR_BIT) && !(axisStatus &
NIMC_AXIS_OFF_BIT)); //
Exit on move
complete/following error/axis off
//
Decelerate the axis to a stop
err =
flex_stop_motion
(boardID, axis,
NIMC_DECEL_STOP, 0);
CheckError;
return
;//
Exit the Application
//
Error Handling
nimcHandleError; //
NIMCCATCHTHIS:
//
Check to see if there were any modal errors
if
(csr & NIMC_MODAL_ERROR_MSG){
do
{
//
Get the command ID, resource ID, and the
error code of the
//
modal error from the
error stack on the device
flex_read_error_msg_rtn
(boardID,&commandI
D,&resourceID, &errorCode);
nimcDisplayError(errorCode,commandID,res
ourceID);
//
Read the communication status register