Chapter 5 Straight-Line Moves
NI-Motion User Manual 5-20 ni.com
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 axis;// Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
i32 moveTime1;// Time for the 1st segment
i32 moveTime2;// Time for the 2nd segment
i32 initialTime;
i32 currentTime;
//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 = 3;
// Set the axis number
axis = NIMC_AXIS1;
// Move time for the first segment
moveTime1 = 5000; //milliseconds
// Move time for the second segment
moveTime2 = 10000; //milliseconds
////////////////////////////////
//-------------------------------------------------
//First segment
//-------------------------------------------------
// Set the velocity for the move (in counts/sec)
err = flex_load_velocity(boardID, axis, 10000,
0xFF);
CheckError;
// Set the acceleration for the move (in
counts/sec^2)
err = flex_load_acceleration(boardID, axis,
NIMC_ACCELERATION, 100000, 0xFF);
CheckError;