APIs, concepts, guides, and more
io-iopoint.cs
/* This sample demonstrates how to use IOPoint objects to read and write network data.
Shows how to create IOPoint objects for digital outputs and use them to control IO.
Requires an EtherCAT network with nodes that have digital outputs.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 IO: IOPoint Objects");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
const int NODE_INDEX = 0; // the EtherCAT Node we will be communicating with
const int OUTPUT_INDEX = 0; // the PDO Index in that Node
// create IOPoint for digital output - automatically gets memory index of specified node and output index
IOPoint output0 = IOPoint.CreateDigitalOutput(controller.NetworkNodeGet(NODE_INDEX), OUTPUT_INDEX);
// set the output to false
output0.Set(false);
Console.WriteLine($"Output {OUTPUT_INDEX} set to: false");
// wait one sample for the change to take effect
controller.SampleWait(1);
// read back the value
bool outputValue = output0.Get();
Console.WriteLine($"Output {OUTPUT_INDEX} value: {outputValue}");
// set the output to true
output0.Set(true);
Console.WriteLine($"Output {OUTPUT_INDEX} set to: true");
controller.SampleWait(1);
outputValue = output0.Get();
Console.WriteLine($"Output {OUTPUT_INDEX} value: {outputValue}");
}
// handle errors as needed
finally
{
controller.Delete(); // dispose
}
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
Definition _helpers.cs:15
Helpers class provides static methods for common tasks in RMP applications.
Definition _helpers.cs:5
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:11559
NetworkNode * NetworkNodeGet(int32_t nodeNumber)
NetworkNodeGet returns a pointer to a RapidCodeNetworkNode object using its node number and initializ...
static MotionController * Get()
Get an already running RMP EtherCAT controller.
void SampleWait(uint32_t samples)
Wait for controller firmware to execute samples.
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:800