Chapter 9
Blending Moves
©
National Instruments Corporation
9-7
C/C++ Code
The following example code is not necessarily complete, and may
not compile 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;
u16
complete;//
Move or blend complete status
//
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 space number
vectorSpace = NIMC_VECTOR_SPACE1;
////////////////////////////////
//
Configure a 2D coordinate space comprised of axes 1,
and 2
err =
flex_config_vect_spc
(boardID, vectorSpace,
NIMC_AXIS1, NIMC_AXIS2, NIMC_NOAXIS);
CheckError;
//
Set the velocity for the move (in counts/sec)
err =
flex_load_velocity
(boardID, vectorSpace, 10000,
0xFF);
CheckError;
//
Set the acceleration for the move (in counts/sec^2)
err =
flex_load_acceleration
(boardID, vectorSpace,
NIMC_ACCELERATION, 100000, 0xFF);
CheckError;
//
Set the deceleration for the move (in counts/sec^2)
err =
flex_load_acceleration
(boardID, vectorSpace,
NIMC_DECELERATION, 100000, 0xFF);
CheckError;
//
Set the jerk or s-curve in sample periods
err =
flex_load_scurve_time
(boardID, vectorSpace, 1,
0xFF);
CheckError;
//
Set the operation mode to absolute position