Modbus RTU bridge LoRaWAN: This feature can convert serial-based devices into LoRa-based ones
Modbus RTU Data Transmission: This feature enables Modbus RTU data transmission between serial network and TCP/IP network over LoRa
- Write data to Modbus RTU device's registers or send query instructions to Modbus RTU devices
- Forward the data from TCP client to UC500/UC11-N1/UC1152
- Write data to Modbus RTU device's registers or send query instruction to Modbus RTU devices
- Responding Modbus RTU data when receiving query
- Transmit Modbus RTU data over LoRa
- Transmit Modtus data transparently by Modbus RTU over TCP or converter Modbus RTU data into Modbus TCP data ty Modtus RTU to TCP
Requirements:
- UC11-N1/UC1152
- Ursalink LoRaWAN Gateway UG8x with firmware version above 80.0.0.34 (included)
- Latest version of Toolbox
Step-by-step:
Declaration
For Modbus over TCP test we use sscom as a simulator of serial data, UC1152, UG87v2-16ch, PC and NetAssist as TCP client for PoC. For Modbus to TCP test, we use Modbus Doctor to simulate Modbus TCP and Modbus slave to monitor RS485 output.
1. Hardware Configuration
As shown in the topology, we need to have these four parts linked hand in hand in order to transmit data in between. For LoRa and TCP sections, we have elaborated explanation in Chapter 2 Software Configuration.
For Modbus RTU section, you should connect with RS485 standard according to serial devices’ operation instructions.
2. Software Configuration
2.1 UC11-N1/UC1152 Configuration
With UC11-N1/UC1152 connected to PC with USB cable, open Toolbox. It will auto detect the COM port to micro USB port of UC11-N1/UC1152. The default password is 123456.
Navigate to “General > RS485”, enable Modbus RS485 bridge LoRaWAN, mark down the port specified for bridging. For example we have 200 as port of UC11-N1/UC1152 to RS485 device here.
In “LoRaWAN” on the left, you can find essential attributes of the UC11-N1/UC1152 and you would need them to register it onto UG8x.
NOTE: “LoRaWAN > Channel” configures LoRaWAN frequency that the UC11-N1/UC1152 uses to communicate with gateway, while “Channel” configures RS485 channel for UC11-N1/UC1152 to poll the remote Modbus Slave.
As for “Channel”, please go through Chapter 4.5 in UC1152 User Guide or Chapter 3.3.2 in UC11-N1 User Guide for more information.
2.2 UG8x Configuration
As a bridge for Modbus data between LoRa and TCP, the gateway needs to connect to Internet.
Enable Network Server in “LoRaWAN > Network Server”, refer to chapter 4.1~4.4 in User Guide of gateway to configure applications and profiles, add devices.
NOTE: if you would like to use Modbus RTU over TCP, when adding UC11-N1/UC1152 in “LoRaWAN > Network Server > Devices”, enable Modbus RTU over TCP. And the same applies to Modbus RTU to TCP according to your need. Put the port for bridging between UC11-N1/UC1152 and RS485 devices in “Fport”. You may take the liberty to name a random port of UG8x as TCP port, but remember it as a crucial parameter when configuring TCP client or Modbus TCP.
2.3 TCP Client Configuration
Open NetAssist on PC, type in IP address of UG8x as IP address of TCP server, and choose TCP port we chose in 2.2 as the port. Click “Connect”, then we have PC connected to UG8x by TCP.
2.4 Modbus TCP Configuration
Open Modbus Doctor on PC, type in IP address of UG8x as IP address of Modbus TCP server, put in the port we chose in 2.2 as NumPort. Click “Close”, choose “CONNECTION”.
3. Test
Modbus over/to TCP shares the same topology, except that the protocol in TCP client side is different. Testing Modbus over TCP is using original Modbus and TCP/IP. While testing Modbus to TCP we introduce Modbus TCP/IP (also Modbus-TCP) which is simply the Modbus RTU protocol with a TCP interface that runs on Ethernet. The Modbus messaging structure is the application protocol that defines the rules for organizing and interpreting the data independent of the data transmission medium, which in this case, is the LoRaWAN connection. So this feature is not only provided in LoRaWAN gateways but also in our industrial cellular routers that have RS485 serial ports.
Chapter 3.3 is for Modbus over TCP testing and chapter 3.4 is for Modbus to TCP testing.
3.1 Check Data with UC11-N1/UC1152
First, we test the Modbus link.
For example, we connect UC11-N1/UC1152 to PC in RS485 and stimulate serial data with Modbus Slave.
In Toolbox, we’d like to configure a channel for UC11-N1/UC1152 to poll stimulated Modbus Slave and read data.
3.2 Send Query from UG8x
Second, we proceed to UG8x. From the gateway we cannot read data directly so we use Modbus format payload to query for it.
Query frame:
Slave ID |
Function |
Address |
Length |
Parity |
0x01 |
0x03 |
0x00 0x00 |
0x00 0x02 |
0xC4 0x0B |
Response frame:
Slave ID |
Function |
Length |
Data |
Parity |
0x01 |
0x03 |
0x04 |
0x00 0x01 0x00 0x02 |
0x2A 0x32 |
Fill the query frame in hex payload in “LoRaWAN > Network Server > Packets”, put in device EUI and port 200 and then click “Send”.
Above DnCnf queued to be sent is shown in gray, we see three continuous packets. A stands for the sent DnCnf and hence the same frame counts as queued DnCnf but not gray. B is the response from UC1152/UC11-N1 to the query we sent from gateway. C is the ACK packet that confirms to have received data by UC1152/UC11-N1.
The details of UpCnf packet is shown below:
Notice the payload in hex, and you can read it with the response frame table above, and the data is “1,2” as in UC1152/UC11-N1 channel.
3.3 Send Query from TCP Client
Use the query frame as 3.2, send 010300000002c40b for example to read first two digits of data, see TCP server (UG8x) responds with 010304000100022A32.
In web GUI of UG8x, we see that on one way UG8x receives the message from TCP client in TCP, on the other way UG8x sends a DnCnf with the message to UC1152/UC11-N1 in LoRaWAN and transfers data in no time.
Click the exclamation mark to see packets details, payload in hex that UC1152/UC11-N1 sent to UG8x matches what TCP client receives and is correctly “1,2”.
3.4 Read to Modbus TCP
Enable SPY MODE and click CONNECTION to see it is printed in status:
Status: Connecting to 192.168.23.226:9099...
Status: Connected
As Modbus Slave has 10 addresses for default, we set Length as 10 too. Click READING. You can see the query frame in darker blue and response frame in lighter one in the traffic communication block on the right.
Here is a data table of Modbus TCP communication protocol.
Query Frame |
Response Frame |
||
Byte |
Content |
Byte |
Content |
0-4 |
Start |
0-4 |
Start |
5 |
Whole Length |
5 |
Whole Length |
6 |
Slave ID |
6 |
Slave ID |
7 |
Function Code |
7 |
Function Code |
8, 9 |
Start Address |
8 |
Data Length |
9, 10 |
Data |
||
10, 11 |
Address Length |
11, 12 |
Data |
... |
Data |
According to the table we can tell the data read from Modbus RTU is 1,2 which is correct.
Meanwhile in packets of Network Server in UG8x, we can see a DnCnf that came with a following UpCnf with the same hex payload.
3.5 Write from Modbus TCP
Modbus Doctor supports writing to Modbus RTU. You can input random number in Value of each Register. Click WRITING. You can read the communication traffic according to the table above.
Meanwhile in packets of Network Server in UG8x, we can see a DnCnf came with a following UpCnf with the same hex payload.
In Modbus Slave, you can see the value has changed correspondingly.
Comments
0 comments
Please sign in to leave a comment.