Chapter 14 Onboard Programs
NI-Motion User Manual 14-40 ni.com
CheckError;
// Wait for move to complete
err = flex_wait_on_event(boardID, 0, NIMC_WAIT,
NIMC_CONDITION_MOVE_COMPLETE, 2/*Indicates axis 1*/,
0, NIMC_MATCH_ALL, 1000 /*time out*/, 0);
CheckError;
// End Program Storage
err = flex_end_store(boardID, 3);
CheckError;
//------------------------------------------------
// Onboard program 1. The main onboard program
monitors an IO line //and based on state of the IO
line executes onboard program 2 or //onboard program
3.
//------------------------------------------------
// Begin onboard program storage - program number 1
err = flex_begin_store(boardID, 1);
CheckError;
// Insert Label number 1
err = flex_insert_program_label(boardID, 1);
CheckError;
// Jump to label 2 if the line 1 on port one is active
err = flex_jump_on_event (boardID, NIMC_IO_PORT1,
NIMC_CONDITION_IO_PORT_MATCH, 2/*Indicates line 1*/,
0, NIMC_MATCH_ALL, 2/*label number*/);
CheckError;
// If the above jump failed, the IO line is not
active; execute //program #3
err = flex_run_prog(boardID, 3);
CheckError;
// Wait for program 3 to finish executing
err = flex_wait_on_event(boardID, 3 /*program #*/,
NIMC_WAIT, NIMC_CONDITION_PROGRAM_COMPLETE, 0, 0,
NIMC_MATCH_ALL, 1000 /*time out*/, 0);
CheckError;
// Jump unconditionally to label 1 and check IO line
again
err = flex_jump_on_event (boardID, 0,
NIMC_CONDITION_TRUE, 0, 0, NIMC_MATCH_ALL, 1/*label
number*/);
CheckError;