APIs, concepts, guides, and more

◆ CompensatorPointCountSet()

void CompensatorPointCountSet ( int32_t compensatorNumber,
int32_t pointCount )
Parameters
compensatorNumberwhich compensator to configure?
pointCountthe number of points which will be stored in the table
Description:
CompensatorPointCountSet sets the number of Compensator points allocated on the controller. This must be configured before creating Axis or MultiAxis objects, as these counts change the dynamic memory allocation inside the controller's firmware.

Part of the Compensator method group.

Sample Code:
Compensator
// To use a compensator space in memory must be reserved before creating axis objects. For this sample app we will create two overlapping compensation tables.
controller.CompensatorCountSet(2);
// To know how much memory will be required for the compensator table you must first know your MIN, MAX, and DELTA. See our compensator topic page for more information.
const int MIN = 0; // The smallest value in counts on the input axis where a table will be applied to the output axis.
const int MAX = 200; // The largest value in counts on the input axis where a table will be applied to the output axis.
const int DELTA = 10; // The number of encoder counts on the input axis between values in the table.
const int POINTS = ((MAX - MIN) / DELTA) + 1; // The space required in memory for the table to be held. (21)
// Compensator table values use Axis COUNTS NOT user units to be applied to the output axis.
double[] TABLE0 = new double[POINTS] { 0, 1000, -5000, -10000, 10000, 5000, -5000, 2500, 0, 2500, 5000, 7500, 1000, 1250, 1000, 7500, 5000, 2500, 0, -2500, -1000 };
double[] TABLE1 = new double[POINTS] { 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 1000, -5000, -1000, 1000, 5000, -5000, 2500, 0, -1000, 0, 0 };
// Reserve space in memory for the compensator tables.
controller.CompensatorPointCountSet(Constants.COMP_NUM_ZERO, TABLE0.Length);
controller.CompensatorPointCountSet(Constants.COMP_NUM_ONE, TABLE1.Length);
controller.AxisCountSet(2);
Axis moving_axis = CreateAndReadyAxis(Constants.MAIN_AXIS_NUMBER); // Helper function to setup an axis
Axis follower_axis = CreateAndReadyAxis(Constants.DRIVEN_AXIS_NUMBER); // Helper function to setup an axis
// NOTE the three following values must be equal before a compensator can be configured. Otherwise an error will be thrown. See topic page for more info.
if (controller.CompensatorPointCountGet(Constants.COMP_NUM_ZERO) == TABLE0.Length && POINTS == TABLE0.Length)
{
// Initalize the Compensator
controller.CompensatorConfigSet(Constants.COMP_NUM_ZERO, moving_axis, RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION, MIN, MAX, DELTA, follower_axis, RSICompensatorOutputType.RSICompensatorOutputTypeSINGLE, TABLE0);
// You can also configure multiple overlaping compensation tables. Note the first compensator remains in SINGLE mode but the second is set to ADDITIVE
controller.CompensatorConfigSet(Constants.COMP_NUM_ONE, moving_axis, RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION, MIN, MAX, DELTA, follower_axis, RSICompensatorOutputType.RSICompensatorOutputTypeADDITIVE, TABLE1);
}
Warning
Important usage instructions for all RapidCode object count set methods:
This should be done after successful MotionController::Create but before any RapidCode object creation, (MotionController::AxisGet, MotionController::MultiAxisGet, etc.) as changing object counts will reconfigure the RMP's dynamic memory allocation which invalidates all preexisting RapidCode objects.
See also
AxisCountSet, MotionCountSet, RecorderCountSet, UserLimitCountSet, MathBlockCountSet, CompensatorCountSet
CompensatorCountSet
Examples
Compensator.cs.