APIs, concepts, guides, and more

Basic template you can use to get up and running quick.

This application is designed to demonstrate simple Controller, Axis declaration. It can be a handy template for starting a RapidCode application or to try example code on you own system.

This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.

📜 Template

18using RSI.RapidCode.dotNET; // Import our RapidCode Library.
19using System;
21#if DOXYGEN // RSI internal documentation use only
22using RSI.RapidCode;
26class Template
27 {
28 static void Main(string[] args)
29 {
30 // Constants
31 const int AXIS_NUMBER = 0; // Specify which axis/motor to control.
32 const int ENCODER_RESOLUTION_BITS = 20; // The number of bits defining the encoder resolution
34 // Specify your counts per unit/user units. (the motor used in this sample app has 1048576 encoder pulses per revolution)
35 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
37 // Initialize RapidCode Objects
38 MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/);// Insert the path location of the RMP.rta (usually the RapidSetup folder)
39 HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialize correctly.
40 HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
41 //controller.AxisCountSet(1); // Uncomment if using Phantom Axes.
42 Axis axis = controller.AxisGet(AXIS_NUMBER); // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)
43 HelperFunctions.CheckErrors(axis); // [Helper Function] Check that the axis has been initialize correctly.
45 try
46 {
47 axis.UserUnitsSet(USER_UNITS); // Specify the counts per Unit.
48 axis.ErrorLimitTriggerValueSet(1); // Specify the position error limit trigger. (Learn more about this on our support page)
49 axis.PositionSet(0); // Make sure motor starts at position 0 everytime.
50 axis.ErrorLimitTriggerValueSet(1); // Set the position error trigger value
51 axis.Abort(); // If there is any motion happening, abort it.
52 axis.ClearFaults(); // Clear faults.
53 axis.AmpEnableSet(true); // Enable the motor.
55 Console.WriteLine("\nHello RMP");
61 }
62 catch (Exception e)
63 {
64 Console.WriteLine(e.Message); // If there are any exceptions/issues this will be printed out.
65 }
66 controller.Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
68 Console.WriteLine("\nPress Any Key To Exit"); // Allow time to read Console.
69 Console.ReadKey();
70 }
71 }
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Helper Functions for checking logged creation errors, starting the network, etc.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
void ErrorLimitTriggerValueSet(double triggerValue)
Set the Position Error Limit trigger value.
void PositionSet(double position)
Set the Command and Actual positions.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5513
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:794
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void Abort()
Abort an axis.