Difference between revisions of "Template:Networking manual Modbus serial RutOS"

From Teltonika Networks Wiki
(Created page with "==Summary== '''Modbus''' is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers...")
 
 
(34 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
 
Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.
  
This article provides a brief example on how to use Modbus serial to monitor a slave device, send data to server and how to configure slave alarms. To find more information about this feature visit [[RUT955 Modbus]] and [[RUT955 RS232/RS485]] pages.
+
This article provides a brief example on how to use Modbus serial to monitor a slave device, send data to server and how to configure slave alarms. To find more information about this feature visit [[RUT955 Modbus]] page.
  
 
==Prerequisites==
 
==Prerequisites==
  
*One RUT955 router
+
*One device with RS232 Serial port;
*Windows 10 computer
+
*Windows 10/11 OS computer;
*Hercules and modRSsim applications
+
*Hercules and ModRSsim applications;
*RS232 to USB cable
+
*RS232 to USB cable.
  
 
==Topology==
 
==Topology==
  
 
[[File:Networking_rut955_configuration_modbus_serial_topology_2_v1.png|border|class=tlt-border|700x700px]]
 
[[File:Networking_rut955_configuration_modbus_serial_topology_2_v1.png|border|class=tlt-border|700x700px]]
 +
{{Template:Networking install Modbus serial RutOS}}
  
 
==Configuring Modbus serial slave device==
 
==Configuring Modbus serial slave device==
  
In this example we are going to be using our Windows 10 computer as a slave. To do so you will need to install '''modRSsim''' application, which you can download [https://sourceforge.net/projects/modrssim/ here].
+
In this example we are going to be using our Windows 10/11 OS computer as a slave. To do so you will need to install '''modRSsim''' application, which you can download [https://sourceforge.net/projects/modrssim2/ here].
  
 
When you are done with that, open the app and apply the following configuration.
 
When you are done with that, open the app and apply the following configuration.
 
+
<table class="nd-othertables_2">
[[File:Networking_rut955_configuration_modbus_serial_1_v1.png|border|class=tlt-border]]
+
    <tr>
 
+
        <th width=330; style="border-bottom: 1px solid white;></th>
 +
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Networking_rut955_configuration_modbus_serial_1_v1.png|border|class=tlt-border|right]]</th>
 +
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 
# Select '''Protocol''' (MODBUS RS-232).
 
# Select '''Protocol''' (MODBUS RS-232).
 
# Click '''Setup the communication Serial or TCP/IP port'''.
 
# Click '''Setup the communication Serial or TCP/IP port'''.
 +
        </td>
 +
    </tr>
 +
</table>
  
[[File:Networking_rut955_configuration_modbus_serial_2_v1.png|border|class=tlt-border]]
+
----
 
+
<table class="nd-othertables_2">
 +
    <tr>
 +
        <th width=330; style="border-bottom: 1px solid white;></th>
 +
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Networking_rut955_configuration_modbus_serial_2_v1.png|border|class=tlt-border|center]]</th>
 +
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 
# Select the '''Port''' which you connected RS232 cable to (to find which port you are using go to Windows search bar and write '''Device Manager''' then select '''Ports''' and see which one you are using).
 
# Select the '''Port''' which you connected RS232 cable to (to find which port you are using go to Windows search bar and write '''Device Manager''' then select '''Ports''' and see which one you are using).
 
# Select '''Parity''' (Even).
 
# Select '''Parity''' (Even).
 
# Click '''OK'''.
 
# Click '''OK'''.
 +
        </td>
 +
    </tr>
 +
</table>
  
 
==Configuring Modbus serial master==
 
==Configuring Modbus serial master==
  
Open router’s WebUI, navigate to '''Services > Modbus > Modbus Serial Master''' and apply the following configuration.
+
Open router’s WebUI, navigate to '''Services Modbus Modbus Serial Client''' and in Serial Device configuratio section '''add new instance''' by entering a name, selecting '''rs232''' and pressing [[File:Add Button.png|60x90px]] button. In the newly opened Device Configuration window configure everything as follows:
  
[[File:Networking_rut955_configuration_modbus_serial_3_v1.png|border|class=tlt-border]]
+
<table class="nd-othertables_2">
 +
    <tr>
 +
        <th width=330; style="border-bottom: 1px solid white;></th>
 +
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Modbus Serial RUT955 1.png|border|class=tlt-border|755x406px|right]]</th>
 +
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 +
# '''Enable''' instance;
 +
# Select '''Baud rate''' (9600, it must match slave‘s baud rate);
 +
# Select '''Parity''' (Even);
 +
# Press [[File:Networking save apply button fw76 v1.png|100x35px]] button.
 +
        </td>
 +
    </tr>
 +
</table>
  
# Press '''Enable'''.
+
----
# Select '''Baud rate''' (9600, it must match slave‘s baud rate).
+
Now in Modbus Devices section create '''RS232 slave''' by writing a new instance name, selecting rs232 and pressing [[File:Add Button.png|60x90px]] button. In the new window apply the following configuration:
# Select '''Parity''' (Even).
 
# Press '''Save'''.
 
 
 
Now create '''RS232 slave''' by writing a name, pressing '''Add''' button. It should appear like in the example and then press '''Edit'''.
 
 
 
[[File:Networking_rut955_configuration_modbus_serial_4_v1.png|border|class=tlt-border]]
 
 
 
Then apply the following configuration.
 
 
 
[[File:Networking_rut955_configuration_modbus_serial_5_v1.png|border|class=tlt-border]]
 
 
 
# Check '''Enable'''.
 
# Type in '''Slave ID''' (any number from 1 to 255).
 
# Add '''Period''' (Query period).
 
# Press '''Save'''.
 
 
 
Go back to the '''Slave configuration''' window and create '''Slave request''' by writing a name, pressing '''Add''' button. It should appear like in the example and then press '''Edit'''.
 
 
 
[[File:Networking_rut955_configuration_modbus_serial_6_v1.png|border|class=tlt-border]]
 
 
 
Then apply the following configuration.
 
 
 
[[File:Networking_rut955_configuration_modbus_serial_7_v1.png|border|class=tlt-border]]
 
  
# Check '''Enable'''.
+
<table class="nd-othertables_2">
# Select '''Function''' (Read Holding Registers).
+
    <tr>
# Write '''First register''' (1).
+
        <th width=330; style="border-bottom: 1px solid white;></th>
# Write '''Register count''' (10).
+
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Modbus Serial RUT955 2.png|border|class=tlt-border|755x406px|right]]</th>
# Press '''Save'''.
+
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 +
# Check '''Enable''';
 +
# Type in desired '''Name''';
 +
# Type in '''Server ID''' (any number from 1 to 255);
 +
# Select '''Period''', e.g. 10;
 +
# Write a '''name''' for a new request.
 +
# Add new request by writing it's name and clicking '''ADD''';
 +
# Select '''data type'''.
 +
# Select '''Function''' (Read holding registers (3)).
 +
# Write '''First register''' (1) and Write '''Register count''' (10).
 +
# Enable the request and you can test it through '''request configuration testing''' section.
 +
# Press [[File:Networking save apply button fw76 v1.png|100x35px]] button.
 +
        </td>
 +
    </tr>
 +
</table>
 +
[[File:Modbus_Serial_RUT955_3.png|border|class=tlt-border|1100x400px]]
 +
[[File:Modbus Serial RUT955 4.png|border|class=tlt-border|850x280px]]
  
 
==Modbus data to server==
 
==Modbus data to server==
Line 87: Line 112:
 
There are many ways how you can create a server to which Modbus will send data to. In this example we are going to be using Windows 10 computer and Hercules app, which you can download  [https://www.hw-group.com/product-version/hercules here], to create a test server. Download, install the app and apply the configuration below:
 
There are many ways how you can create a server to which Modbus will send data to. In this example we are going to be using Windows 10 computer and Hercules app, which you can download  [https://www.hw-group.com/product-version/hercules here], to create a test server. Download, install the app and apply the configuration below:
  
[[File:Networking_rut955_configuration_modbus_serial_8_v1.png|border|class=tlt-border]]
+
<table class="nd-othertables_2">
 
+
    <tr>
 +
        <th width=300; style="border-bottom: 1px solid white;></th>
 +
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Modbus serial rut955 5.png|border|class=tlt-border|left]]</th>
 +
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 
# Select '''TCP Server''' tab.
 
# Select '''TCP Server''' tab.
# Enter '''Port''' (In this example default 1883 is used).
+
# Enter '''Port''' (In this example default 80 is used).
 
# Click '''Listen'''
 
# Click '''Listen'''
 +
        </td>
 +
    </tr>
 +
</table>
  
 
And that is it, now you will be able to see the data coming from Modbus in the Received data section.
 
And that is it, now you will be able to see the data coming from Modbus in the Received data section.
Line 98: Line 131:
 
----
 
----
  
In order to setup your router to send Modbus data to server you will need to navigate to '''Services > Modbus > Modbus Data to Server'''.
+
In order to setup your router to send Modbus data to server you will need to navigate to '''Services Data to Server''', create a '''"New collectiom name"''' and press '''ADD''' to add a new instance.
 
 
[[File:Networking_rut955_configuration_modbus_serial_9_v1.png|border|class=tlt-border]]
 
 
 
# Select '''Protocol''' (In this example HTTP(S) will be used).
 
# Enter '''IP''' and '''port''' of the PC with the Hercules software.
 
# Enter '''Period''' (minutes, how often router should send data to server).
 
# Click '''ADD'''.
 
 
 
Then you will be redirected to '''Advanced sender settings'''.
 
 
 
[[File:Networking_rut955_configuration_modbus_serial_10_v1.png|border|class=tlt-border]]
 
  
# Enter '''Name''' (It can be anything you want).
+
#Select '''Type: Modbus''';
# Click '''Save'''.
+
#Select '''Format Type: Custom''';
 +
#Enter desired '''format string''';
 +
#Leave other parameterms as it is and click on [[File:Next Collection.png|150x35px]] icon;
 +
#In the '''Collection configuration''' window leave the settings as default and click on [[File:Next Server.png|180x35px]] button;
 +
#In the '''Server configuration''' window select '''Type: HTTP''';
 +
#Enter '''Server address''';
 +
#Click [[File:Networking save apply button fw76 v1.png|100x35px]];
 +
[[File:Modbus Serial RUT955 6.png|border|class=tlt-border|1100x539px]]
 +
[[File:Modbus Serial RUT955 8.png|border|class=tlt-border|1000x250px]]
  
 
===Receiving data===
 
===Receiving data===
 
----
 
----
 
 
Open Hercules again, press '''Listen''' and you should start receiving Modbus Data messages.
 
Open Hercules again, press '''Listen''' and you should start receiving Modbus Data messages.
 
+
[[File:Modbus serial rut955 9.png|border|class=tlt-border|700x600px]]
[[File:Networking_rut955_configuration_modbus_serial_11_v1.png|border|class=tlt-border]]
 
  
 
Try to change some data in the Modbus Slave simulator.
 
Try to change some data in the Modbus Slave simulator.
  
[[File:Networking_rut955_configuration_modbus_serial_12_v1.png|border|class=tlt-border]]
+
[[File:Modbus serial rut955 10.png|border|class=tlt-border|700x700px]]
  
 
Received data should change.
 
Received data should change.
  
[[File:Networking_rut955_configuration_modbus_serial_13_v1.png|border|class=tlt-border]]
+
[[File:Modbus serial rut955 11.png|border|class=tlt-border|700x600px]]
  
 
==Slave alarms==
 
==Slave alarms==
Line 133: Line 161:
 
In order to setup the following configuration SIM card is required.
 
In order to setup the following configuration SIM card is required.
  
Go back to '''Services > Modbus > Modbus Serial Master''' and press edit the same Slave configuration or create a new one. There will be section called '''Slave alarms'''. Create a name, then press '''Add''' button. When it appears like in the example, press '''Edit'''.
+
Go back to '''Services Modbus Modbus Serial Client''' and press [[File:Networking edit button fw76 v1.png]] button on the previously created '''Modbus''' slave '''Device''' instance or create a new one. In the opened window scroll down to the bottom and in '''Alarms Configuration''' section press [[File:Add Button.png|60x90px]].
 
 
[[File:Networking_rut955_configuration_modbus_serial_14_v1.png|border|class=tlt-border]]
 
  
Then apply the following configuration:
+
In Alarm Configuration apply the following changes:
 
 
[[File:Networking_rut955_configuration_modbus_serial_15_v1.png|border|class=tlt-border]]
 
  
 +
<table class="nd-othertables_2">
 +
    <tr>
 +
        <th width=320; style="border-bottom: 1px solid white;></th>
 +
        <th width=800; style="border-bottom: 1px solid white"; rowspan=2>[[File:Modbus Serial RUT955 10.png|border|class=tlt-border|770x570px|right]]</th>
 +
    </tr>
 +
    <tr>
 +
        <td style="border-bottom: 4px solid white>
 
# '''Enable''' instance.
 
# '''Enable''' instance.
 
# Select '''Function''' (Read Holding Registers).
 
# Select '''Function''' (Read Holding Registers).
 
# Write '''Register''' (1).
 
# Write '''Register''' (1).
 
# Select '''Condition''' (More than).
 
# Select '''Condition''' (More than).
# Write '''Value''' (5).
+
# Write '''Value''' (10).
 +
# Select '''Action frequency''' (First trigger)
 
# Select '''Action''' (SMS).
 
# Select '''Action''' (SMS).
 +
# Create '''Message''' (type anything you want to receive).
 
# Write '''Phone number''' (the number you want to receive the messages to).
 
# Write '''Phone number''' (the number you want to receive the messages to).
# Create '''Message''' (type anything you want to receive).
+
# Press [[File:Networking save apply button fw76 v1.png|100x35px]] button.
# Press '''Save'''.
+
        </td>
 +
    </tr>
 +
</table>
  
 
Now go back to '''Modbus slave simulator''' and edit this window:
 
Now go back to '''Modbus slave simulator''' and edit this window:
  
[[File:Networking_rut955_configuration_modbus_serial_16_v1.png|border|class=tlt-border]]
+
[[File:Modbus serial rut955 14.png|border|class=tlt-border|1000x700px]]
 +
 
 +
Change the value to anything below 10, you should not receive messages. Then change the value to anything above 10, you should start receiving messages.
  
Change the value to anything below 5, you should not receive messages. Then change the value to anything above 5, you should start receiving messages.
+
[[File:Modbus serial rut955 15.png|border|class=tlt-border|400x400px]]

Latest revision as of 13:20, 21 August 2024

Summary

Modbus is a serial communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Modbus has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. The main reasons for the use of Modbus in the industrial environment are:

  • developed with industrial applications in mind;
  • openly published and royalty-free;
  • easy to deploy and maintain;
  • moves raw bits or words without placing many restrictions on vendors.

Modbus enables communication among many devices connected to the same network, for example, a system that measures temperature and humidity and communicates the results to a computer. Modbus is often used to connect a supervisory computer with a remote terminal unit (RTU) in supervisory control and data acquisition (SCADA) systems. Many of the data types are named from its use in driving relays: a single-bit physical output is called a coil, and a single-bit physical input is called a discrete input or a contact.

This article provides a brief example on how to use Modbus serial to monitor a slave device, send data to server and how to configure slave alarms. To find more information about this feature visit RUT955 Modbus page.

Prerequisites

  • One device with RS232 Serial port;
  • Windows 10/11 OS computer;
  • Hercules and ModRSsim applications;
  • RS232 to USB cable.

Topology

Networking rut955 configuration modbus serial topology 2 v1.png

Installation

From FW version of RUT9_R_00.07.05 and newer Modbus Serial Client package is installed by default. To install it on older FW versions open device's WebUI, navigate to Services → Package manager → Packages and search for Modbus Serial Master and press + icon to install. After installation you should see a status Installed on this package.

Configuring Modbus serial slave device

In this example we are going to be using our Windows 10/11 OS computer as a slave. To do so you will need to install modRSsim application, which you can download here.

When you are done with that, open the app and apply the following configuration.

Networking rut955 configuration modbus serial 1 v1.png
  1. Select Protocol (MODBUS RS-232).
  2. Click Setup the communication Serial or TCP/IP port.

Networking rut955 configuration modbus serial 2 v1.png
  1. Select the Port which you connected RS232 cable to (to find which port you are using go to Windows search bar and write Device Manager then select Ports and see which one you are using).
  2. Select Parity (Even).
  3. Click OK.

Configuring Modbus serial master

Open router’s WebUI, navigate to Services → Modbus → Modbus Serial Client and in Serial Device configuratio section add new instance by entering a name, selecting rs232 and pressing Add Button.png button. In the newly opened Device Configuration window configure everything as follows:

Modbus Serial RUT955 1.png
  1. Enable instance;
  2. Select Baud rate (9600, it must match slave‘s baud rate);
  3. Select Parity (Even);
  4. Press Networking save apply button fw76 v1.png button.

Now in Modbus Devices section create RS232 slave by writing a new instance name, selecting rs232 and pressing Add Button.png button. In the new window apply the following configuration:

Modbus Serial RUT955 2.png
  1. Check Enable;
  2. Type in desired Name;
  3. Type in Server ID (any number from 1 to 255);
  4. Select Period, e.g. 10;
  5. Write a name for a new request.
  6. Add new request by writing it's name and clicking ADD;
  7. Select data type.
  8. Select Function (Read holding registers (3)).
  9. Write First register (1) and Write Register count (10).
  10. Enable the request and you can test it through request configuration testing section.
  11. Press Networking save apply button fw76 v1.png button.

Modbus Serial RUT955 3.png Modbus Serial RUT955 4.png

Modbus data to server

Creating server


In order to test the functionality, you will need to set up a server (you can run a server on the same computer you use as a slave simulator).

There are many ways how you can create a server to which Modbus will send data to. In this example we are going to be using Windows 10 computer and Hercules app, which you can download here, to create a test server. Download, install the app and apply the configuration below:

Modbus serial rut955 5.png
  1. Select TCP Server tab.
  2. Enter Port (In this example default 80 is used).
  3. Click Listen

And that is it, now you will be able to see the data coming from Modbus in the Received data section.

RUT Modbus data to server configuration


In order to setup your router to send Modbus data to server you will need to navigate to Services → Data to Server, create a "New collectiom name" and press ADD to add a new instance.

  1. Select Type: Modbus;
  2. Select Format Type: Custom;
  3. Enter desired format string;
  4. Leave other parameterms as it is and click on Next Collection.png icon;
  5. In the Collection configuration window leave the settings as default and click on Next Server.png button;
  6. In the Server configuration window select Type: HTTP;
  7. Enter Server address;
  8. Click Networking save apply button fw76 v1.png;

Modbus Serial RUT955 6.png Modbus Serial RUT955 8.png

Receiving data


Open Hercules again, press Listen and you should start receiving Modbus Data messages. Modbus serial rut955 9.png

Try to change some data in the Modbus Slave simulator.

Modbus serial rut955 10.png

Received data should change.

Modbus serial rut955 11.png

Slave alarms

In order to setup the following configuration SIM card is required.

Go back to Services → Modbus → Modbus Serial Client and press Networking edit button fw76 v1.png button on the previously created Modbus slave Device instance or create a new one. In the opened window scroll down to the bottom and in Alarms Configuration section press Add Button.png.

In Alarm Configuration apply the following changes:

Modbus Serial RUT955 10.png
  1. Enable instance.
  2. Select Function (Read Holding Registers).
  3. Write Register (1).
  4. Select Condition (More than).
  5. Write Value (10).
  6. Select Action frequency (First trigger)
  7. Select Action (SMS).
  8. Create Message (type anything you want to receive).
  9. Write Phone number (the number you want to receive the messages to).
  10. Press Networking save apply button fw76 v1.png button.

Now go back to Modbus slave simulator and edit this window:

Modbus serial rut955 14.png

Change the value to anything below 10, you should not receive messages. Then change the value to anything above 10, you should start receiving messages.

Modbus serial rut955 15.png