|
APIs, concepts, guides, and more
|
Learn RapidCode C# with these sample applications.
These C# examples, located in the examples/ folder under your RMP install directory (e.g., C:/RSI/X.X.X/examples/ or /rsi/examples/), show how to control the RMP EtherCAT motion controller with the RapidCode API. Use these projects to explore API features, validate configurations, and jumpβstart your own apps.
These sample applications are provided to help you integrate the RMP motion controller into your own projects. They are not production-ready and may lack critical logic or safety mechanisms required for your specific application.
If you are working with real hardware, we strongly recommend wiring an external hardware emergency stop (e-stop) button. This safeguard is essential to protect both people and equipment, reducing the risk of injury or damage when using these sample applications.
Verify that it is correctly installed by running
| General | |
|---|---|
| _constants.cs | Common configuration file for all sample apps (RMP path, default axis index, etc) |
| _helpers.cs | Helper functions and utilities used across sample applications |
| _setup.cs | Gets your controller/system ready for sample apps. (create controller, setup axis, etc) |
| _config.cs | Helper functions for _setup.cs, including one you must implement (see Run with Hardware) |
| Directory.Build.targets | MSBuild configuration that references RapidCode .NET dll and manages build settings |
Use settings specific to your machine and hardware
| Constant | Windows | Linux | Description |
|---|---|---|---|
| RMP_WINDOWS_PATH | βοΈ | RMP installation path. Default is C:\RSI\X.X.X for Windows | |
| RMP_LINUX_PATH | βοΈ | RMP installation path. Default is /rsi for Linux | |
| RMP_NODE_NAME | βοΈ | INtime node name (usually NodeA) | |
| RMP_NIC_PRIMARY | βοΈ | The name of the primary network card used by RMP (only required for physical axes) | |
| RMP_CPU_AFFINITY | βοΈ | Isolated CPU core you want to use. Find it with cat /sys/devices/system/cpu/isolated | |
| USE_HARDWARE | βοΈ | βοΈ | Start with false to test your sample app with phantom axes. When you're ready to use physical motors, see the "Run with Hardware" section below |
| AXIS_COUNT | βοΈ | βοΈ | The number of axes connected to your system (see below). |
| MULTIAXIS_COUNT | βοΈ | βοΈ | The number of MultiAxis objects you want to use with your sample apps. This must be at least 1 to run the MultiAxis samples |
AXIS_COUNT Note: The sample apps will only ever use a maximum of 6 axes. If you are using hardware, you should always set AXIS_COUNT to the number of axes connected to your system, and extra axes will be ignored. If you are using phantom, you can leave this at 6 and RMP will simulate enough axes for all sample apps.
You must set these for values of i from 0 to AXIS_COUNT - 1 (or set all of them if AXIS_COUNT >= 6)
| Constant | Windows | Linux | Description |
|---|---|---|---|
| AXIS_i_INDEX | βοΈ | βοΈ | Change which axes will be used by the sample apps. See the comment in _constants.cs for details |
| AXIS_i_USER_UNITS | βοΈ | βοΈ | The User Units for the i'th axis in your program. See Concepts > Configuration > Counts Per Unit in the documentation for more info |
If you want to explore more advanced features or are having trouble, look at these additional constants
| Constant | Windows | Linux | Description |
|---|---|---|---|
| AMP_ENABLE_MS | βοΈ | βοΈ | How many ms to wait for AmpEnableSet. You can increase this up to 1000ms if you are encountering amp faults. |
| RAPIDSERVER_IP | βοΈ | βοΈ | The "server ip" displayed when starting your rapidserver |
| RAPIDSERVER_PORT | βοΈ | βοΈ | The "grpc port" displayed when starting your rapidserver |
Navigate to the sample apps folder
where X.X.X is your RMP version.
For example:
Clean existing builds
Run _setup.cs
Note: Repeat this step after any changes to _constants.cs
Run a sample app
For example:
Warning: Unless you call MotionController::Shutdown(), the RMP firmware will continue your run after your sample app finishes. This can also happen if you started it through RapidSetup or RapidSetupX. If you believe this is causing issues with your execution, re-run _setup.cs as above, or manually end the RMP firmware process (i.e., shutdown the controller in RapidSetupX or RapidSetup) before running your sample app again.
If you wish to debug the sample apps with breakpoints and step-through debugging:
Note: For more info on configuring hardware axes, see the axis-config sample apps and our Concepts > Configuration documentation