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:
Motion: Compensator
/* This sample demonstrates how to configure and use a 1-dimensional compensator.
Two overlapping compensation tables are applied to modify the follower axis motion
based on the moving axis position.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Compensator: 1D");
// set sample config params
const int INDEX_ZERO = 0;
const int INDEX_ONE = 1;
const int MIN = 0; // smallest value in counts on input axis where table is applied
const int MAX = 100; // largest value in counts on input axis where table is applied
const int DELTA = 10; // number of encoder counts on input axis between values in table
const int POINTS = ((MAX - MIN) / DELTA) + 1; // 11 points
// compensator tables (values are in raw counts not user units)
double[] table0 = new double[POINTS] { 0, 1000, -5000, -10000, 10000, 5000, -5000, 2500, 0, 2500, 5000 };
double[] table1 = new double[POINTS] { 0, 500, 0, 0, 0, 0, 0, 0, 0, 0, 1000 };
// print compensator info
Console.WriteLine($"Range: {MIN} to {MAX}, Delta: {DELTA}");
Console.WriteLine($"Points: {POINTS}");
// get rmp controller
try
{
Helpers.CheckErrors(controller);
// set compensator count before any RapidCodeObject get/create other than the controller
controller.CompensatorCountSet(2);
// reserve space in memory for the compensator tables
controller.CompensatorPointCountSet(INDEX_ZERO, table0.Length);
controller.CompensatorPointCountSet(INDEX_ONE, table1.Length);
// get & configure axes
Axis movingAxis = controller.AxisGet(axisNumber: 0);
Helpers.CheckErrors(movingAxis);
Axis followerAxis = controller.AxisGet(axisNumber: 1);
Helpers.CheckErrors(followerAxis);
Helpers.PhantomAxisReset(followerAxis);
// Verify the three following values are equal before configuring compensator
if (controller.CompensatorPointCountGet(INDEX_ZERO) == table0.Length && POINTS == table0.Length)
{
// set compensator0
controller.CompensatorConfigSet(
compensatorNumber: INDEX_ZERO,
inputAxis: movingAxis,
inputAxisType: RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION,
inputAxisMinimum: MIN,
inputAxisMaximum: MAX,
inputAxisDelta: DELTA,
outputAxis: followerAxis,
outputType: RSICompensatorOutputType.RSICompensatorOutputTypeSINGLE,
table: table0);
// set compensator1
// configure multiple overlapping compensation tables
// note: first compensator remains in SINGLE mode, second is set to ADDITIVE
controller.CompensatorConfigSet(
compensatorNumber: INDEX_ONE,
inputAxis: movingAxis,
inputAxisType: RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION,
inputAxisMinimum: MIN,
inputAxisMaximum: MAX,
inputAxisDelta: DELTA,
outputAxis: followerAxis,
outputType: RSICompensatorOutputType.RSICompensatorOutputTypeADDITIVE,
table: table1);
// move one index into the compensation table to test
movingAxis.PositionSet(DELTA);
// get results
double compPos = followerAxis.CompensationPositionGet();
// print results
Console.WriteLine($"Compensation position: {compPos} (expected: {table0[1] + table1[1]})");
// verify compensation
if (compPos != table0[1] + table1[1])
throw new Exception("❌ Compensator compensation position does not match expected value.");
// cleanup
Helpers.AbortMotionObject(followerAxis);
}
}
// handle errors as needed
finally
{
controller.CompensatorCountSet(0); // restore
controller.Delete(); // dispose
}
static void AbortMotionObject(RapidCodeMotion motionObject)
Aborts motion on the given RapidCodeMotion object (Axis or MultiAxis), waits for motion to stop,...
Definition _helpers.cs:186
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
static void PhantomAxisReset(Axis phantomAxis)
Configures a phantom axis on the controller.
Definition _helpers.cs:144
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
RSICompensatorOutputType
Compensator output types.
Definition rsienums.h:1419
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.
Definition rsienums.h:1218
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