Modbus Example Ethernet Adapter

Modbus Bridge Example - Ethernet Adapters

This is the XBee to Ethernet node portion of an Modbus Bridge example using a Digi ConnectPort X4 as the central Modbus/TCP bridge and a collection of serial and Ethernet nodes.

This page shows how to enable XBee wireless to be bridged to Modbus/TCP servers (or slaves). This is not directly related to use of Modbus/TCP to query remote nodes via XBee wireless.

To see how to Bridge mesh to Modbus/RTU serial slaves, see this web page: Modbus Example Serial Adapter.

Supported Models

Digi ConnectPort X2 when loaded with firmware 82001596 (Ethernet model) or 82001630 (Wi-Fi model), which supports Python.

Product Installation

Confirm that you have the correct power for your ConnectPort X2 - probably 9 to 30vdc. If you want to use an existing shared 12vdc or 24vdc supply, Digi sells a power-pigtail with the correct locking barrel connector - details are here: Locking Power Connecter.

You'll also need to make sure the appropriate antenna is installed - and if the CP-X2 is to be installed inside of a metal enclosure, you'll need to plan to mount the appropriate external antenna options.

Reflash the CPX2's XBee Module

To allow Modbus/RTU traffic on the XBee wireless to bridge to local Ethernet servers, you'll need the XBee module to be flashed with the XBee Router API firmware (such as 0x2364) - not the default XBee Coordinator API firmware. Quite literally, you need the CPX2 to be a member of the central CPX4 bridge's mesh, so the CPX4's XBee is to be the Coordinator; not the CPX2's XBee.

You can either:

Use the web UI to upload the EBL file (such as XB24-ZB_2364.ebl or XBP24-ZB_2364.ebl)

If you instead dissemble the CPX2 unit and manually reflash the XBee using a serial or USB development board, then make sure you enter the settings below. These should already be handled if you used the web UI:

As a second step, enter this Setting:

Set the Baud Rate to 115200 (BD=7). This will have defaulted back to 9600 after you reflashed the XBee firmware, plus XCTU might give you an error as you try to set this.

Configure the CPX2's XBee Module

If the CPX2 and XBee are properly configured, then the CPX2 will show up on both the "Network View" of the Digi ConnectPort X4 (the central bridge) and on that of the Digi ConnectPort X2. You can configure the following settings via either the CPX4 or the CPX2:

Click on the appropriate Extended Address (MAC address) link and you will see the Basic settings page:

On the XBee Configuration - Basic Settings page:

Enabling the Python application to do the bridging

To enable the bridging of XBee wireless packets to local Modbus/TCP server/slaves, you'll need to upload the appropriate Python files to your CPX2.

Create the address.txt file

The first generation of this tool supports a single Modbus/TCP server/slave, and its IP address must be uploaded in the text file named "address.txt". The ":502" at the end is optional, but can be used to change the default TCP port number to use.

192.168.196.6:502

Uploading the Files

Click the Python Application link, then upload the three files: mbus_bridge.py, crc16.py and address.txt. They are contained in this ZIP file: X2_mbus_2009Sep13.zip.

The file list should look similar to that below, however the file sizes may vary:

Enable auto-start of the bridging

After uploading the files, click the Auto-Start Settings section and enter the mbus_bridge.py.

Note that this Python application closes all sockets and sleeps for 60 seconds anytime there is a fault. So if you are moving Ethernet cables around or doing other disruptive things, the CPX2 might not appear to function for a minute or two.