Jump to content

Template:Networking rutos manual modbus: Difference between revisions

no edit summary
No edit summary
No edit summary
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:Networking_rutos_manual_fw_disclosure
{{Template: Networking_rutos_manual_fw_disclosure
| fw_version = {{{series}}}_R_00.02.05
| fw_version = {{{series}}}_R_00.07.01
| series    = {{{series}}}
| series    = {{{series}}}
}}
}}
 
{{#ifeq: {{{series}}} | RUT9 |<br><i><b>Note</b>: <b>[[{{{name}}} Modbus (legacy WebUI)|click here]]</b> for the old style WebUI (FW version RUT9XX_R_00.06.08.3 and earlier) user manual page.</i>|}}
{{#ifeq: {{{series}}} | RUT2 |<br><i><b>Note</b>: <b>[[{{{name}}} Modbus (legacy WebUI)|click here]]</b> for the old style WebUI (FW version RUT2XX_R_00.01.14.1 and earlier) user manual page.</i>|}}
==Summary==
==Summary==


Line 9: Line 10:


This manual page provides an overview of the Modbus functionality in {{{name}}} devices.
This manual page provides an overview of the Modbus functionality in {{{name}}} devices.
{{#switch: {{{series}}}
| RUTX =
| TRB1 =
| TRB2 =
| RUT9 =
| #default =
<u><b>


Note:</b> On {{{name}}}, Modbus TCP Slave/Master and MQTT Gateway is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u><br>}}
{{Template:Networking_rutos_manual_basic_advanced_webui_disclaimer
{{Template:Networking_rutos_manual_basic_advanced_webui_disclaimer
| series = {{{series}}}
| series = {{{series}}}
Line 30: Line 39:
     <tr>
     <tr>
       <td>Enable</td>
       <td>Enable</td>
       <td>off | on; default: <b>none</b></td>
       <td>off | on; default: <b>off</b></td>
       <td>Turns Modbus TCP on or off.</td>
       <td>Turns Modbus TCP on or off.</td>
     </tr>
     </tr>
Line 71: Line 80:
|analog = {{{analog}}}
|analog = {{{analog}}}
|gps = {{{gps}}}
|gps = {{{gps}}}
|dualsim = {{{dualsim}}}
}}
}}


{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table  
{{Template:Networking_rutos_manual_modbus_modbus_tcp_set_parameters_table  
|wifi={{{wifi}}}
|wifi = {{{wifi}}}
|mobile={{{mobile}}}
|mobile = {{{mobile}}}
|series={{{series}}}
|series = {{{series}}}
|name={{{name}}}
|name = {{{name}}}
|dualsim = {{{dualsim}}}
}}
}}
==Modbus TCP Master==
==Modbus TCP Master==
Line 199: Line 210:
</table>
</table>


<b>Additional note:</b>By default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:
<b>Additional note:</b> by default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
Line 272: Line 283:
     <tr>
     <tr>
         <td>Action</td>
         <td>Action</td>
         <td>SMS | MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>Action that will be taken if the condition is met. Possible actions:
         <td>Action that will be taken if the condition is met. Possible actions:
             <ul>
             <ul>{{#ifeq: {{{mobile}}} | 1 |
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
             </ul>
             </ul>
         </td>
         </td>
     </tr>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
Line 289: Line 300:
         <td>phone number; default: <b>none</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>Recipient's phone number.</td>
         <td>Recipient's phone number.</td>
     </tr>
     </tr>|}}
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
         <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
Line 330: Line 341:


The <b>Modbus Serial Master</b> page is used to configure the device as a Modbus RTU Master. Modbus RTU (remote terminal unit) is a serial communication protocol mainly used in communication via serial interfaces.
The <b>Modbus Serial Master</b> page is used to configure the device as a Modbus RTU Master. Modbus RTU (remote terminal unit) is a serial communication protocol mainly used in communication via serial interfaces.
<u><b>Note:</b> Modbus Serial Master is additional software that can be installed from the <b>Services → [[{{{name}}} Package Manager|Package Manager]]</b> page.</u>
{{#ifeq: {{{rs232}}} | 1 |
{{#ifeq: {{{rs232}}} | 1 |
===RS232===
===RS232===
Line 436: Line 449:
     </tr>
     </tr>
</table>
</table>
====Requests Configuration====
=====Requests Configuration=====
----
----
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
Line 461: Line 474:
     <tr>
     <tr>
         <td>Data type</td>
         <td>Data type</td>
         <td>8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float, Byte order 1,2,3,4 | 32bit float, Byte order 4,3,2,1 | 32bit float, Byte order 2,1,4,3 | 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
         <td>8bit INT <nowiki>|</nowiki> 8bit UINT <nowiki>|</nowiki> 16bit INT, high byte first <nowiki>|</nowiki> 16bit INT, low byte first <nowiki>|</nowiki> 16bit UINT, high byte first <nowiki>|</nowiki> 16bit UINT, low byte first <nowiki>|</nowiki> 32bit float, Byte order 1,2,3,4 <nowiki>|</nowiki> 32bit float, Byte order 4,3,2,1 <nowiki>|</nowiki> 32bit float, Byte order 2,1,4,3 <nowiki>|</nowiki> 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
         <td>Defines how read data will be stored.</td>
         <td>Defines how read data will be stored.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function</td>
         <td>Function</td>
         <td>Read coils (1) | Read input coils (2) | Read holding registers (3) | Read input registers (4) | Set single coil (5) | Set single coil register (6) | Set multiple coils (15) | Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
         <td>Read coils (1) <nowiki>|</nowiki> Read input coils (2) <nowiki>|</nowiki> Read holding registers (3) <nowiki>|</nowiki> Read input registers (4) <nowiki>|</nowiki> Set single coil (5) <nowiki>|</nowiki> Set single coil register (6) <nowiki>|</nowiki> Set multiple coils (15) <nowiki>|</nowiki> Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
         <td>Specifies the type of register being addressed by a Modbus request.  
         <td>Specifies the type of register being addressed by a Modbus request.  
         </td>
         </td>
Line 482: Line 495:
     <tr>
     <tr>
         <td>No Brackets</td>
         <td>No Brackets</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
     </tr>
     </tr>
Line 492: Line 505:
     <tr>
     <tr>
         <td>off/on slider</td>
         <td>off/on slider</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns the request on or off.</td>
         <td>Turns the request on or off.</td>
     </tr>
     </tr>
</table>
</table>


<b>Additional note:</b>By default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:
<b>Additional note:</b> by default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
Line 505: Line 518:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]


====Alarms Configuration====
=====Modbus Master Alarms=====
----
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus TCP Master (this {{{name}}} device) requests some information from a slave device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
 
The figure below is an example of the Modbus Master Alarms list. To create a new Alarm, click the 'Add' button.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_add_button.png|border|class=tlt-border]]


The figure below is an example of the Alarms Configuration list. To create a new Alarm, click the 'Add' button.
Then click the 'Edit' button next to the newly created Alarm to configuration.


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_add_button.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_edit_button.png|border|class=tlt-border]]


After adding the Alarm you should be redirected to its configuration page which should look similar to this:
After this you should be redirected to that Alarm's configuration page which should look similar to this:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_alarm_configuration.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 525: Line 542:
     <tr>
     <tr>
         <td>Enabled</td>
         <td>Enabled</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns the alarm on or off.</td>
         <td>Turns the alarm on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function code</td>
         <td>Function code</td>
         <td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Read Coil Status (1) <nowiki>|</nowiki> Read Input Status (2) <nowiki>|</nowiki> Read Holding Registers (3) <nowiki>|</nowiki> Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS232_Slave_Device_Configuration|RS232 Slave Device Configuration]].</td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS485_Slave_Device_Configuration|RS485 Slave Device Configuration]].</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 540: Line 557:
     <tr>
     <tr>
         <td>Condition</td>
         <td>Condition</td>
         <td>More than | Less than | Equal to | Not Equal to; default: <b>Equal to</b></td>
         <td>More than <nowiki>|</nowiki> Less than <nowiki>|</nowiki> Equal to <nowiki>|</nowiki> Not Equal to; default: <b>Equal to</b></td>
         <td>When a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.</td>
         <td>When a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.</td>
     </tr>
     </tr>
Line 555: Line 572:
     <tr>
     <tr>
         <td>Action frequency</td>
         <td>Action frequency</td>
         <td>Every trigger | First trigger; default: <b>Every trigger</b></td>
         <td>Every trigger <nowiki>|</nowiki> First trigger; default: <b>Every trigger</b></td>
         <td>Describes how frequently the specified action will be taken.</td>
         <td>Describes how frequently the specified action will be taken.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Redundancy protection</td>
         <td>Redundancy protection</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Protection against executing a configured action too often.</td>
         <td>Protection against executing a configured action too often.</td>
     </tr>
     </tr>
Line 570: Line 587:
     <tr>
     <tr>
         <td>Action</td>
         <td>Action</td>
         <td>SMS | MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>{{#ifeq:{{{mobile}}}|1|SMS {{!}}|}} MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>Action that will be taken if the condition is met. Possible actions:
         <td>Action that will be taken if the condition is met. Possible actions:
             <ul>
             <ul>{{#ifeq: {{{mobile}}} | 1 |
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>
                 <li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li>|}}
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
                 <li><b>Modbus Request</b> - sends a Modbus Write request to a specified slave.</li>
             </ul>
             </ul>
         </td>
         </td>
     </tr>
     </tr>{{#ifeq: {{{mobile}}} | 1 |
     <tr>
     <tr>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
         <td><span style="color: #0054a6;">SMS: Message</span></td>
Line 587: Line 604:
         <td>phone number; default: <b>none</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>Recipient's phone number.</td>
         <td>Recipient's phone number.</td>
     </tr>
     </tr>|}}
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
        <td>ip | host; default: <b>none</b></td>
        <td>Modbus slave's IP address.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: Port</span></td>
        <td>integer [0..65535]; default: <b>none</b></td>
        <td>Modbus slave's port.</td>
    </tr>
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
         <td><span style="color: purple;">MODBUS Write Request: Timeout</span></td>
Line 610: Line 617:
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>Read Force Single Coil (5) | Preset Single Register (6) | Force Multiple Coils (15) | Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
         <td>Read Force Single Coil (5) <nowiki>|</nowiki> Preset Single Register (6) <nowiki>|</nowiki> Force Multiple Coils (15) <nowiki>|</nowiki> Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
     </tr>
     </tr>
Line 625: Line 632:
</table>
</table>
|}}|}}{{#ifeq: {{{rs485}}} | 1 |
|}}|}}{{#ifeq: {{{rs485}}} | 1 |
===RS485===
<h3>RS485</h3>
----
----
This section is used to configure the Modbus Serial Master's <b>RS485</b> serial interface settings. Refer to the figure and table below for information on RS485 configuration.
This section is used to configure the Modbus Serial Master's <b>RS485</b> serial interface settings. Refer to the figure and table below for information on RS485 configuration.
Line 640: Line 647:
         <td>Enabled</td>
         <td>Enabled</td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns Modbus Serial Master configuration via RS232 on or off. Both this and RS232 from Services → [[{{{name}}} RS232|RS232]] cannot be enabled at the same time.</td>
         <td>Turns Modbus Serial Master configuration via RS485 on or off. Both this and RS485 from Services → [[{{{name}}} RS485|RS485]] cannot be enabled at the same time.</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 730: Line 737:
     </tr>
     </tr>
</table>
</table>
====Requests Configuration====
=====Requests Configuration=====
----
----
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
A Modbus <b>request</b> is a way of obtaining data from Modbus slaves. The master sends a request to a slave specifying the function code to be performed. The slave then sends the requested data back to the Modbus master. You can create a maximum of 64 request configurations for each slave device.
Line 755: Line 762:
     <tr>
     <tr>
         <td>Data type</td>
         <td>Data type</td>
         <td>8bit INT | 8bit UINT | 16bit INT, high byte first | 16bit INT, low byte first | 16bit UINT, high byte first | 16bit UINT, low byte first | 32bit float, Byte order 1,2,3,4 | 32bit float, Byte order 4,3,2,1 | 32bit float, Byte order 2,1,4,3 | 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
         <td>8bit INT <nowiki>|</nowiki> 8bit UINT <nowiki>|</nowiki> 16bit INT, high byte first <nowiki>|</nowiki> 16bit INT, low byte first <nowiki>|</nowiki> 16bit UINT, high byte first <nowiki>|</nowiki> 16bit UINT, low byte first <nowiki>|</nowiki> 32bit float, Byte order 1,2,3,4 <nowiki>|</nowiki> 32bit float, Byte order 4,3,2,1 <nowiki>|</nowiki> 32bit float, Byte order 2,1,4,3 <nowiki>|</nowiki> 32bit float, Byte order 3,4,1,2; default: <b>16bit INT, high byte first</b></td>
         <td>Defines how read data will be stored.</td>
         <td>Defines how read data will be stored.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function</td>
         <td>Function</td>
         <td>Read coils (1) | Read input coils (2) | Read holding registers (3) | Read input registers (4) | Set single coil (5) | Set single coil register (6) | Set multiple coils (15) | Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
         <td>Read coils (1) <nowiki>|</nowiki> Read input coils (2) <nowiki>|</nowiki> Read holding registers (3) <nowiki>|</nowiki> Read input registers (4) <nowiki>|</nowiki> Set single coil (5) <nowiki>|</nowiki> Set single coil register (6) <nowiki>|</nowiki> Set multiple coils (15) <nowiki>|</nowiki> Set multiple holding registers (16); default: <b>Read holding registers (3)</b></td>
         <td>Specifies the type of register being addressed by a Modbus request.  
         <td>Specifies the type of register being addressed by a Modbus request.  
         </td>
         </td>
Line 776: Line 783:
     <tr>
     <tr>
         <td>No Brackets</td>
         <td>No Brackets</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
         <td>Removes the starting and ending brackets from the request (only for read requests).</td>
     </tr>
     </tr>
Line 786: Line 793:
     <tr>
     <tr>
         <td>off/on slider</td>
         <td>off/on slider</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns the request on or off.</td>
         <td>Turns the request on or off.</td>
     </tr>
     </tr>
</table>
</table>


<b>Additional note:</b>By default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:
<b>Additional note:</b> by default the newly added Request Configurations are turned off. You can use the on/off slider to the right of the Request Configuration to turn it on:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_on_off_slider.png|border|class=tlt-border]]
Line 799: Line 806:
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_tcp_master_requests_configuration_testing.png|border|class=tlt-border]]


====Alarms Configuration====
=====Modbus Master Alarms=====
----
----
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus TCP Master (this {{{name}}} device) requests some information from a slave device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
<b>Alarms</b> are a way of setting up automated actions when some Modbus values meet user-defined conditions. When the Modbus Serial Master (this {{{name}}} device) requests some information from a slave device it compares that data to with the parameters set in an Alarm Configuration. If the comparison meets the specified condition (more than, less than, equal to, not equal to), the Master performs a user-specified action, for example, a Modbus write request or switching the state of an output.
 
The figure below is an example of the Modbus Master Alarms list. To create a new Alarm, click the 'Add' button.
 
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_add_button.png|border|class=tlt-border]]


The figure below is an example of the Alarms Configuration list. To create a new Alarm, click the 'Add' button.
Then click the 'Edit' button next to the newly created Alarm to configuration.


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration_add_button.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_edit_button.png|border|class=tlt-border]]


After adding the Alarm you should be redirected to its configuration page which should look similar to this:
After this you should be redirected to that Alarm's configuration page which should look similar to this:


[[File:Networking_rutos_manual_modbus_modbus_tcp_master_alarms_configuration.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_modbus_serial_master_modbus_master_alarms_alarm_configuration.png|border|class=tlt-border]]


<table class="nd-mantable">
<table class="nd-mantable">
Line 819: Line 830:
     <tr>
     <tr>
         <td>Enabled</td>
         <td>Enabled</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Turns the alarm on or off.</td>
         <td>Turns the alarm on or off.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Function code</td>
         <td>Function code</td>
         <td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Read Coil Status (1) <nowiki>|</nowiki> Read Input Status (2) <nowiki>|</nowiki> Read Holding Registers (3) <nowiki>|</nowiki> Read Input Registers (4); default: <b>Read Coil Status (1)</b></td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS485_Slave_Device_Configuration|RS485 Slave Device Configuration]].</td>
         <td>Modbus function used for this alarm's Modbus request. The Modbus TCP Master (this {{{name}}} device) perform this request as often as specified in the 'Period' field in [[#RS485_Slave_Device_Configuration|RS485 Slave Device Configuration]].</td>
     </tr>
     </tr>
Line 834: Line 845:
     <tr>
     <tr>
         <td>Condition</td>
         <td>Condition</td>
         <td>More than | Less than | Equal to | Not Equal to; default: <b>Equal to</b></td>
         <td>More than <nowiki>|</nowiki> Less than <nowiki>|</nowiki> Equal to <nowiki>|</nowiki> Not Equal to; default: <b>Equal to</b></td>
         <td>When a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.</td>
         <td>When a value is obtained it will be compared against the value specified in the following field. The comparison will be made in accordance with the condition specified in this field.</td>
     </tr>
     </tr>
Line 849: Line 860:
     <tr>
     <tr>
         <td>Action frequency</td>
         <td>Action frequency</td>
         <td>Every trigger | First trigger; default: <b>Every trigger</b></td>
         <td>Every trigger <nowiki>|</nowiki> First trigger; default: <b>Every trigger</b></td>
         <td>Describes how frequently the specified action will be taken.</td>
         <td>Describes how frequently the specified action will be taken.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Redundancy protection</td>
         <td>Redundancy protection</td>
         <td>off | on; default: <b>off</b></td>
         <td>off <nowiki>|</nowiki> on; default: <b>off</b></td>
         <td>Protection against executing a configured action too often.</td>
         <td>Protection against executing a configured action too often.</td>
     </tr>
     </tr>
Line 864: Line 875:
     <tr>
     <tr>
         <td>Action</td>
         <td>Action</td>
         <td>SMS | MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>SMS <nowiki>|</nowiki> MODBUS Write Request; default: <b>MODBUS Write Request</b></td>
         <td>Action that will be taken if the condition is met. Possible actions:
         <td>Action that will be taken if the condition is met. Possible actions:
             <ul>
             <ul>
Line 881: Line 892:
         <td>phone number; default: <b>none</b></td>
         <td>phone number; default: <b>none</b></td>
         <td>Recipient's phone number.</td>
         <td>Recipient's phone number.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: IP address</span></td>
        <td>ip | host; default: <b>none</b></td>
        <td>Modbus slave's IP address.</td>
    </tr>
    <tr>
        <td><span style="color: purple;">MODBUS Write Request: Port</span></td>
        <td>integer [0..65535]; default: <b>none</b></td>
        <td>Modbus slave's port.</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 904: Line 905:
     <tr>
     <tr>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td><span style="color: purple;">MODBUS Write Request: Modbus function</span></td>
         <td>Read Force Single Coil (5) | Preset Single Register (6) | Force Multiple Coils (15) | Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
         <td>Read Force Single Coil (5) <nowiki>|</nowiki> Preset Single Register (6) <nowiki>|</nowiki> Force Multiple Coils (15) <nowiki>|</nowiki> Force Multiple Registers (16); default: <b>Force Single Coil (5)</b></td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
         <td>A function code specifies the type of register being addressed by a Modbus request.</td>
     </tr>
     </tr>
Line 918: Line 919:
     </tr>
     </tr>
</table>
</table>
|}}|}}
|}}
 
==MQTT Gateway==
==MQTT Gateway==


The <b>MQTT Gateway</b> function is used to transfer Modbus data over MQTT. Refer to the table for information on MQTT Gateway configuration fields.
The <b>MQTT Gateway</b> function is used to transfer Modbus data (send requests, receive responses) over MQTT. When it is enabled, the device (this {{{name}}}) subscribes to a REQUEST topic and publishes on a RESPONSE topic on a specified MQTT broker. It translates received MQTT message payload to a Modbus request and relays it to the specified Modbus TCP slave.
 
When the MQTT Gateway receives a response from the slave, it translates it to an MQTT message and publishes it on the RESPONSE topic.
 
[[File:Networking_rutos_manual_modbus_mqtt_gateway_scheme.png]]
 
Below is an example of the MQTT Gateway page. Refer to the table for information on MQTT Gateway configuration fields.


[[File:Networking_rutos_manual_modbus_mqtt_gateway.png|border|class=tlt-border]]
[[File:Networking_rutos_manual_modbus_mqtt_gateway.png|border|class=tlt-border]]
Line 949: Line 957:
         <td>Request topic</td>
         <td>Request topic</td>
         <td>alphanumeric string; default: <b>request</b></td>
         <td>alphanumeric string; default: <b>request</b></td>
         <td>.</td>
         <td>MQTT topic for sending requests.</td>
     </tr>
     </tr>
     <tr>
     <tr>
         <td>Response topic</td>
         <td>Response topic</td>
         <td>alphanumeric string; default: <b>response</b></td>
         <td>alphanumeric string; default: <b>response</b></td>
         <td>.</td>
         <td>MQTT topic for subscribing to responses.</td>
     </tr>
     </tr>
     <tr>
     <tr>
Line 967: Line 975:
     </tr>
     </tr>
</table>
</table>
===Request messages===
----
Modbus request data sent in the MQTT payload should be generated in accordance with the following format:
<b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <REGISTER_NUMBER> <REGISTER_COUNT/VALUE></b>
Explanation:
<ul>
    <li><b>0</b> - must be 0, which signifies a textual format (currently the only one implemented).</li>
    <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>]). A cookie is used in order to distinguish which response belongs to which request, each request and the corresponding response contain a matching cookie: a 64-bit unsigned integer.</li>
    <li><b>IP type</b> - host IP address type. Possible values:
        <ul>
            <li><b>0</b> - IPv4 address;</li>
            <li><b>1</b> - IPv6 address;</li>
            <li><b>2</b> - hostname that will be resolved to an IP address.</li>
        </ul></li>
    <li><b>IP</b> - IP address of a Modbus TCP slave. IPv6 must be presented in full form (e.g., <i>2001:0db8:0000:0000:0000:8a2e:0370:7334</i>).</li>
    <li><b>Port</b> - port number of the Modbus TCP slave.</li>
    <li><b>Timeout</b> - timeout for Modbus TCP connection, in seconds. Range [1..999].</li>
    <li><b>Slave ID</b> - Modbus TCP slave ID. Range [1..255].</li>
    <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are:
        <ul>
            <li><b>3</b> - read holding registers;</li>
            <li><b>6</b> - write to a single holding register;</li>
            <li><b>16</b> - write to multiple holding registers.</li>
        </ul></li>
    <li><b>Register number</b> - number of the first register (in range [1..65536]) from which the registers will be read/written to.
    <li><b>Register count/value</b> - this value depends on the Modbus function:
        <ul>
            <li><b>3</b> - <u>register count</u> (in range [1..125]); must not exceed the boundary (first register number + register count <= 65537);</li>
            <li><b>6</b> - <u>register value</u> (in range [0..65535]);</li>
            <li><b>16</b> - <u>register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].</li>
        </ul></li>
</ul>
===Response messages===
----
A special response message can take one of the following forms:
<COOKIE> OK                              - <i>for functions 6 and 16</i>
<COOKIE> OK <VALUE> <VALUE> <VALUE>...  - <i>for function 3, where <VALUE> <VALUE> <VALUE>... are read register values</i>
<COOKIE> ERROR: ...                      - <i>for failures, where ... is the error description</i>
===Examples===
----
Below are a few <b>examples</b> of controlling/monitoring the internal Modbus TCP Slave on {{{name}}}.
----
<b>Reboot the device</b>
<ul>
    <li>Request:<br><pre>0 65432 0 192.168.1.1 502 5 1 6 206 1</pre></li>
    <li>Response:<br><pre>65432 OK</pre></li>
</ul>
----
<b>Retrieve uptime</b>
<ul>
    <li>Request:<br><pre>0 65432 0 192.168.1.1 502 5 1 3 2 2</pre></li>
    <li>Response:<br><pre>65432 OK 0 5590</pre></li>
</ul>
----
If you're using Eclipse Mosquitto (MQTT implementation used on {{{name}}}), Publish/Subscribe commands may look something like this:
<b>Retrieve uptime</b>
<ul>
    <li>Request:<br><pre>mosquitto_pub -h 192.168.1.1 -p 1883 -t request -m "0 65432 0 192.168.1.1 502 5 1 3 2 2"</pre></li>
    <li>Response:<br><pre>mosquitto_sub -h 192.168.1.1 -p 1883 -t response
65432 OK 0 5590</pre></li>
</ul>


==See also==
==See also==


{{Template: Networking_device_modbus_see_also}}
<ul>
    <li><b>[[{{{name}}} Monitoring via Modbus|Monitoring via Modbus]]</b> - detailed examples on how to use Modbus TCP</li>
</ul>


[[Category:{{{name}}} Services section]]
[[Category:{{{name}}} Services section]]