Multi-Axis motion sample applications.
- 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.
📜 Multi-Axis Point-to-Point Motion
We have created several arrays below. These represent the positions and velocities for the two movements we will perform, as well as the accelerations and decelerations for these movements (these two arrays are common across the two movements). We will demonstrate both types of point to point motion: SCurve and Trapezoidal.
Note: MoveSCurve requires an additional argument, jerkPercent. This array is also created below, but is only used with the MoveSCurve command, not the MoveTrapezoidal command.
const int NUM_OF_AXES = 2;
double[] positions1 = new double[NUM_OF_AXES] { 5, 10 };
double[] positions2 = new double[NUM_OF_AXES] { 15, 15 };
double[] velocities1 = new double[NUM_OF_AXES] { 1000, 1000 };
double[] velocities2 = new double[NUM_OF_AXES] { 1000, 1000 };
double[] accelerations = new double[NUM_OF_AXES] { 500, 500 };
double[] decelerations = new double[NUM_OF_AXES] { 500, 500 };
double[] jerkPercent = new double[NUM_OF_AXES] { 50, 50 };
Axis axis0 = controller.
AxisGet(Constants.X_AXIS_NUMBER);
Axis axis1 = controller.
AxisGet(Constants.Y_AXIS_NUMBER);
multi.
MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent);
Assert.That(axis0.
CommandPositionGet(), Is.EqualTo(positions1[0]),
"The first axis in the multi axis object should be commanded to move to the firt element of the array");
Assert.That(axis1.
CommandPositionGet(), Is.EqualTo(positions1[1]),
"The second axis in the multi axis object should be commanded to move to the second element of the array");
multi.
MoveTrapezoidal(positions2, velocities2, accelerations, decelerations);
Assert.That(axis0.
CommandPositionGet(), Is.EqualTo(positions2[0]),
"The first axis in the multi axis object should be commanded to move to the firt element of the array");
Assert.That(axis1.
CommandPositionGet(), Is.EqualTo(positions2[1]),
"The second axis in the multi axis object should be commanded to move to the second element of the array");
Learn more in the concept page.
📜 Multi-Axis Velocity Motion
This sample application updates a multi-axis velocity synchronously and on the fly. It can update velocities at a rate of ~2ms.
Before runninng this sample app:
1. Make sure to configure your Multi-Axis on RapidSetup.
2. Make sure to adjust your Limits and Action for all axes.
const int cycles = 2;
const int NUM_OF_AXES = 6;
int i;
double[] accelerations = new double[6] { 1000, 1000, 1000, 1000, 1000, 1000 };
double[] velocities = new double[6];
Random rnd = new Random();
Axis x_axis = controller.
AxisGet(Constants.X_AXIS_NUMBER);
Axis y_axis = controller.
AxisGet(Constants.Y_AXIS_NUMBER);
Axis z_axis = controller.
AxisGet(Constants.Z_AXIS_NUMBER);
Axis a_axis = controller.
AxisGet(Constants.A_AXIS_NUMBER);
Axis b_axis = controller.
AxisGet(Constants.B_AXIS_NUMBER);
Axis c_axis = controller.
AxisGet(Constants.C_AXIS_NUMBER);
for (i = 0; i < cycles; i++)
{
int random_vel1 = rnd.Next(1, 100);
int random_vel2 = rnd.Next(1, 100);
int random_vel3 = rnd.Next(1, 100);
int random_vel4 = rnd.Next(1, 100);
int random_vel5 = rnd.Next(1, 100);
int random_vel6 = rnd.Next(1, 100);
velocities = new double[6] {random_vel1,
random_vel2,
random_vel3,
random_vel4,
random_vel5,
random_vel6 };
System.Threading.Thread.Sleep(100);
}
Learn more in the concept page.