APIs, concepts, guides, and more
gearing.cs
/* This sample demonstrates how to configure electronic gearing between two axes.
The follower axis position is controlled as a ratio of the moving axis position.
Moving Axis: the master axis that drives the motion.
Follower Axis: follows the moving axis at a specified gear ratio.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 Gearing");
// get rmp objects
// set sample config params
const int NUMERATOR = 2; // for every 1 rotation of moving axis...
const int DENOMINATOR = 1; // ...follower axis rotates 2 times (2:1 ratio)
const double POSITION = 10;
const double VELOCITY = 10;
const double ACCELERATION = 100;
const double DECELERATION = 100;
const double JERK_PERCENT = 50;
try
{
Helpers.CheckErrors(controller);
// get axes
Axis movingAxis = controller.AxisGet(Constants.AXIS_0_INDEX);
Helpers.CheckErrors(movingAxis);
Axis followerAxis = controller.AxisGet(Constants.AXIS_1_INDEX);
Helpers.CheckErrors(followerAxis);
// configure phantom axes
Helpers.PhantomAxisReset(followerAxis);
// enable phantoms to keep commanded position after motion done
movingAxis.AmpEnableSet(true);
followerAxis.AmpEnableSet(true);
// configure follower axis to gear to moving axis
followerAxis.GearingEnable(
masterAxisNumber: movingAxis.NumberGet(),
masterFeedbackSource: RSIAxisMasterType.RSIAxisMasterTypeAXIS_COMMAND_POSITION, // use COMMAND for phantoms, ACTUAL for real axis
numerator: NUMERATOR,
denominator: DENOMINATOR);
// perform s-curve motion on moving axis
movingAxis.MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
// wait for motion to complete
movingAxis.MotionDoneWait();
// print results
Console.WriteLine($"Moving axis final position: {movingAxis.CommandPositionGet()}");
Console.WriteLine($"Follower axis final position: {followerAxis.CommandPositionGet()}");
Console.WriteLine($"Gear ratio: {NUMERATOR}:{DENOMINATOR}");
// disable gearing
followerAxis.GearingDisable();
// cleanup
Helpers.AbortMotionObject(followerAxis);
}
// handle errors as needed
finally
{
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
void GearingDisable()
Disable the electronic gearing.
void GearingEnable(int32_t masterAxisNumber, RSIAxisMasterType masterFeedbackSource, int32_t numerator, int32_t denominator)
Enable this Axis to be follower (slave) using electronic gearing.
void MoveSCurve(double position, double vel, double accel, double decel, double jerkPct)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5862
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.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
int32_t MotionDoneWait()
Waits for a move to complete.
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
int32_t NumberGet()
Get the axis number.
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.
Definition rsienums.h:1218