In this tutorial, we will demonstrate relay control over a standard Ethernet port using a ProXR series relay board and a Lantronix XPort communications module. This tutorial will show you everything you need to get started sending TCP/IP data using Comm Operator. Comm Operator was created by ginkgomo.com, and we have worked directly with the author of this software since 2003. Comm Operator is capable of communicating to every device we manufacture, this tutorial will show you how easy it is to use Comm Operator to control our devices. A trial version of Comm Operator is included with Base Station. If you have not done so, please download Base Station software and run on your Windows 7, 8, or 10 computer:
Controlling a Relay over Ethernet using TCP/IP
Sending and Receiving TCP/IP data is very easy using Comm Operator software. This tutorial will demonstrate the basics of discovering a device and controlling relays by sending TCP/IP data over Ethernet using Comm Operator.
Step 1: Determine IP Address through UDP Broadcast
The first step to controlling a network device using Comm Operator is to determine the IP address of the device. The easiest way to determine the IP address is to listen on the local area network for a UDP broadcast. This is a default feature of all NCD network devices. To read the UDP broadcast, make sure your controller is connected to your local area network and make sure your computer is on the same network connection.
In Comm Operator, select the “File” pull-down menu and select “Open Connection”.
Now click on the UDP tab and make sure the listen port is set to 13000 as shown in the screenshot below. Click the “Open” button to begin listening for the UDP broadcast of the device.
Step 2: Determine IP Address of the Device
Within the next minute or so, you should see a UDP broadcast appear. This UDP broadcast will identify the IP address of the device, the Mac Address, the port number, the type of device (in this case, Lantronix XPort, and the firmware version. See the photo below for an example of a UDP broadcast and take note of the IP address of your device.
Step 3: Open a Connection to the Ethernet Relay Controller
Now that you know the IP address and port of your controller, it’s time to use Comm Operator to open a connection to the device.
Select File>Open Connection in Comm Operator.
Choose TCP Client and Enter the IP Address and Port Number (Usually 2101) and click the “Open” button, as shown in the screenshot below:
Step 4: Setup Comm Operator User Interface
Make sure Comm Operator is configured for the following settings (the IP Address may be different for your network, also, you can disregard the Recv and Send data, this just indicates how many bytes have been communicated since the connection was opened):
Step 5: Sending a Command
Many times in our tutorials, we will show you the complete command, including API encoding. You will see tables throughout our tutorials that look like this:
TX: | FUNCTION: | RX: | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
170 | 3 | 254 | 108 | 1 | 24 | Turn On Relay 1 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 109 | 1 | 25 | Turn On Relay 2 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 110 | 1 | 26 | Turn On Relay 3 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 111 | 1 | 27 | Turn On Relay 4 in Bank 1 | 170 | 1 | 85 | 0 |
The actual command is smaller than the API encoding data. The table below shows the actual commands, as the API data can be automatically generated. Highlighted in Blue below, the actual bytes of data sent and received from the controller.
TX: | FUNCTION: | RX: | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
170 | 3 | 254 | 108 | 1 | 24 | Turn On Relay 1 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 109 | 1 | 25 | Turn On Relay 2 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 110 | 1 | 26 | Turn On Relay 3 in Bank 1 | 170 | 1 | 85 | 0 |
170 | 3 | 254 | 111 | 1 | 27 | Turn On Relay 4 in Bank 1 | 170 | 1 | 85 | 0 |
As you can see, it’s pretty easy to strip out API data to look at the command. Simply omit the first 2 bytes and the last byte on both the send and receive packet.
For this tutorial, we will be activating the first 4 relays on a ProXR series controller:
TX: | FUNCTION: | RX: | ||
---|---|---|---|---|
254 | 108 | 1 | Turn On Relay 1 in Bank 1 | 85 |
254 | 109 | 1 | Turn On Relay 2 in Bank 1 | 85 |
254 | 110 | 1 | Turn On Relay 3 in Bank 1 | 85 |
254 | 111 | 1 | Turn On Relay 4 in Bank 1 | 85 |
Start by entering: 254 108 1 as shown in the box below and click the “Send” button.
Step 6: Confirm Data
After sending data to the controller you, should receive a API packet back. Notice how Comm Operator added the API data for you. The relay should be on and you should be ready to send any command you want with Comm Operator.