Robot Electronics EthRly16 .Net Control Library

Robot Electronics - EthRly 16 Device

Let’s move on to the next quick bit of code I refurbished lately. This time it’s a C# Library for an 8-port relay card from RobotElectronics. Specifically the EthRly16 with an ethernet port and 8 relays of which each one has a Normally-Open and Normally-Closed output. That probably explains the 16 in the model name, or its the 16 amps of switching load, who knows.

How to use it

EthRly16Card relayCard = new EthRly16Card("");

Like the IPWE library this one will be instantiated by telling it the ip address of the device. After that you can use all functions the EthRly16 has to offer. Ask for the input voltage, the firmware version, the MAC address or to get to the good part, set and unset one or all relays and query the current states of them.

double voltage = relayCard.GetInputVoltage();
byte[] mac = relayCard.GetMacAddress();
int version = relayCard.GetFirmwareVersion();
bool[] states = relayCard.GetRelaysStates();

relayCard.SetRelay(i, true);
EthRly16 Test Console Output
EthRly16 Test Console Output

The library including a sample console project is available on GitHub.

How it works

The relay card offers a tcp endpoint which is used to send commands to the device. More information about that is listed on the device website that is accessible using the ip address in the browser address line. Basically you send two bytes to the device. The first byte contains the command code and the second if needed the payload. After that you get the response which is usually one byte, except you query the mac address. In that case you get of course six bytes which represents the mac address.

EthRly16 WebSite
EthRly16 WebSite

Hopefully this will help someone and if you have questions leave a comment or send me an email or a tweet. See you with the next post.

Felix Reisch is a professional and passionate software engineer employed at adesso AG in Dortmund, Germany. His main objectives are ASP.NET Web Applications and Apps for the Universal Windows Platform. In his spare time he likes rock climbing and playing around with everything that contains the letters IoT.

Leave a Reply

%d bloggers like this: