Chapter 10 Electronic Gearing and Camming
NI-Motion User Manual 10-20 ni.com
u8 slaveAxis = 1; // Slave axis ID
u8 buffer = 1; // Buffer to contain the
cam table
i32 positionArr[] = {0, 10000, 40000, 45000, 45000,
40000, 10000, 0}; // Position array
u32 positionSize = sizeof(positionArr) / sizeof(i32);
// Number of positions in the array
NIMC_DATA data; // Generic data structure
i32 targetPos = 10000; // Position to move to
f64 velocity = 10000; // Velocity limit for this move
u16 moveComplete;
// For error handling
u16 csr; // Communication status
u16 commandID; // Command ID that causes the
error
u16 resourceID; // Resource ID that is set on
the failed command
i32 errorCode; // Error code from the
controller
// Configuring camming profile.
// Configure the cam master & master cycle
err = flex_configure_camming_master(boardID,
slaveAxis, masterAxis, camCycle);
CheckError;
// Configure the cam table
err = flex_configure_buffer(boardID, buffer,
slaveAxis, NIMC_CAMMING_POSITION, positionSize,
positionSize, TRUE, bufferInterval, &bufferInterval);
CheckError;
// Write the data to the buffer
err = flex_write_buffer(boardID, buffer,
positionSize, NIMC_REGENERATION_NO_CHANGE, positionArr,
0xFF);
CheckError;
// Enable camming immediately
err = flex_enable_camming_single_axis(boardID,
slaveAxis, TRUE, -1.0);
CheckError;
// At this point camming is engaged or started. You
can start the master
// axis or insert other functionality here.
Sleep(5000);