Chapter 5
Straight-Line Moves
5-14
ni.com
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;
//
Set the deceleration for the move (in
counts/sec^2)
err =
flex_load_acceleration
(boardID, axis,
NIMC_DECELERATION, 100000, 0xFF);
CheckError;
//
Set the jerk (s-curve value) for the move (in
sample periods)
err =
flex_load_scurve_time
(boardID, axis, 100,
0xFF);
CheckError;
//
Set the operation mode to velocity
err =
flex_set_op_mode
(boardID, axis,
NIMC_VELOCITY);
CheckError;
//
Start the move
err =
flex_start
(boardID, axis, 0);
CheckError;
//
Wait for the time for first segment
initialTime = timeGetTime();