National Instruments NI-Motion User Manual
Page 149

Chapter 11
Acquiring Time-Sampled Position and Velocity Data
© National Instruments Corporation
11-5
i32
axis1Positions[200];// Array to store the
positions (1)
i32
axis1Velocities[200];// Array to store
velocities(1)
i32
axis2Positions[200];// Array to store the
positions (2)
i32
axis2Velocities[200];// Array to store
velocities(2)
u16
numSamples = 200;// Number of samples
i32
returnData[4];// Need size of 4 for 2 axes worth
of data
//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;
// Axes whose data needs to be acquired
axisMap = ((1<<1) | (1<<2)); // Axis 1 and axis 2
////////////////////////////////
err = flex_acquire_trajectory_data(boardID, axisMap,
numSamples, 3/* ms time period*/);
CheckError;
Sleep(numSamples * 3/* ms time period*/);
for
(i=0; i<numSamples; i++){
Sleep (2);
// Read the trajectory data
err = flex_read_trajectory_data_rtn(boardID,
returnData);
CheckError;
// Two axes worth of data is read every sample
axis1Positions[i] = returnData[0];
axis1Velocities[i] = returnData[1];
axis2Positions[i] = returnData[2];
axis2Velocities[i] = returnData[3];
}
return
;// Exit the Application
//////////////////////
// Error Handling
//
nimcHandleError; //NIMCCATCHTHIS: