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

Motion control
Table of Contents

Advertisement

Chapter 14
Onboard Programs

C/C++ Code

NI-Motion User Manual
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
i32 targetPosition;
i32 multiplier;
u16 axisStatus;
u16 moveCompleteStatus;
//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 move length
targetPosition = 5000;
// Set the multiplier
multiplier = -1;
//------------------------------------------------
// Onboard program. This onboard program moves an
axis back and //forth between targetPosition and
-targetPosition. Before //reversing directions it
//indicates to the host computer that it //is about
to do so.
//-------------------------------------------------
// Initialize onboard variable 2 to the multiplier
used to change //the target position
err = flex_load_var(boardID, multiplier, 2);
CheckError;
// Initialize onboard variable 1 to the target
position
14-30
folder on the
examples
ni.com

Advertisement

Table of Contents
loading

Table of Contents