National Instruments NI-Motion User Manual

Page 110

Advertising
background image

Chapter 8

Reference Moves

NI-Motion User Manual

8-4

ni.com

//Variables for modal error handling

u16

commandID;// The commandID of the function

u16

resourceID;// The resource ID

i32

errorCode;// Error code

//Get the board ID

printf("Enter the Board ID: ");

scanf("%d", &scanVar);

boardID=(u8)scanVar;

//Check if the device is at power up reset condition

err = flex_read_csr_rtn(boardID, &csr);

CheckError;

if

(csr & NIMC_POWER_UP_RESET ){

printf("\nThe FlexMotion device is in the reset

condition. Please initialize the device before

");

printf("running this example. The

\"flex_initialize_controller\" function will

initialize the ");

printf("board with settings selected through

Measurement & Automation Explorer.\n");

return;

}

//Get the axis number

printf("Enter the axis: ");

scanf("%d",&scanVar);

axis=(u8)scanVar;

//Flush the Stdin

fflush(stdin);

//Load acceleration and deceleration to the axis

selected

err = flex_load_rpsps(boardID, axis, NIMC_BOTH,

acceleration, 0xFF);

CheckError;

//Load velocity to the axis selected

err = flex_load_rpm(boardID, axis, velocity, 0xFF);

CheckError;

//Start the Find Reference move

err = flex_find_reference(boardID, axis, 0,

NIMC_FIND_HOME_REFERENCE);

CheckError;

Advertising