C/C++ Code - National Instruments NI-Motion User Manual

Motion control
Table of Contents

Advertisement

C/C++ Code

© National Instruments Corporation
The following example code is not necessarily complete, and may
not compile if copied exactly. Refer to the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 axis; // Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
//Variables for modal error handling
u16 commandID;// The commandID of the function
u16 resourceID;// The resource ID
i32 errorCode;// Error code
///////////////////////////////
// Set the board ID
boardID = 1;
// Set the axis number
axis = NIMC_AXIS1;
////////////////////////////////
// Route breakpoint 1 to RTSI line 1
err = flex_select_signal (boardID, NIMC_RTSI1
/*destination*/, NIMC_BREAKPOINT1/*source*/);
CheckError;
//Configure Breakpoint
err = flex_configure_breakpoint(boardID, axis,
NIMC_MODULO_BREAKPOINT, NIMC_SET_BREAKPOINT,
NIMC_OPERATION_SINGLE);
CheckError;
// Load Breakpoint Modulus - repeat period
err = flex_load_bp_modulus(boardID, axis, 500,
0xFF);
CheckError;
// Load Breakpoint Position - position at which
breakpoint should //occur every modulo
err = flex_load_pos_bp(boardID, axis, 0, 0xFF);
CheckError;
for(;;){
// Enable the breakpoint on axis 1
12-25
Chapter 12
Synchronization
folder on the
examples
NI-Motion User Manual

Advertisement

Table of Contents
loading

Table of Contents