45using RSI.RapidCode.dotNET;
52class Compensator : StaticMemoryTestBase
56 public void Compensator1D()
67 const int POINTS = ((MAX - MIN) / DELTA) + 1;
70 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 };
71 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 };
79 Axis moving_axis = CreateAndReadyAxis(Constants.MAIN_AXIS_NUMBER);
80 Axis follower_axis = CreateAndReadyAxis(Constants.DRIVEN_AXIS_NUMBER);
96 Assert.That(TABLE0.Length, Is.EqualTo(POINTS));
99 moving_axis.PositionSet(DELTA);
100 Assert.That(follower_axis.CompensationPositionGet(), Is.EqualTo(TABLE0[1] + TABLE1[1]));
104 public void Compensator2D()
109 const int X_MAX = 500;
110 const int X_DELTA = 100;
112 const int Y_MAX = 500;
113 const int Y_DELTA = 100;
114 const int COMPENSATOR_X_POINTS = ((X_MAX - X_MIN) / X_DELTA) + 1;
115 const int COMPENSATOR_Y_POINTS = ((Y_MAX - Y_MIN) / Y_DELTA) + 1;
116 const int POINTS = (COMPENSATOR_X_POINTS) * (COMPENSATOR_Y_POINTS);
119 double[] TABLE =
new double[POINTS] {
121 100, 200, -200, 10, 300, 0,
122 100, 200, -500, 400, 500, 0,
124 -300, 300, -300, -300, -300, 0,
134 Axis x = CreateAndReadyAxis(Constants.X_AXIS_NUMBER);
135 Axis y = CreateAndReadyAxis(Constants.Y_AXIS_NUMBER);
136 Axis z = CreateAndReadyAxis(Constants.Z_AXIS_NUMBER);
138 z.ErrorLimitTriggerValueSet(1);
141 controller.
CompensatorConfigSet(Constants.COMP_NUM_ZERO, x,
RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION, X_MIN, X_MAX, X_DELTA, y,
RSIAxisMasterType.RSIAxisMasterTypeAXIS_ACTUAL_POSITION, Y_MIN, Y_MAX, Y_DELTA, z,
RSICompensatorOutputType.RSICompensatorOutputTypeSINGLE, TABLE);
148 Assert.That(z.CompensationPositionGet(), Is.EqualTo(TABLE[0]));
150 x.PositionSet(X_DELTA);
151 y.PositionSet(Y_DELTA);
152 Assert.That(z.CompensationPositionGet(), Is.EqualTo(TABLE[7]));
154 x.PositionSet(X_DELTA * 2);
155 y.PositionSet(Y_DELTA * 2);
156 Assert.That(z.CompensationPositionGet(), Is.EqualTo(TABLE[14]));
160 public void CompensatorSingleAxis()
162 Console.WriteLine(
"Start SompensatorSingleAxis");
168 const int DELTA = 10;
169 const int POINTS = ((MAX - MIN) / DELTA) + 1;
172 double[] TABLE =
new double[POINTS] { 0, 2, -3, -5, -3, 2, -3, 0, 2, -3, -5, -3, 2, -3, 0, 2, -3, -5, -3, 2, -3 };
180 Axis axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
187 axis.MoveSCurve(DELTA * 2);
188 axis.MotionDoneWait();
196 Assert.That(TABLE.Length, Is.EqualTo(POINTS));
197 Assert.That(axis.CompensationPositionGet(), Is.EqualTo(TABLE[1]));
199 Console.WriteLine(
"End SompensatorSingleAxis");
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 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.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
RSICompensatorOutputType
Compensator output types.
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.