APIs, concepts, guides, and more

◆ MultiAxisGet()

MultiAxis * MultiAxisGet ( int32_t motionSupervisorNumber)
Description:

MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.

Parameters
motionSupervisorNumberA motion supervisor index, should be >= AxisCount.
Returns
(MultiAxis*) A pointer to the MultiAxis specified.
Sample Code:
Motion: Multi-Axis
// Constants
const int NUM_OF_AXES = 2; // Specify the number of axes (Make sure your axis count in RapidSetup is 2!)
// Parameters
double[] positions1 = new double[NUM_OF_AXES] { 5, 10 }; // The first set of positions to be moved to
double[] positions2 = new double[NUM_OF_AXES] { 15, 15 }; // The second set of positions to be moved to
double[] velocities1 = new double[NUM_OF_AXES] { 1000, 1000 }; // The velocity for the two axes for the first move- Units: units/sec (driver will execute 10 rotations per second)
double[] velocities2 = new double[NUM_OF_AXES] { 1000, 1000 }; // The velocity for the two axes for the second move
double[] accelerations = new double[NUM_OF_AXES] { 500, 500 }; // The acceleration for the two axes
double[] decelerations = new double[NUM_OF_AXES] { 500, 500 }; // The deceleration for the two axes
double[] jerkPercent = new double[NUM_OF_AXES] { 50, 50 }; // The jerk percent for the two axes
controller.AxisCountSet(NUM_OF_AXES);
controller.MotionCountSet(NUM_OF_AXES + 1);
Axis axis0 = controller.AxisGet(Constants.X_AXIS_NUMBER); // Initialize axis0
Axis axis1 = controller.AxisGet(Constants.Y_AXIS_NUMBER); // Initialize axis1
HelperFunctions.CheckErrors(axis0); // [Helper Function] Check that 'axis0' has been initialized correctly
HelperFunctions.CheckErrors(axis1); // [Helper Function] Check that 'axis1' has been initialized correctly
// In this application, we have two Axis objects and one MultiAxis object, so three motion supervisors are required
MultiAxis multi = controller.MultiAxisGet(NUM_OF_AXES); // Initialize a new MultiAxis object. MultiAxisGet takes a motion supervisor number as its argument.
// This number is equal to the number of axes since motion supervisors are zero indexed (i.e., motion supervisors
// 0 and 1 are used for axis0 and axis1, so motion supervisor 2 is available for our MultiAxis object).
HelperFunctions.CheckErrors(multi); // [Helper Function] Check that 'multi' has been initialized correctly
controller.AxisCountSet(NUM_OF_AXES); // Set the number of axis being used. A phantom axis will be created if for any axis not on the network. You may need to refresh rapid setup to see the phantom axis.
multi.AxisRemoveAll(); // Remove all current axis if any. So we can add new ones
multi.AxisAdd(axis0); // Add axis0 to the MultiAxis object
multi.AxisAdd(axis1); // Add axis1 to the MultiAxis object
multi.Abort(); // If there is any motion happening, abort it
multi.ClearFaults(); // Clear any faults
multi.AmpEnableSet(true); // Enable the motor
axis0.ErrorLimitActionSet(RSIAction.RSIActionNONE); // Disable poistion error for Phantom Axes.
axis1.ErrorLimitActionSet(RSIAction.RSIActionNONE); // Disable poistion error for Phantom Axes.
multi.MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent); // Move to the positions specified in positions1 using a trapezoidal motion profile
multi.MotionDoneWait(); // Wait for motion to finish
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); // Move to the positions specified in positions2 using a SCurve motion profile
multi.MotionDoneWait(); // Wait for the motion to finish
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");
multi.AmpEnableSet(false); // Disable the axes
Note
You'll need to set the number of MotionSupervisors to a number greater than the Axis count. This should be done before any calls to AxisGet or MultiAxisGet.

Part of the Create and Initialize RapidCode Objects method group.

Note
Important usage instructions for all RapidCode creation methods: All creation methods, such as and Create(), AxisGet(), NetworkNodeGet(), etc. Each return valid pointers to RapidCode objects. These pointers are never null, even when there is an error during object creation.
Error Checking After Creation
Immediately after the creation of a RapidCode object, you need to check if there were any errors during its creation. You do this by calling the ErrorLogCountGet() method on the created object. If ErrorLogCountGet() returns a value greater than zero, it means there were errors during the object creation.
Handling Errors
To handle the errors, you call the ErrorLogGet() method once for each error on the created object to retrieve an RsiError object. You can then inspect the RsiError object to understand more about the error.
Helper Functions
RapidCode also provides helper functions in both C++ and C#, like HelperFunctions::CheckErrors(), that work with all RapidCode objects. These helper functions operate on RapidCodeObject, hence they are compatible with all RapidCode objects. For example:
Notes on creation methods with the C# API (vs. C++)
In the C# API, the pointers are replaced by references due to differences between C++ and C#. The creation methods return a reference to the object instead of a pointer. However, the method calls and error handling procedures remain the same. Null references are not returned by the creation methods in C#. Always check for errors after object creation, as described above.
Note
Object Cleanup Any and all objects created by RapidCode creation methods will be cleaned up by calling MotionController::Delete(). This should be done with your application is finished using RapidCode objects.
See also
ErrorLogCountGet , ErrorLogGet , Delete , HelperFunctions.CheckErrors
MultiAxis::AxisAdd , MotionCountGet , MotionCountSet
Examples
DifferenceOfPositionUserLimit.cpp, HelperFunctions.cs, MathBlock.cs, MultiAxisMotion.cs, MultiaxisMotion.cpp, PVTmotionMultiAxis.cpp, PathMotion.cpp, SyncOutputWithMotion.cpp, Template.cpp, and UpdateBufferPoints.cpp.