31,703
edits
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==Summary== | ==Summary== | ||
<b>Modbus</b> is a serial communications protocol. Simple and robust, it has since become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. This chapter is an overview of the Modbus TCP functionality. | |||
{{Template: Networking_rutxxx_manual_fw_disclosure | |||
| fw_version = {{{fw_version}}} | |||
}} | |||
==Modbus TCP== | ==Modbus TCP== | ||
<b>Modbus TCP</b> provides users with the possibility to set or get system parameters. The Modbus daemon acts as slave device. That means it accepts connections from a master (client) and sends out a response or sets some system related parameter in accordance with the given query. | |||
The figure below is an example of the Modbus TCP window section and the table below provides information on the fields contained in that window: | The figure below is an example of the Modbus TCP window section and the table below provides information on the fields contained in that window: | ||
Line 18: | Line 22: | ||
===Get Parameters=== | ===Get Parameters=== | ||
---- | ---- | ||
Modbus parameters are held within | Modbus parameters are held within <b>registers</b>. Each register contains 2 bytes of information. For simplification, the number of registers for storing numbers is 2 (4 bytes), while the number of registers for storing text information is 16 (32 bytes). The register numbers and corresponding system values are described in the table below: | ||
<br> <br> | <br> <br> | ||
{{#ifeq: {{{series}}} | RUT2xx | {{#ifeq: {{{series}}} | RUT2xx | ||
Line 37: | Line 41: | ||
}} | }} | ||
<span class="asterisk">*</span> All ON/OFF commands only accept | <span class="asterisk">*</span> All ON/OFF commands only accept <b>0</b> and <b>1</b> values, which represent the following: | ||
<ul> | <ul> | ||
<li>1 - ON</li> | <li>1 - ON</li> | ||
Line 81: | Line 85: | ||
<table class="nd-mantable"> | <table class="nd-mantable"> | ||
<tr> | <tr> | ||
<th>Field | <th>Field</th> | ||
<th>Value</th> | <th>Value</th> | ||
<th>Description</th> | <th>Description</th> | ||
Line 87: | Line 91: | ||
<tr> | <tr> | ||
<td>Enabled</td> | <td>Enabled</td> | ||
<td>yes | no; | <td>yes | no; default: <b>no</b></td> | ||
<td>Turns communication with the slave device | <td>Turns communication with the slave device on or off.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Name</td> | <td>Name</td> | ||
<td>string; | <td>string; default: <b>none</b></td> | ||
<td>Slave device | <td>Slave device's name, used for easier management purposes.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Slave ID</td> | <td>Slave ID</td> | ||
<td>integer [ | <td>integer [0..255]; default: <b>none</b></td> | ||
<td>Slave ID. Each slave in a network is assigned a unique identifier | <td>Slave ID. Each slave in a network is assigned a unique identifier ranging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID. When set to 0, the slave will respond to requests addressed to any ID.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>IP address</td> | <td>IP address</td> | ||
<td>ip; | <td>ip; default: <b>none</b></td> | ||
<td>Slave device IP address</td> | <td>Slave device's IP address.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Port</td> | <td>Port</td> | ||
<td>integer [0..65535]; | <td>integer [0..65535]; default: <b>none</b></td> | ||
<td>Slave device Modbus TCP port</td> | <td>Slave device's Modbus TCP port.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Period</td> | <td>Period</td> | ||
<td>integer [1..6400]; | <td>integer [1..6400]; default: <b>none</b></td> | ||
<td>Interval at which requests are sent to the slave device</td> | <td>Interval at which requests are sent to the slave device.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Timeout</td> | <td>Timeout</td> | ||
<td>integer [1..30]; | <td>integer [1..30]; default: <b>none</b></td> | ||
<td>Maximum response wait time</td> | <td>Maximum response wait time.</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Line 202: | Line 206: | ||
<table class="nd-mantable"> | <table class="nd-mantable"> | ||
<tr> | <tr> | ||
<th>Field | <th>Field</th> | ||
<th>Value</th> | <th>Value</th> | ||
<th>Description</th> | <th>Description</th> | ||
Line 208: | Line 212: | ||
<tr> | <tr> | ||
<td>Enabled</td> | <td>Enabled</td> | ||
<td>yes | no; | <td>yes | no; default: <b>no</b></td> | ||
<td>Turns the alarm | <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); | <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>Modbus function used in Modbus request</td> | <td>Modbus function used in Modbus request.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Register</td> | <td>Register</td> | ||
<td>integer [0..65535]; | <td>integer [0..65535]; default: <b>none</b></td> | ||
<td>Number of the | <td>Number of the Modbus coil/input/holding register/input register that will be read.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Condition</td> | <td>Condition</td> | ||
<td>More than | Less than | Equal to | Not Equal to; | <td>More than | Less than | Equal to | 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 | <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> | ||
<tr> | <tr> | ||
<td>Value</td> | <td>Value</td> | ||
<td>various; | <td>various; default: <b>none</b></td> | ||
<td>The value against which the read data will be compared</td> | <td>The value against which the read data will be compared.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>Action</td> | <td>Action</td> | ||
<td>SMS | Trigger output | Modbus Request; | <td>SMS | Trigger output | Modbus Request; default: <b>SMS</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> | ||
<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>Trigger output</b> - changes the state of a specified output(s)</li> | <li><b>Trigger output</b> - changes the state of a specified output(s).</li> | ||
<li><b>Modbus Request</b> - sends a Modbus request to a specified slave</li> | <li><b>Modbus Request</b> - sends a Modbus request to a specified slave.</li> | ||
</ul> | </ul> | ||
</td> | </td> | ||
Line 244: | Line 248: | ||
<tr> | <tr> | ||
<td><span style="color: #0054a6;">SMS: Message</span></td> | <td><span style="color: #0054a6;">SMS: Message</span></td> | ||
<td>string; | <td>string; default: <b>none</b></td> | ||
<td>SMS message text</td> | <td>SMS message text.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: #0054a6;">SMS: Phone number</span></td> | <td><span style="color: #0054a6;">SMS: Phone number</span></td> | ||
<td>phone number; | <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: red;">Trigger output: Output</span></td> | <td><span style="color: red;">Trigger output: Output</span></td> | ||
<td>Open collector output | Relay output | Both; | <td>Open collector output | Relay output | Both; default: <b>Open collector output</b></td> | ||
<td>Which output(s) will be triggered</td> | <td>Which output(s) will be triggered.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: red;">Trigger output: I/O Action</span></td> | <td><span style="color: red;">Trigger output: I/O Action</span></td> | ||
<td>Turn On | Turn Off | Invert; | <td>Turn On | Turn Off | Invert; default: <b>Turn On</b></td> | ||
<td>Action that will taken on the specified output</td> | <td>Action that will taken on the specified output.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: IP address</span></td> | <td><span style="color: purple;">Modbus Request: IP address</span></td> | ||
<td>ip | host; | <td>ip | host; default: <b>none</b></td> | ||
<td>Modbus slave's IP address</td> | <td>Modbus slave's IP address.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: Port</span></td> | <td><span style="color: purple;">Modbus Request: Port</span></td> | ||
<td>integer [0..65535]; | <td>integer [0..65535]; default: <b>none</b></td> | ||
<td>Modbus slave's port</td> | <td>Modbus slave's port.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: Timeout</span></td> | <td><span style="color: purple;">Modbus Request: Timeout</span></td> | ||
<td>integer [1..30]; | <td>integer [1..30]; default: <b>5</b></td> | ||
<td>Maximum time to wait for a response</td> | <td>Maximum time to wait for a response.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: ID</span></td> | <td><span style="color: purple;">Modbus Request: ID</span></td> | ||
<td>integer [1..255]; | <td>integer [1..255]; default: <b>none</b></td> | ||
<td>Modbus slave ID</td> | <td>Modbus slave ID.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: Modbus function</span></td> | <td><span style="color: purple;">Modbus Request: Modbus function</span></td> | ||
<td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4) | Force Single Coil (5) | Preset Single Register (6) | Force Multiple Coils (15) | Force Multiple Registers (16); | <td>Read Coil Status (1) | Read Input Status (2) | Read Holding Registers (3) | Read Input Registers (4) | 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>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> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: First register</span></td> | <td><span style="color: purple;">Modbus Request: First register</span></td> | ||
<td>integer [0..65535]; | <td>integer [0..65535]; default: <b>none</b></td> | ||
<td>Begins reading from the register specified in this field</td> | <td>Begins reading from the register specified in this field.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><span style="color: purple;">Modbus Request: Number of registers</span></td> | <td><span style="color: purple;">Modbus Request: Number of registers</span></td> | ||
<td>integer [0..65535]; | <td>integer [0..65535]; default: <b>none</b></td> | ||
<td>The number of registers that will be read from the first register</td> | <td>The number of registers that will be read from the first register.</td> | ||
</tr> | |||
</table> | |||
==Modbus Serial Master== | |||
===RS232=== | |||
---- | |||
[[File:{{{file_rs232}}}]] | |||
<table class="nd-mantable"> | |||
<tr> | |||
<th>Field</th> | |||
<th>Value</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>Enabled</td> | |||
<td>yes | no; default: <b>no</b></td> | |||
<td>Turns the Modbus RTU via RS232 on or off.</td> | |||
</tr> | |||
<tr> | |||
<td>Baud rate</td> | |||
<td>300 | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 | 57600 | 115200; default: <b>19200</b></td> | |||
<td>Serial data transmission rate (in bits per second).</td> | |||
</tr> | |||
<tr> | |||
<td>Data bits</td> | |||
<td>5 | 6 | 7 | 8; default: <b>8</b></td> | |||
<td>Number of data bits of each character.</td> | |||
</tr> | |||
<tr> | |||
<td>Parity</td> | |||
<td>None | Even | Odd; default: <b>Even</b></td> | |||
<td>In serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check. | |||
<ul> | |||
<li><b>None</b> (<b>N</b>) - no parity method is used.</li> | |||
<li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li> | |||
<li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>Stop bits</td> | |||
<td>1 | 2; default: <b>1</b></td> | |||
<td>Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.</td> | |||
</tr> | |||
<tr> | |||
<td>Flow control</td> | |||
<td>None | RTS/CTS | Xon/Xoff; default: <b>None</b></td> | |||
<td>In many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking. | |||
<ul> | |||
<li><b>RTS/CTS</b> - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.</li> | |||
<li><b>Xon/Xoff</b> - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
</table> | |||
===RS485=== | |||
---- | |||
[[File:{{{file_rs485}}}]] | |||
<table class="nd-mantable"> | |||
<tr> | |||
<th>Field</th> | |||
<th>Value</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>Enabled</td> | |||
<td>yes | no; default: <b>no</b></td> | |||
<td>Turns the Modbus RTU via RS485 on or off.</td> | |||
</tr> | |||
<tr> | |||
<td>Baud rate</td> | |||
<td>300 | 1200 | 2400 | 4800 | 9600 | 19200 | 38400 | 57600 | 115200; default: <b>19200</b></td> | |||
<td>Serial data transmission rate (in bits per second).</td> | |||
</tr> | |||
<tr> | |||
<td>Data bits</td> | |||
<td>5 | 6 | 7 | 8; default: <b>8</b></td> | |||
<td>Number of data bits of each character.</td> | |||
</tr> | |||
<tr> | |||
<td>Parity</td> | |||
<td>None | Even | Odd; default: <b>Even</b></td> | |||
<td>In serial transmission, parity is a method of detecting errors. An extra data bit is sent with each data character, arranged so that the number of 1 bits in each character, including the parity bit, is always odd or always even. If a byte is received with the wrong number of 1s, then it must have been corrupted. However, an even number of errors can pass the parity check. | |||
<ul> | |||
<li><b>None</b> (<b>N</b>) - no parity method is used.</li> | |||
<li><b>Odd</b> (<b>O</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be odd.</li> | |||
<li><b>Even</b> (<b>E</b>) - the parity bit is set so that the number of "logical ones (1s)" has to be even.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>Stop bits</td> | |||
<td>1 | 2; default: <b>1</b></td> | |||
<td>Stop bits sent at the end of every character allow the receiving signal hardware to detect the end of a character and to resynchronise with the character stream. Electronic devices usually use one stop bit. Two stop bits are required if slow electromechanical devices are used.</td> | |||
</tr> | |||
<tr> | |||
<td>Flow control</td> | |||
<td>None | RTS/CTS | Xon/Xoff; default: <b>None</b></td> | |||
<td>In many circumstances a transmitter might be able to send data faster than the receiver is able to process it. To cope with this, serial lines often incorporate a "handshaking" method, usually distinguished between hardware and software handshaking. | |||
<ul> | |||
<li><b>RTS/CTS</b> - hardware handshaking. RTS and CTS are turned OFF and ON from alternate ends to control data flow, for instance when a buffer is almost full.</li> | |||
<li><b>Xon/Xoff</b> - software handshaking. The Xon and Xoff characters are sent by the receiver to the sender to control when the sender will send data, i.e., these characters go in the opposite direction to the data being sent. The circuit starts in the "sending allowed" state. When the receiver's buffers approach capacity, the receiver sends the Xoff character to tell the sender to stop sending data. Later, after the receiver has emptied its buffers, it sends an Xon character to tell the sender to resume transmission.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
</table> | |||
===Slaves=== | |||
---- | |||
[[File:{{{file_slave_settings}}}]] | |||
<table class="nd-mantable"> | |||
<tr> | |||
<th>Field</th> | |||
<th>Value</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>Enabled</td> | |||
<td>yes | no; default: <b>no</b></td> | |||
<td>Turns the slave on or off.</td> | |||
</tr> | |||
<tr> | |||
<td>Slave ID</td> | |||
<td>integer [1..255]; default: <b>1</b></td> | |||
<td>Slave ID. Each slave in a network is assigned a unique identifier randging from 1 to 255. When the master requests data from a slave, the first byte it sends is the Slave ID.</td> | |||
</tr> | |||
<tr> | |||
<td>Period</td> | |||
<td>integer [1..9999]; default: <b>10</b></td> | |||
<td>Interval (in minutes) at which requests are sent to the slave device.</td> | |||
</tr> | |||
</table> | |||
====Slave requests==== | |||
---- | |||
[[File:{{{file_slave_request}}}]] | |||
<table class="nd-mantable"> | |||
<tr> | |||
<th>Field</th> | |||
<th>Value</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>Enabled</td> | |||
<td>yes | no; default: <b>no</b></td> | |||
<td>Turns the request on or off.</td> | |||
</tr> | |||
<tr> | |||
<td>Function</td> | |||
<td>Read Coil | Read Discrete Input | Read Holding Registers | Read Input Registers; default: <b>Read Holding Registers</b></td> | |||
<td>Modbus function used in Modbus request.</td> | |||
</tr> | |||
<tr> | |||
<td>First Register</td> | |||
<td>integer [1..65536]; default: <b>1</b></td> | |||
<td>First Modbus register from which data will be read.</td> | |||
</tr> | |||
<tr> | |||
<td>Number of Registers</td> | |||
<td>integer [1..2000]; default: <b>none</b></td> | |||
<td>Number of Modbus registers that will be read during the request/</td> | |||
</tr> | |||
</table> | |||
====Slave alarms==== | |||
---- | |||
[[File:{{{file_slave_alarm}}}]] | |||
<table class="nd-mantable"> | |||
<tr> | |||
<th>Field</th> | |||
<th>Value</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>Enabled</td> | |||
<td>yes | no; default: <b>no</b></td> | |||
<td>Turns the alarm on or off.</td> | |||
</tr> | |||
<tr> | |||
<td>Function</td> | |||
<td>Read Coil | Read Discrete Input | Read Holding Registers | Read Input Registers; default: <b>Read Holding Registers</b></td> | |||
<td>Modbus function used in Modbus request.</td> | |||
</tr> | |||
<tr> | |||
<td>Register</td> | |||
<td>integer [1..65536]; default: <b>1</b></td> | |||
<td>Number of the Modbus coil/input/holding register/input register that will be read.</td> | |||
</tr> | |||
<tr> | |||
<td>Condition</td> | |||
<td>More than | Less than | Equal to | Not equal to; default: <b>More than</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> | |||
</tr> | |||
<tr> | |||
<td>Value</td> | |||
<td>integer [0..65535]; default: <b>0</b></td> | |||
<td>The value against which the read data will be compared.</td> | |||
</tr> | |||
<tr> | |||
<td>Action</td> | |||
<td>SMS | Trigger output | Modbus request; default: <b>SMS</b></td> | |||
<td>Action that will be taken if the condition is met. Possible actions: | |||
<ul> | |||
<li><b>SMS</b> - sends and SMS message to a specified recipient(s).</li> | |||
<li><b>Trigger output</b> - changes the state of a specified output(s).</li> | |||
<li><b>Modbus Request</b> - sends a Modbus request to a specified slave.</li> | |||
</ul> | |||
</td> | |||
</tr> | </tr> | ||
</table> | </table> |