C/c++ code, C/c++ code -5 – National Instruments NI-Motion User Manual

Page 195

Advertising
background image

Chapter 13

Torque Control

© National Instruments Corporation

13-5

NI-Motion User Manual

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

axis;// axis number

u16

csr = 0;// Communication status register

u16

axisStatus;// Axis status

u16

moveComplete;

//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;

////////////////////////////////

//-------------------------------------------------

//Is is assumed that the axis being moved has an ADC

channel mapped //as its primary feedback. Position is

treated as binary volts. //Hence velocity is loaded

in binary volts/sec and acceleration as //binary

volts/sec^2.

//-------------------------------------------------

// Set the velocity for the move (in binary

volts/sec)

err = flex_load_velocity(boardID, axis, 10000,

0xFF);

CheckError;

// Set the acceleration for the move (in binary

volts/sec^2)

err = flex_load_acceleration(boardID, axis,

NIMC_ACCELERATION, 100000, 0xFF);

CheckError;

// Set the deceleration for the move (in binary

volts/sec^2)

Advertising