Chapter 15 Scanning
© National Instruments Corporation 15-17 NI-Motion User Manual
C/C++ Code
The following example code is not necessarily complete, and may
notcompile if copied exactly. Refer to the examples folder on the
NI-Motion CD for files that are complete and compile as is.
// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 vectorSpace;// Vector space number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 status;// Temporary copy of status
u16 moveComplete;// Move complete status
i32 i;
i32 points[1994] = NIMC_SPIRAL_ARRAY;// Array of 2D
points to move
u32 numPoints = 1994;// Total number of points to
contour through
i32 bufferSize = 1000;// The size of the buffer to
allocate on the //motion controller
f64 actualInterval;// The interval at which the
motion controller can //really contour
i32* downloadData = NULL;// The temporary array that
is created to //download the points to the motion
controller
u32 currentDataPoint = 0;// Indicates the next point
in the points //array that is to be downloaded
i32 backlog;// Indicates the available space to
download more //points
u16 bufferState;// Indicates the state of the onboard
buffer
u32 pointsDone;// Indicates the number of points that
have been //consumed
u32 dataCopied = 0;// Keeps track of the points
copied
//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 vector number