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.
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.
MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
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.
MoveRelative(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
axis.
MoveRelative(-POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT);
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.
MoveSCurve(POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PERCENT, FINAL_VELOCITY);
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.
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)
using System.Threading;
Console.WriteLine("📜 Axis Motion: Velocity via Analog Input");
const double ACCELERATION = 100;
const double MAX_VEL = 10;
const double MAX_ANALOG = 65536;
const int RUN_TIME_SECONDS = 20;
try
{
{
Console.WriteLine("Network not started. Please start it before running this app.");
return;
}
Axis axis = controller.
AxisGet(Constants.AXIS_1_INDEX);
Console.WriteLine($"Max Speed = {MAX_VEL}");
Console.WriteLine($"Running for {RUN_TIME_SECONDS} seconds...\n");
var startTime = DateTime.Now;
while ((DateTime.Now - startTime).TotalSeconds < RUN_TIME_SECONDS)
{
double analogValue = node.AnalogInGet(analogChannel: 0);
double normalizedValue = analogValue / MAX_ANALOG;
double velocity = normalizedValue * MAX_VEL;
Thread.Sleep(1);
}
}
finally
{
}
static void AbortMotionObject(RapidCodeMotion motionObject)
Aborts motion on the given RapidCodeMotion object (Axis or MultiAxis), waits for motion to stop,...
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void PhantomAxisReset(Axis phantomAxis)
Configures a phantom axis on the controller.
Helpers class provides static methods for common tasks in RMP applications.
void MoveVelocity(double velocity)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
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...
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
RSINetworkState
State of network.