APIs, concepts, guides, and more
io-general-purpose.cs
/* This sample demonstrates how to access General Purpose IO on EtherCAT network nodes.
Shows how to read and write digital and analog inputs/outputs.
Requires an EtherCAT network with nodes that have IO.
*/
using RSI.RapidCode; // RSI.RapidCode.dotNET;
Console.WriteLine("📜 IO: General Purpose");
// get rmp objects
try
{
Helpers.CheckErrors(controller);
// get node
var node = controller.NetworkNodeGet(nodeNumber: 0);
// digital io
bool dIn = node.DigitalInGet(digitalInNumber: 0);
bool dOut = node.DigitalOutGet(digitalOutNumber: 0);
node.DigitalOutSet(digitalOutNumber: 0, state: dOut);
// analog io
int aIn = node.AnalogInGet(analogChannel: 0);
int aOut = node.AnalogOutGet(analogChannel: 0);
node.AnalogOutSet(analogChannel: 0, analogValue: aOut);
Console.WriteLine($"Digital Input 0: {dIn}");
Console.WriteLine($"Digital Output 0: {dOut}");
Console.WriteLine($"Analog Input 0: {aIn}");
Console.WriteLine($"Analog Output 0: {aOut}");
}
// 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
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 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