The RMP Motion Controller APIs
Template.cs
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
using System;
class Template
{
static void Main(string[] args)
{
// Constants
const int AXIS_NUMBER = 0; // Specify which axis/motor to control.
const int ENCODER_RESOLUTION_BITS = 20; // The number of bits defining the encoder resolution
// Specify your counts per unit/user units. (the motor used in this sample app has 1048576 encoder pulses per revolution)
double USER_UNITS = Math.Pow(2, ENCODER_RESOLUTION_BITS); //1048576 Setting the user units to this value will result in a commaneded position of 1 spinning the motor 1 full revolution
// Initialize RapidCode Objects
MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/);// Insert the path location of the RMP.rta (usually the RapidSetup folder)
HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialize correctly.
HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
//controller.AxisCountSet(1); // Uncomment if using Phantom Axes.
Axis axis = controller.AxisGet(AXIS_NUMBER); // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)
HelperFunctions.CheckErrors(axis); // [Helper Function] Check that the axis has been initialize correctly.
try
{
axis.UserUnitsSet(USER_UNITS); // Specify the counts per Unit.
axis.ErrorLimitTriggerValueSet(1); // Specify the position error limit trigger. (Learn more about this on our support page)
axis.PositionSet(0); // Make sure motor starts at position 0 everytime.
axis.ErrorLimitTriggerValueSet(1); // Set the position error trigger value
axis.Abort(); // If there is any motion happening, abort it.
axis.ClearFaults(); // Clear faults.
axis.AmpEnableSet(true); // Enable the motor.
Console.WriteLine("\nHello RMP");
//-----INSERT YOUR SAMPLE CODE HERE-----
//-----INSERT YOUR SAMPLE CODE HERE-----
}
catch (Exception e)
{
Console.WriteLine(e.Message); // If there are any exceptions/issues this will be printed out.
}
controller.Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
Console.WriteLine("\nPress Any Key To Exit"); // Allow time to read Console.
Console.ReadKey();
}
}
RSI::RapidCode
RSI
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
HelperFunctions.StartTheNetwork
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Definition: HelperFunctions.cs:109
HelperFunctions
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50