Appending MovePVT
/* Copyright(c) 1998-2009 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. 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. This sample applications demonstrates how PVT motion list can be appended while the controller is still in the process of executing PVT points. This is usful for users that want to either extend or cancel a PVT move depending on results of first PVT points that were passed on. For any questions regarding this sample code please visit www.roboticsys.com. ================================================================================== */ using System; using System.Collections.Generic; using System.Text; using NUnit.Framework; using RSI.RapidCode.SynqNet.dotNET; using RSI.RapidCode.SynqNet.dotNET.Enums; namespace SampleApplications { [TestFixture] public class PVT_Append { const int AXIS_X = 0; const int AXIS_Y = 1; const int CONTROLLER = 1; const int POINTS = 5; const int AXES = 2; [Test] public void Main() { try { //Create RapidCode objects MotionController controller; Axis axisX; Axis axisY; MultiAxis multiAxis; double[] pos = new double[POINTS * AXES]; double[] t = new double[POINTS]; double[] v = new double[POINTS * AXES]; double[] pos1 = new double[POINTS * AXES]; double[] t1 = new double[POINTS]; double[] v1 = new double[POINTS * AXES]; //Initialize controller object controller = MotionController.CreateFromBoard(CONTROLLER); //Initialize axis objects axisX = controller.AxisGet(AXIS_X); axisY = controller.AxisGet(AXIS_Y); //Initialize Multiaxis Objects multiAxis = controller.MultiAxisGet(axisX); multiAxis.AxisAdd(axisY); //Set Position to 0 axisX.PositionSet(0); axisY.PositionSet(0); //Clear faults and Enable MultiAxis group multiAxis.Abort(); multiAxis.ClearFaults(); multiAxis.AmpEnableSet(true); //Position points for FIRST MovePVT pos[0] = 500; pos[1] = 500; pos[2] = 1000; pos[3] = 1000; pos[4] = 1500; pos[5] = 1500; pos[6] = 2000; pos[7] = 2000; pos[8] = 2500; pos[9] = 2500; //Velocity points for SECOND MovePVT v[0] = 1000; v[1] = 1000; v[2] = 1000; v[3] = 1000; v[4] = 1000; v[5] = 1000; v[6] = 1000; v[7] = 1000; v[8] = 0; v[9] = 0; //Time points for FIRST MovePVT t[0] = 1; t[1] = 0.5; t[2] = 0.5; t[3] = 0.5; t[4] = 1; //Position points for SECOND MovePVT pos1[0] = 3000; pos1[1] = 3000; pos1[2] = 3500; pos1[3] = 3500; pos1[4] = 4000; pos1[5] = 4000; pos1[6] = 4500; pos1[7] = 4500; pos1[8] = 5000; pos1[9] = 5000; //Velocity points for SECOND MovePVT v1[0] = 1000; v1[1] = 1000; v1[2] = 1000; v1[3] = 1000; v1[4] = 1000; v1[5] = 1000; v1[6] = 1000; v1[7] = 1000; v1[8] = 0; v1[9] = 0; //Time points for SECOND MovePVT t1[0] = 1; t1[1] = 0.5; t1[2] = 0.5; t1[3] = 0.5; t1[4] = 1; // Initiate PVT motion. By setting last parameter (final) = FALSE, we are telling the controller // to expect another round of points to be loaded in controller. multiAxis.MovePVT(pos, v, t, POINTS, -1, false, false); // This is added to poll until several points from first MovePVT have been executed before // calling a second MovePVT to complete the motion profile while (axisX.CommandPositionGet() < 2000) { } // Initiate PVT motion. This time around, last parameter (final) = TRUE. This will be the // last time we call MovePVT. Once all point are executed, motion done event will be generated multiAxis.MovePVT(pos1, v1, t1, POINTS, -1, false, true); Console.WriteLine("MovePVT appended with additional points"); //While loop to wait for completion of PVT motion multiAxis.MotionDoneWait(); Console.WriteLine("PVT Motion Complete"); } catch (RsiError err) { Console.WriteLine(err.text); } } } }