Point to point multi-axis motion sample application.
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.
- Precondition
- This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
- Warning
- This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires.
- Copyright
- Copyright © 1998-2019 by Robotic Systems Integration, Inc. All rights reserved. This software contains proprietary and confidential information of Robotic Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth in the license agreement under which this software is supplied, disclosure, reproduction, or use with controls other than those provided by RSI or suppliers for RSI is strictly prohibited without the prior express written consent of Robotic Systems Integration.
using RSI.RapidCode.dotNET;
using RSI.RapidCode.dotNET.Enums;
using System;
{
class PointToPointMultiaxisMotion
{
static void Main(string[] args)
{
const int X_AXIS = 0;
const int Y_AXIS = 1;
const int NUM_OF_AXES = 2;
const int USER_UNITS = 1048576;
double[] positions1 = new double[2] { 100, 200 };
double[] positions2 = new double[2] { 300, 300 };
double[] velocities1 = new double[2] { 5, 10 };
double[] velocities2 = new double[2] { 10, 5 };
double[] accelerations = new double[2] { 10, 10 };
double[] decelerations = new double[2] { 10, 10 };
double[] jerkPercent = new double[2] { 50, 50 };
try
{
Console.WriteLine("MultiAxis Point-to-Point Motion Example\n");
Console.WriteLine("\nBegin SCurve Motion\n");
multi.
MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent);
Console.WriteLine("\nSCurve Motion Complete\n");
Console.WriteLine("\nBegin Trapezoidal Motion\n");
multi.
MoveTrapezoidal(positions2, velocities2, accelerations, decelerations);
Console.WriteLine("\nTrapezoidal Motion Complete\n");
Console.WriteLine("\nTest Complete\n");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("\nPress Any Key To Exit");
Console.ReadKey();
}
}
}