APIs, concepts, guides, and more
Motion: Point-to-Point

Learn how to use point-to-point motion commands 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:


📜 Absolute Motion

Learn how to move a single axis in Absolute Motion 📖 profile. Absolute motion accelerates at a constant rate until reaching the specified velocity, then decelerates at a constant rate when approaching the target position.

axis.AmpEnableSet(true);
axis.MoveTrapezoidal(POSITION, VELOCITY, ACCELERATION, DECELERATION);
axis.MotionDoneWait(); // wait for motion to complete

Source: axis-motion-point-to-point.cs


📜 S-Curve Motion

Learn how to move a single axis in an S-Curve Motion 📖 profile. S-curve motion provides smoother acceleration and deceleration with controlled jerk.

axis.AmpEnableSet(true);
axis.MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete

Source: axis-motion-point-to-point.cs


📜 Relative Motion

Learn how to move a single axis Relative Motion 📖 to its current position. Shows moving forward and then back using negative relative distance.

axis.AmpEnableSet(true);
axis.MoveRelative(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete
// move back to start using negative relative motion
axis.MoveRelative(-POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.MotionDoneWait(); // wait for motion to complete

Source: axis-motion-point-to-point.cs


📜 Final Velocity Motion

Learn how to command motion with a Final Velocity Motion 📖 . Once the position is reached, the axis continues spinning at the specified final velocity.

axis.AmpEnableSet(true);
axis.MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, FINAL_VELOCITY); // axis continues at final velocity after reaching position
// wait until axis transitions to final velocity
while (axis.StatusBitGet(RSIEventType.RSIEventTypeMOTION_AT_VELOCITY) == false)
Thread.Sleep(100);

Source: axis-motion-point-to-point.cs


📜 Velocity Motion

Learn how to move a single axis at a specified Velocity Motion 📖 . The axis accelerates to the velocity and continues until explicitly stopped.

axis.AmpEnableSet(true);
axis.MoveVelocity(VELOCITY, ACCELERATION); // move at constant velocity

Source: axis-motion-point-to-point.cs


📜 Velocity Motion via Analog Input

This sample app was created using the EL3002 Analog Input module. Please note that some variable values might changed based on your analog input module. The functionality used with many other Analog Input modules, not only Beckhoff's.
Learn more about the EL3XXX analog input modules from beckhoff. (https://www.beckhoff.com/english/ethercat/analog.htm)

/* This sample demonstrates how to control axis velocity dynamically using an analog input value.
The analog input value (0 to 65536 for a 16-bit input) is mapped to a velocity range.
This was created using the EL3002 Analog Input module but works with many other modules.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
using System.Threading;
Console.WriteLine("📜 Axis Motion: Velocity via Analog Input");
// set sample config params
const double ACCELERATION = 100;
const double MAX_VEL = 10;
const double MAX_ANALOG = 65536; // 16-bit analog input
const int RUN_TIME_SECONDS = 20; // how long to run the velocity control loop
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// check is network is started
if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL)
{
Console.WriteLine("Network not started. Please start it before running this app.");
return;
}
// get phantom axis
Axis axis = controller.AxisGet(Constants.AXIS_1_INDEX);
// get node
var node = controller.NetworkNodeGet(nodeNumber: 0);
// configure axis
axis.AmpEnableSet(true);
// print sample info
Console.WriteLine($"Max Speed = {MAX_VEL}");
Console.WriteLine($"Running for {RUN_TIME_SECONDS} seconds...\n");
// control velocity based on analog input
var startTime = DateTime.Now;
while ((DateTime.Now - startTime).TotalSeconds < RUN_TIME_SECONDS)
{
// get analog input value and normalize to 0.0 - 1.0
double analogValue = node.AnalogInGet(analogChannel: 0);
double normalizedValue = analogValue / MAX_ANALOG;
/*
┌────────────────────────────────────────────────────┐
│ Analog Input Value Maps Linearly to Velocity │
│ │
│ Analog: 0 ............................ 65,536 │
│ Velocity: 0 ............................ MAX_VEL │
└────────────────────────────────────────────────────┘
*/
// map analog input linearly to velocity (0 to MAX_VEL)
double velocity = normalizedValue * MAX_VEL;
axis.MoveVelocity(velocity, ACCELERATION);
Thread.Sleep(1); // prevent cpu spin
}
// cleanup
}
// 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 MoveVelocity(double velocity)
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.
NetworkNode * NetworkNodeGet(int32_t nodeNumber)
NetworkNodeGet returns a pointer to a RapidCodeNetworkNode object using its node number and initializ...
RSINetworkState NetworkStateGet()
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 AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
RSINetworkState
State of network.
Definition rsienums.h:568