 RapidCode 10.3.2 The RMP Motion Controller API
Motion.cs
Precondition
This is a sample assumes you already have a RapidCode MotionController and Axis Object. See the Template.cs or HelperFunctions.cs sample app to see how to set up those objects.
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.
Constants
public const double POSITION = 2; // Specify the position to travel to.
public const double VELOCITY = 200; // Specify your velocity. - units: UserUnits/Sec
public const double ACCELERATION = 100; // Specify your acceleration. - units: UserUnits/Sec^2
public const double DECELERATION = 100; // Specify your deceleration. - units: UserUnits/Sec^2
public const double JERK_PERCENT = 50; // Specify your jerk percent (0.0 to 100.0)
AbsoluteMotion
This sample code moves a single axis in trapezoidal profile to an absolute distance set by CONSTANTS.POSITION below. Trapezoidal motion accelerates each axis at the given rate until it reaches the specified velocity. When each axis approaches the specified location, it decelerates at the given rate to a stop. All accelerations and decelerations are constant,
axis.MoveTrapezoidal(Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION);// Command simple trapezoidal motion.
axis.MotionDoneWait();// Wait for motion to be done
//---TEST ASSERT---
Assert.That(axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");

SCurveMotion
This sample code moves a single axis in an SCurve profile to an absolute position.

axis.MoveSCurve(Constants.POSITION); // Command SCurve Motion. This overload willuse default velocity, acceleration, deceleration, jerk values for the axis. See axis config to learn how to set those values.
axis.MotionDoneWait(); // Wait for motion to finish
//---TEST ASSERT---
Assert.That(axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");

RelativeMotion
This sample code moves a single axis relative to its current position.

// Command a relative to the current position
axis.MoveRelative(Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT); // Command a relative to the current position
axis.MotionDoneWait(); // Wait for motion to finish. (the motion should take 2.5 seconds)
//---TEST ASSERT---
Assert.That(axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");
// Move back to the start position by moving negative relative to current position
axis.MoveRelative(-1 * Constants.POSITION, Constants.VELOCITY, Constants.ACCELERATION, Constants.DECELERATION, Constants.JERK_PERCENT);
axis.MotionDoneWait();

FinalVelocity
This sample code moves a single axis. Once the motion is complete the axis continues spinning at a specified velocity.

//Constants
int FINAL_VELOCITY = 5;
//---COMMAND MOTION---
axis.MoveSCurve(Constants.POSITION, // Command an SCurve move with a final velocity of FINAL_VELOCITY.
Constants.VELOCITY,
Constants.ACCELERATION,
Constants.DECELERATION,
Constants.JERK_PERCENT,
FINAL_VELOCITY);// Once the commanded position has been reached, the motor will begin spinning with a speed of FINAL_VELOCITY, and continue to spin at that velocity until stopped.

MoveVelocity