APIs, concepts, guides, and more
Motion: Gearing

Learn how to configure Gearing coordinated motion between axes in C#.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


In this page:


📜 Gearing Motion

Learn how to configure electronic Gearing 📖 between two axes. The follower axis follows the moving axis at a specified gear ratio (numerator/denominator). Shows how to set up a 2:1 gear ratio where the follower rotates twice for each rotation of the moving axis.

/* 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(movingAxis);
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);
Helpers.AbortMotionObject(movingAxis);
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
Definition _constants.cs:3
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:11
const int AXIS_1_INDEX
Default: 1.
Definition _constants.cs:12
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: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
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
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21