The RMP Motion Controller APIs
GearingCamming.cs
using NUnit.Framework;
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
[TestFixture]
[Category("Software")]
class GearingCamming : SampleAppTestBase
{
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void Camming()
{
//Create RapidCode Objects
Axis moving_axis = controller.AxisGet(Constants.MAIN_AXIS_NUMBER);
Axis follower_axis = controller.AxisGet(Constants.DRIVEN_AXIS_NUMBER);
HelperFunctions.CheckErrors(follower_axis);
// Constants
const double MAIN_VELOCITY = 50; // Specify your Moving Axis's velocity. - units: Units/Sec (it will do 1 counts / (1/104857) of a revolution every 1 second.)
const double MAIN_ACCELERATION = 20; // Specify your Moving Axis's acceleration. - units: Units/Sec^2
// Commanded Positions
double[] movingAxisDistances = { 5, 10, 8 }; // This is the RELATIVE Moving Axis distance, every n revolutions it changes its Driven position. (This is the x-axis)
double[] followerAxisPositions = { 10, 20, 10 }; // This is the final ABSOLUTE Driven position, for every 5 revolutions one of this positions gets applied. (This is the y-axis)
// Command motion on the Driven before the Moving Axis starts
follower_axis.MoveCamLinear(moving_axis.NumberGet(),
RSIAxisMasterType.RSIAxisMasterTypeAXIS_COMMAND_POSITION, // Use COMMAND for phantoms and ACTUAL for real axis.
movingAxisDistances,
followerAxisPositions,
movingAxisDistances.Length);
moving_axis.MoveVelocity(MAIN_VELOCITY, MAIN_ACCELERATION); // Command a constant velocity on the master axis, Driven will follow.
follower_axis.MotionDoneWait(); // Wait for the cam motion to complet
moving_axis.Stop(); // Stop the Moving Axis
Assert.AreEqual(followerAxisPositions[followerAxisPositions.Length - 1], follower_axis.CommandPositionGet());
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void Gearing()
{
//Create RapidCode Objects
Axis moving_axis = controller.AxisGet(Constants.MAIN_AXIS_NUMBER);
Axis follower_axis = controller.AxisGet(Constants.DRIVEN_AXIS_NUMBER);
HelperFunctions.CheckErrors(follower_axis);
int numerator = 2; // Specify the numerator of the gearing ratio.
int denominator = 1; // Specify the denominator of the gearing ratio.
// Configure the 'follower' axis to be a follow to the 'moving' axis at a ratio of 2:1, that is,
// for every rotation of the Moving Axis axis, the Driven axis will rotate twice.
follower_axis.GearingEnable(moving_axis,
RSIAxisMasterType.RSIAxisMasterTypeAXIS_COMMAND_POSITION, // If NOT using a Phantom Axis, switch to RSIAxisMasterTypeAXIS_ACTUAL_POSITION
numerator,
denominator);
// Perform a S-curve motion on the Moving Axis axis.
moving_axis.MoveSCurve(Constants.POSITION,
Constants.VELOCITY,
Constants.ACCELERATION,
Constants.DECELERATION,
Constants.JERK_PERCENT);
moving_axis.MotionDoneWait(); // Wait for motion to finish.
Assert.That(moving_axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION), "The command position should be equal to POSITION");
Assert.That(follower_axis.CommandPositionGet(), Is.EqualTo(Constants.POSITION * (numerator / denominator)), "The command position should be equal to twice POSITION");
}
}
RSI::RapidCode::RSIAxisMasterType
RSIAxisMasterType
Sources available to a slave Axis for electronic gearing & camming.
Definition: rsienums.h:1114
RSI::RapidCode
RSI
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
HelperFunctions
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50