The RMP Motion Controller APIs
Template.cs
1
18using RSI.RapidCode.dotNET; // Import our RapidCode Library.
19using System;
20
21#if DOXYGEN // RSI internal documentation use only
22using RSI.RapidCode;
23#endif
24
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
33
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
36
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.
44
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.
54
55 Console.WriteLine("\nHello RMP");
56
57 //-----INSERT YOUR SAMPLE CODE HERE-----
58
59
60 //-----INSERT YOUR SAMPLE CODE HERE-----
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.
67
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:5664
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:762
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void Abort()
Abort an axis.