Console.WriteLine("📜 Compensator: Single Axis");
int exitCode = 0;
const int INDEX_ZERO = 0;
const int MIN = 10;
const int MAX = 110;
const int DELTA = 10;
const int POINTS = ((MAX - MIN) / DELTA) + 1;
const double VELOCITY = 20.0;
const double ACCELERATION = 30.0;
const double DECELERATION = 30.0;
const double JERK = 50.0;
double[] table = new double[POINTS] { 0, 2, -3, -5, -3, 2, -3, 0, 2, -3, -5 };
Console.WriteLine($"Range: {MIN} to {MAX}, Delta: {DELTA}");
Console.WriteLine($"Points: {POINTS}");
Console.WriteLine("Compensator Table:");
for (int i = 0; i < POINTS; i++)
{
int inputPos = MIN + (i * DELTA);
Console.WriteLine($"@ Pos: {inputPos}, Compensate by: {table[i]}");
}
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
controller.CompensatorCountSet(1);
controller.CompensatorPointCountSet(compensatorNumber: INDEX_ZERO, pointCount: table.Length);
if (controller.CompensatorPointCountGet(INDEX_ZERO) == table.Length && POINTS == table.Length)
{
controller.CompensatorConfigSet(
compensatorNumber: INDEX_ZERO,
inputAxis: axis,
inputAxisMinimum: MIN,
inputAxisMaximum: MAX,
inputAxisDelta: DELTA,
outputAxis: axis,
table: table);
axis.PositionSet(MIN);
axis.MoveSCurve(position: MIN + DELTA, VELOCITY, ACCELERATION, DECELERATION, JERK);
axis.MotionDoneWait();
double compPos = axis.CompensationPositionGet();
Console.WriteLine($"Compensation position: {compPos} (expected: {table[1]})");
axis.AmpEnableSet(false);
axis.UserUnitsSet(originalUserUnits);
if (compPos != table[1])
throw new Exception("❌ Compensator compensation position does not match expected value.");
}
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.CompensatorCountSet(0);
controller.Delete();
}
return exitCode;
Constants used in the C# sample apps.
const bool USE_HARDWARE
Default: false.
const int EXIT_FAILURE
Exit code for failed execution.
const int AXIS_0_INDEX
Default: 0.
const int AMP_ENABLE_MS
Default: 750.
const int EXIT_SUCCESS
Exit code for successful execution.
double UserUnitsGet()
Get the number of counts per User Unit.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
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...
RSICompensatorOutputType
Compensator output types.
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.
Helpers namespace provides utility functions for common tasks in RMP applications.