C/C++ Code; 1D Straight-Line Move 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.

1D Straight-Line Move Code

// Main Function
void main(void)
{
u8 boardID;// Board identification number
u8 axis; // Axis number
u16 csr = 0;// Communication status register
u16 axisStatus;// Axis status
u16 moveComplete;
//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;
////////////////////////////////
// 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;
// Set the deceleration for the move (in
counts/sec^2)
err = flex_load_acceleration(boardID, axis,
NIMC_DECELERATION, 100000, 0xFF);
CheckError;
// Set the jerk - scurve time (in sample periods)
examples
5-5
Chapter 5
Straight-Line Moves
folder on the
NI-Motion User Manual

Advertisement

Table of Contents
loading

Table of Contents