APIs, concepts, guides, and more

◆ CompensatorConfigSet() [4/4]

void CompensatorConfigSet ( int32_t compensatorNumber,
int32_t inputAxisNumber,
RSIAxisMasterType inputAxisType,
double inputAxisMinimum,
double inputAxisMaximum,
double inputAxisDelta,
int32_t outputAxisNumber,
RSICompensatorOutputType outputType,
const double *const table )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
compensatorNumberwhich compensator to configure?
inputAxisTypeFeedback or position to follow
inputAxisNumberThis specifies the axis of the first compensating Axis object. The position from this Axis will be used to index a single dimension of the compensation table. This number must correspond to a valid (existing) and enabled Axis on the controller.
inputAxisMinimumThe minimum feedback position (COUNTS) along the first compensation axis where compensation will occur.
inputAxisMaximumThe maximum feedback position (COUNTS) along the first compensation axis where compensation will occur.
inputAxisDeltaSpacing between compensation positions on the compensating axis. positionDelta must meet some specifications: positionDelta must be an exact multiple of the range (i.e. ((range.positionMax - range.positionMin) / positionDelta) must be an integer value). positionDelta must be greater than zero. positionDelta must be greater than (positionMax - positionMin).
outputAxisNumberThis specifies the axis of the Axis to be compensated by the Compensator object. This number must correspond to a valid (existing) and enabled Axis on the controller.
outputTypeSets the behavior of a compensator. SINGLE: Only the most recent compensator configured to output on a specific axes will be applied ADDITIVE: The output of the compensator will be added with the result form the previously applied compensator on the specific axis.
tablethe points which will be written to the table

Part of the Compensator method group.

Sample Code:
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(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(movingAxis);
movingAxis.Abort();
movingAxis.ClearFaults();
controller.SampleWait(10);
movingAxis.PositionSet(0);
Axis followerAxis = controller.AxisGet(Constants.AXIS_1_INDEX);
Helpers.CheckErrors(followerAxis);
followerAxis.Abort();
followerAxis.ClearFaults();
controller.SampleWait(10);
followerAxis.PositionSet(0);
// Verify the three following values are equal before configuring compensator
if (controller.CompensatorPointCountGet(INDEX_ZERO) == table0.Length && POINTS == table0.Length)
{
// set compensator0
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
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.");
}
}
// handle errors as needed
finally
{
controller.CompensatorCountSet(0); // restore
controller.Delete(); // dispose
}
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
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
double CompensationPositionGet()
Get the compensator position.
void PositionSet(double position)
Set the Command and Actual positions.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5870
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static MotionController * Get()
Get an already running RMP EtherCAT controller.
int32_t CompensatorPointCountGet(int32_t compensatorNumber)
Get the number of points for use with a Compensator.
void CompensatorPointCountSet(int32_t compensatorNumber, int32_t pointCount)
Set the number of points for use with a Compensator.
void SampleWait(uint32_t samples)
Wait for controller firmware to execute samples.
void Delete(void)
Delete the MotionController and all its objects.
void CompensatorCountSet(int32_t compensatorCount)
Set the number of Compensators available in the firmware.
void CompensatorConfigSet(int32_t compensatorNumber, int32_t firstInputAxisNumber, RSIAxisMasterType firstInputAxisType, double firstInputAxisMinimum, double firstInputAxisMaximum, double firstInputAxisDelta, int32_t secondInputAxisNumber, RSIAxisMasterType secondInputAxisType, double secondInputAxisMinimum, double secondInputAxisMaximum, double secondInputAxisDelta, int32_t outputAxisNumber, RSICompensatorOutputType outputType, const double *const table)
Configure a 2D compensator.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void Abort()
Abort an axis.
RSICompensatorOutputType
Compensator output types.
Definition rsienums.h:1419
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.
Definition rsienums.h:1218
See also
CompensatorCountSet