The RMP Motion Controller APIs
IO: Input & Output

Learn how to use IO. More...

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.


πŸ“œ Dedicated IO
This application demonstrates how to access Dedicated IO.

// Retrieve dedicated inputs with generic and specific function.
Console.WriteLine("RSIMotorDedicatedInLIMIT_HW_NEG: {0} and {1}",
axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_NEG),
axis.NegativeLimitGet());
Console.WriteLine("RSIMotorDedicatedInLIMIT_HW_POS: {0} and {1}",
axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_POS),
axis.PositiveLimitGet());
Console.WriteLine("RSIMotorDedicatedInHOME: {0} and {1}",
axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInHOME),
axis.HomeSwitchGet());
Console.WriteLine("RSIMotorDedicatedInAMP_FAULT: {0} and {1}",
axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInAMP_FAULT),
axis.AmpFaultGet());
Console.WriteLine("RSIMotorDedicatedInAMP_ACTIVE: {0} and {1}",
axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInAMP_ACTIVE),
axis.AmpEnableGet());

Learn more in topic page.


πŸ“œ Network Inputs and Outputs
This sample apps will demonstrate how to read the different values from your system's interchangable PDOs and SDOs.

// Get Input Values
int inputCount = controller.NetworkInputCountGet(); // Get number of Network Inputs (PDOs)
for (int i = 0; i < inputCount; i++)
{
int size = controller.NetworkInputBitSizeGet(i); // Read Input BitSize
int offset = controller.NetworkInputBitOffsetGet(i); // Read Input BitOffset
string name = controller.NetworkInputNameGet(i); // Read Input Name
UInt64 value = controller.NetworkInputValueGet(i); // Read Input Value
}
// Get Output Values
int outputCount = controller.NetworkOutputCountGet(); // Get number of Network Outputs (SDOs)
for (int i = 0; i < outputCount; i++)
{
int size = controller.NetworkOutputBitSizeGet(i); // Read Output BitSize
int offset = controller.NetworkOutputBitOffsetGet(i); // Read Output BitOffset
string name = controller.NetworkOutputNameGet(i); // Read Output Name
UInt64 value = controller.NetworkOutputSentValueGet(i); // Read Output Value
controller.NetworkOutputOverrideValueSet(i, value);
}

Learn more in topic page.


πŸ“œ IO Points
This sample apps will demonstrate how to use the IO point object to read and write to network data.

const int NODE_INDEX = 0; // The EtherCAT Node we will be communicating with
//const int INPUT_INDEX = 0; // The PDO Index in that Node
const int OUTPUT_INDEX = 0; // The PDO Index in that Node
// IOPoint input0 = IOPoint.CreateDigitalInput(controller.IOGet(NODE_INDEX), INPUT_INDEX); // Automatically gets the memory index of a specified node and input index
IOPoint output0 = IOPoint.CreateDigitalOutput(controller.IOGet(NODE_INDEX), OUTPUT_INDEX); // Automatically gets the memory index of a specified node and input index
output0.Set(false);
controller.SampleWait(1);
Assert.False(output0.Get(), "The getter function should return a value equal to false");

Learn more in topic page.


πŸ“œ Single Axis Sync Outputs
This sample application will show you a basic demonstartion on how to set up Sync Outputs, so that you can easily change any IO’s state based on a specified point index (or ElmentID) on your steaming motion.

const int TOTAL_POINTS = 4; // total number of points
const int EMPTY_CT = -1; // Number of points that remains in the buffer before an e-stop
const int OUTPUT_INDEX = 0; // This is the index of the digital output that will go active when the user limit triggers.
const int NODE_INDEX = 0; // The EtherCAT Node we will be communicating with
double[] positions = { 1.0, 2.0, 3.0, 4.0 }; // These will be the streaming motion 5 positions.
double[] times = { 0.5, 0.1, 0.2, 0.4 }; // These will be the streaming motion 5 positions' time.
int outputEnableID = 2; // The motion element ID at which to set the output
int outputDisableID = 3; // The motion element ID at which to set the output
// Set up the inputs
// IOPoint output0 = IOPoint.CreateDigitalOutput(axis, RSIMotorGeneralIo.RSIMotorGeneralIo16); // Retrieve DOUT 1, Method 1: requires you know the io adress in memory, slightly faster
IOPoint output0 = IOPoint.CreateDigitalOutput(controller.IOGet(NODE_INDEX), OUTPUT_INDEX); // Retrieve DOUT 1 Method 2: only need to know node index
output0.Set(false); // Set the output low
// Set up Sync Outputs
axis.StreamingOutputsEnableSet(true); // Enable streaming output.
// ENABLE the Sync Output(s)
axis.StreamingOutputAdd(output0, true, outputEnableID); // This will turn DOUT1 High when the streaming motion reaches its 3rd motion point.
axis.StreamingOutputAdd(output0, false, outputDisableID); // This will turn DOUT1 Low when the streaming motion reaches its 4th motion point.
// DISABLE the Sync Output(s)
// axis.StreamingOutputAdd(output0, false, outPutEnableID);
axis.MovePT(RSIMotionType.RSIMotionTypePT, positions, times, TOTAL_POINTS, EMPTY_CT, false, true); // Start Streaming Motion
while (!axis.MotionDoneGet())
{
if (axis.MotionIdExecutingGet() > outputEnableID && axis.CommandPositionGet() < outputEnableID)
{
Assert.AreEqual(output0.Get(), true, "The output should be triggered");
}
else
{
Assert.AreEqual(output0.Get(), false, "The output should NOT be triggered");
}
}
axis.StreamingOutputsEnableSet(false); // Disable Sync Outputs.
axis.AmpEnableSet(false); // Disable the motor.

Learn more in topic page.


πŸ“œ IO Point User Buffer
This sample application will show you how to create a simulated IOPoint from base on a memory address and index.

const int INPUT_INDEX = 0;
const int OUTPUT_INDEX = 1; // The PDO Index in that Node
UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabing an memory address to store a simulated IO point.
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX); // Automatically gets the memory index of a specified node and input index
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX); // Automatically gets the memory index of a specified node and input index
//---ACT/ASSERT---
output0.Set(false);
Assert.False(output0.Get(), "The getter function should return a value equal to false");
output0.Set(true);
Assert.True(output0.Get(), "The getter function should return a value equal to true");
controller.MemorySet(input0.AddressGet(), 0);
Assert.False(input0.Get(), "The getter function should return a value equal to false");
controller.MemorySet(input0.AddressGet(), 1);
Assert.True(input0.Get(), "The getter function should return a value equal to true");

Learn more in topic page.

RSI::RapidCode::MotionController::NetworkOutputSentValueGet
uint64_t NetworkOutputSentValueGet(int32_t index)
Gets the value sent out over EtherCAT.
RSI::RapidCode::MotionController::SampleWait
void SampleWait(uint32_t samples)
Wait for controller firmware to execute samples.
RSI::RapidCode::RSIMotionType
RSIMotionType
Streaming motion types.
Definition: rsienums.h:979
RSI::RapidCode::MotionController::NetworkInputValueGet
uint64_t NetworkInputValueGet(int32_t index)
RSI::RapidCode::MotionController::MemorySet
void MemorySet(uint64_t address, int32_t data)
Write a value to controller memory.
RSI::RapidCode::MotionController::IOGet
IO * IOGet(int32_t nodeNumber)
IOGet returns a pointer to an IO object using its node number and initializes its internals.
RSI::RapidCode::MotionController::NetworkOutputBitSizeGet
int32_t NetworkOutputBitSizeGet(int32_t index)
Get the size (in bits) of a PDO output.
RSI::RapidCode::MotionController::AddressGet
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
RSI::RapidCode::MotionController::NetworkInputBitSizeGet
int32_t NetworkInputBitSizeGet(int32_t index)
Get the size (in bits) of a network input.
RSI::RapidCode::MotionController::NetworkOutputNameGet
const char *const NetworkOutputNameGet(int32_t index)
Get the name of a PDO output.
RSI::RapidCode::RSIMotorDedicatedIn
RSIMotorDedicatedIn
Dedicated Input bits per motor.
Definition: rsienums.h:834
RSI::RapidCode::MotionController::NetworkInputBitOffsetGet
int32_t NetworkInputBitOffsetGet(int32_t index)
RSI::RapidCode::MotionController::NetworkOutputCountGet
int32_t NetworkOutputCountGet()
RSI::RapidCode::MotionController::NetworkOutputBitOffsetGet
int32_t NetworkOutputBitOffsetGet(int32_t index)
Get the raw PDO offset for an output.
RSI::RapidCode::RSIControllerAddressType
RSIControllerAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition: rsienums.h:412
RSI::RapidCode::MotionController::NetworkOutputOverrideValueSet
void NetworkOutputOverrideValueSet(int32_t index, uint64_t outputValue)
Sets a PDO output directly.
RSI::RapidCode::MotionController::NetworkInputNameGet
const char *const NetworkInputNameGet(int32_t index)
Get the name of a PDO network input.
RSI::RapidCode::MotionController::NetworkInputCountGet
int32_t NetworkInputCountGet()
Get the number of PDO inputs found on the network.