APIs, concepts, guides, and more
io-sync-outputs.cs
Note
See IO: Input & Output 📜 for a detailed explanation of this sample code.
Warning
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.
/* This sample demonstrates how to set up Sync Outputs for streaming motion.
Shows how to configure outputs to trigger at specific motion element IDs during streaming motion,
allowing synchronized IO operations with motion control.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
using System.Threading;
Console.WriteLine("📜 IO: Sync Outputs");
// get rmp objects
Axis axis = controller.AxisGet(Constants.AXIS_0_INDEX);
try
{
Helpers.CheckErrors(controller);
Helpers.CheckErrors(axis);
// ready axis
Helpers.PhantomAxisReset(axis);
const int TOTAL_POINTS = 4; // total number of points
const int EMPTY_CT = -1; // number of points that remains in buffer before e-stop
const int OUTPUT_INDEX = 0; // digital output index that will be controlled
const int NODE_INDEX = 0; // the EtherCAT Node index
double[] positions = [1.0, 2.0, 3.0, 4.0]; // streaming motion positions
double[] times = [0.5, 0.1, 0.2, 0.4]; // streaming motion times
int outputEnableID = 2; // motion element ID at which to set output HIGH
int outputDisableID = 3; // motion element ID at which to set output LOW
// create IOPoint for digital output
IOPoint output0 = IOPoint.CreateDigitalOutput(controller.NetworkNodeGet(NODE_INDEX), OUTPUT_INDEX);
output0.Set(false); // set output low initially
// enable streaming/sync outputs
// configure sync outputs - turn output HIGH at motion element 2, LOW at motion element 3
axis.StreamingOutputAdd(output0, true, outputEnableID); // turn output HIGH at element ID 2
axis.StreamingOutputAdd(output0, false, outputDisableID); // turn output LOW at element ID 3
Console.WriteLine($"Starting streaming motion with {TOTAL_POINTS} points");
Console.WriteLine($"Output will go HIGH at element ID {outputEnableID}");
Console.WriteLine($"Output will go LOW at element ID {outputDisableID}");
// start streaming motion
axis.MovePT(RSIMotionType.RSIMotionTypePT, positions, times, TOTAL_POINTS, EMPTY_CT, false, true);
// monitor motion and output state
while (!axis.MotionDoneGet())
{
int currentElement = axis.MotionIdExecutingGet();
bool outputState = output0.Get();
Console.WriteLine($"Motion Element: {currentElement}, Output State: {outputState}");
Thread.Sleep(50); // small delay to avoid overwhelming console
}
// cleanup
Helpers.AbortMotionObject(axis);
}
// handle errors as needed
finally
{
axis.StreamingOutputsEnableSet(false); // restore
controller.Delete(); // dispose
}
Constants used in the C# sample apps.
Definition _constants.cs:3
const int AXIS_0_INDEX
Default: 0.
Definition _constants.cs:11
uint16_t MotionIdExecutingGet()
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Definition rsi.h:5863
void Set(bool state)
Set the state of a Digital Output.
static IOPoint * CreateDigitalOutput(Axis *axis, RSIMotorDedicatedOut motorDedicatedOutNumber)
Create a Digital Output from an Axis' Dedicated Output bits.
bool Get()
Get the state of Digital Input or Output.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
Definition rsi.h:11550
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
void StreamingOutputAdd(int32_t onMask, int32_t offMask, uint64_t address)
void StreamingOutputsEnableSet(bool enable)
Sets whether Streaming Output is enabled (true) or disabled (false).
void MovePT(RSIMotionType type, const double *const position, const double *const time, int32_t pointCount, int32_t emptyCount, bool retain, bool final)
A move commanded by a list of position and time points.
bool MotionDoneGet()
Check to see if motion is done and settled.
RSIMotionType
PT and PVT streaming motion types.
Definition rsienums.h:1039
Helpers namespace provides utility functions for common tasks in RMP applications.
Definition helpers.h:21