The RMP Motion Controller APIs
Helper Functions

This class includes the source code of all our SampleAppsCS helper functions. More...

Helper functions were created to reduce code. Please note that if you would like to use this classes on your personal project you will have to replicate this class.

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.

📜 Check Errors
Check the RSIError log for any logged errors. Read and print all the errors. Ignore warnings.

public static void CheckErrors(RapidCodeObject rsiObject)
bool hasErrors = false;
System.Text.StringBuilder errorStringBuilder = new System.Text.StringBuilder();
while (rsiObject.ErrorLogCountGet() > 0)
RsiError error = rsiObject.ErrorLogGet();
if (error.isWarning)
errorStringBuilder.AppendLine("WARNING: " + error.Message);
hasErrors = true;
errorStringBuilder.AppendLine("ERROR: " + error.Message);
if (errorStringBuilder.Length > 0)
if (hasErrors)
throw new Exception(errorStringBuilder.ToString());

📜 Start the Network
Start the network and print any errors encountered.

public static void StartTheNetwork(MotionController controller)
// Initialize the Network
if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL) // Check if network is started already.
Console.WriteLine("Starting Network..");
controller.NetworkStart(); // If not. Initialize The Network. (This can also be done from RapidSetup Tool)
if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL) // Check if network is started again.
int messagesToRead = controller.NetworkLogMessageCountGet(); // Some kind of error starting the network, read the network log messages
for (int i = 0; i < messagesToRead; i++)
Console.WriteLine(controller.NetworkLogMessageGet(i)); // Print all the messages to help figure out the problem
Console.WriteLine("Expected OPERATIONAL state but the network did not get there.");
//throw new RsiError(); // Uncomment if you want your application to exit when the network isn't operational. (Comment when using phantom axis)
else // Else, of network is operational.
Console.WriteLine("Network Started");

📜 Create and Ready Axis

public Axis CreateAndReadyAxis(int AxisNumber)
Axis axis = controller.AxisGet(AxisNumber); // 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.
return axis;

📜 Reset Axis

public void ResetAxis(Axis myAxis)
myAxis.UserUnitsSet(Constants.USER_UNITS); // Specify the counts per Unit.
myAxis.PositionSet(0); // Sets the current position as 0 effectively 'homing' it.
myAxis.Abort(); // If there is any motion happening, abort it (creates a fault).

📜 Enable Axis Amp

public void EnableAmp(Axis myAxis)
myAxis.ClearFaults(); // To enable after an abort faults must be cleared.
myAxis.AmpEnableSet(true); // Enable the motor.
State of network.
Definition: rsienums.h:557
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50