Chapter 14
Onboard Programs
14-32
ni.com
err =
flex_jump_on_event
(boardID, 0,
NIMC_CONDITION_TRUE, 0, 0, NIMC_MATCH_ALL, 1/*label
number*/);
CheckError;
//
End Program Storage
err =
flex_end_store
(boardID, 1);
CheckError;
//------------------------------------------------
//
Host program. This programs monitors the 13th bit
in the move
//
complete status register and records
the position the axis is
//
going to move to.
//------------------------------------------------
do
{
//
Check the move complete status/following
error/axis off
//
status
err =
flex_read_axis_status_rtn
(boardID, axis,
&axisStatus);
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;
}
//
Read the move complete status register and once
the 13th bit
//
is set; reset the bit and read the
target position.
err =
flex_read_mcs_rtn
(boardID,
&moveCompleteStatus);
CheckError;
if
(moveCompleteStatus & (1<<13)){
i32
currentTargetPosition;
//
Reset the 13th bit in the move complete
status
register
err =
flex_set_status_momo
(boardID, 0,
0x20);
CheckError;