National Instruments NI-Motion Home Safety Product User Manual


 
Chapter 13 Torque Control
© National Instruments Corporation 13-17 NI-Motion User Manual
// 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;
do
{
// Read the ADC channel number 1 and calculate the
velocity to //be updated
err = flex_read_adc16_rtn(boardID, NIMC_ADC1,
&adcValue);
CheckError;
// Set the velocity based on the ADC value read
err = flex_load_velocity(boardID, axis, (adcValue
* constant), 0xFF);
CheckError;
// Update the velocity
err = flex_start(boardID, axis, 0);
CheckError;
// Check the move complete status/following
error/axis off //status
err = flex_read_axis_status_rtn(boardID, axis,
&axisStatus);
CheckError;
// Read the communication status register and
check the modal //errors
err = flex_read_csr_rtn(boardID, &csr);
CheckError;
// Check the modal errors
if (csr & NIMC_MODAL_ERROR_MSG)
{
err = csr & NIMC_MODAL_ERROR_MSG;
CheckError;
}