Перейти к содержанию

Навигация

Modbus/en: различия между версиями

Часть переводимой страницы Протокол Modbus.
(Новая страница: «The most common Modbus error codes are listed in the following table:»)
(Часть переводимой страницы Протокол Modbus.)
 
(не показано 10 промежуточных версий 3 участников)
Строка 1: Строка 1:
<languages/>
<languages/>


===Basics===
=== Fundamentals===


Basic concept
Modbus is a protocol of the applied (seventh) level of the [https://en.wikipedia.org/wiki/OSI_model OSI] model for data exchange, most often between automation devices and is implemented in the form of "request-reply protocol".  
Modbus is a Protocol of the applied (seventh) level of the [https://en.wikipedia.org/wiki/OSI_model OSI] model for data exchange, most often between automation devices and is implemented in the form of "request-reply protocol".  


In Wirenboard devices, Modbus data is transmitted over RS-485 serial communication lines. In serial lines RS-485 Protocol is half-duplex and works on the principle of "client-server". Each device on the network (except the master, see below) has an address from 1 to 247, address 0 is used for broadcasting to all devices, and addresses 248-255 are considered reserved according to the Modbus specification, their use is not recommended.
In Wirenboard devices, Modbus data is transmitted over RS-485 serial communication lines. In serial lines RS-485 Protocol is half-duplex and works on the principle of "client-server". Each device on the network (except the master, see below) has an address from 1 to 247, address 0 is used for broadcasting to all devices, and addresses 248-255 are considered reserved according to the Modbus specification, their use is not recommended.




There are two protocol specifications: Modbus RTU and Modbus ASCII. An 11-bit character consisting of 1 start bit, 8 data bits (starting with the lower bit), a parity bit (optional), and 2 stop bits if no parity bit is transmitted, or 1 stop bit if no parity bit is transmitted, is transmitted to the Modbus RTU. This character allows you to transfer 1 byte of data. In Wiren Board devices, the parity bit is not transmitted and 2 stop bits are used. In Modbus ASCII, each byte is transmitted in two characters representing the ASCII codes of the lower and upper four-bit byte groups ([http://www.simplymodbus.ca/ASCII.htm пример]). The Modbus RTU allows you to transmit more information at the same serial line speed and it is used in the Wiren Board devices. All further description applies to Modbus RTU.
There are two protocol specifications: Modbus RTU and Modbus ASCII. An 11-bit character consisting of 1 start bit, 8 data bits (starting with the lower bit), a parity bit (optional), and 2 stop bits if no parity bit is transmitted, or 1 stop bit if parity bit is transmitted, is transmitted to the Modbus RTU. This character allows you to transfer 1 byte of data. In Wiren Board devices, the parity bit is not transmitted and 2 stop bits are used. In Modbus ASCII, each byte is transmitted in two characters representing the ASCII codes of the lower and upper four-bit byte groups ([http://www.simplymodbus.ca/ASCII.htm пример]). The Modbus RTU allows you to transmit more information at the same serial line speed and it is used in the Wiren Board devices. All further description applies to Modbus RTU.




Строка 63: Строка 62:
Holding Registers and Input Registers are represented by a two-byte word and can store values from 0 to 65535 (0x0000 — 0xFFFFF).
Holding Registers and Input Registers are represented by a two-byte word and can store values from 0 to 65535 (0x0000 — 0xFFFFF).
Input registers are read-only (e.g. current temperature). Storage registers support both read and write (to store settings). Currently, in many devices, particularly Wiren Board devices, these registers are not separated. Commands to read the storage register N and the input register N will access the same value in the address space of the device.
Input registers are read-only (e.g. current temperature). Storage registers support both read and write (to store settings). Currently, in many devices, particularly Wiren Board devices, these registers are not separated. Commands to read the storage register N and the input register N will access the same value in the address space of the device.


===Registers addresses and numbers===
===Registers addresses and numbers===
Строка 115: Строка 113:


[[File:SDM220_Template.png|700px|thumb|center|Template Fragment for SDM220 meter]]
[[File:SDM220_Template.png|700px|thumb|center|Template Fragment for SDM220 meter]]


=== Register reading and writing function codes ===
=== Register reading and writing function codes ===
Строка 165: Строка 162:
The following table shows the query and response data structures for the main Modbus functions.
The following table shows the query and response data structures for the main Modbus functions.


<div class="mw-translate-fuzzy">
{|class="wikitable" align="center"
{|class="wikitable" align="center"
!Function code || Request || Reply   
!Function code || Request || Reply   
Строка 185: Строка 181:
|-
|-
!    16 (Write Multiple register )
!    16 (Write Multiple register )
| <ul><li>The address of the first storage register for recording (16-bit</li><li>Number of holding registers to write (16 bits)</li><li>the Number of transmitted data bytes for the registers (8-bit)</li><li>Data (16 bytes per register)</li></ul> ||  <ul><li>The address of the first storage register (16 bits)</li><li>Number of written holding registers(16 bit)</li></ul>   
| <ul><li>The address of the first storage register for recording (16-bits)</li><li>Number of holding registers to write (16 bits)</li><li>the Number of transmitted data bytes for the registers (8-bit)</li><li>Data (16 bytes per register)</li></ul> ||  <ul><li>The address of the first storage register (16 bits)</li><li>Number of written holding registers(16 bit)</li></ul>   
|-
|-
|}
|}
</div>




Строка 201: Строка 196:


{|class="wikitable" align="center"
{|class="wikitable" align="center"
!Код ошибки || Название ошибки|| Что означает
!Error Code || Error name|| Meaning
|-
|-
!    1   
!    1   
| Illegal Function || В запросе был передан недопустимый код функции
| Illegal Function ||   An invalid function code was sent in the request
|-
|-
!    2   
!    2   
| Illegal Data Address ||Указанный в запросе адрес не существует
| Illegal Data Address ||Illegal Data Address
|-
|-
!    3   
!    3   
| Illegal Data Value || В поле данных передано неверное значение
| Illegal Data Value || Illegal Data Value
|-
|-
!    4   
!    4   
| Slave Device Failure ||Произошла невосстановимая ошибка на устройстве при выполнении запрошенной операции
| Slave Device Failure ||An unrecoverable error occurred on the device while performing the requested operation
|-
|-
!    5   
!    5   
| Acknowledge ||Запрос принят, выполняется, но выполнение потребует много времени; необходимо увеличить таймаут.
| Acknowledge ||Request is accepted, executed, but will take a long time to complete; you must increase the timeout.
|-
|-
!    6   
!    6   
| Slave Device Busy ||Устройство занято обработкой предыдущего запроса.  
| Slave Device Busy || The device is busy processing the previous request.
|-
|-
!    7   
!    7   
| Negative Acknowledge || Устройство не может выполнить запрос, необходимо получить от устройства дополнительную диагностическую информацию. Возможно, требуется тех. обслуживание.
| Negative Acknowledge || The device cannot fulfill the request, you must obtain additional diagnostic information from the device. Maintenance may be required.
|-
|-
!    8   
!    8   
| Memory Parity Error || Ошибка четности при обращении к внутренней памяти устройства.
| Memory Parity Error || Parity Error when accessing the internal memory of the device.
|-
|-
|}
|}
Строка 231: Строка 226:




=== Вычисление контрольной суммы Modbus ===
=== Modbus checksum calculation  ===


Для протокола Modbus RTU 16-битная контрольная сумма (CRC) вычисляется по алгоритму, описанному в [http://www.modbus.org/specs.php спецификации Modbus], в документе "Modbus Serial Line Protocol and Implementation Guide", раздел "CRC-generation". Передающее устройство формирует два байта контрольной суммы на основе данных сообщения, а принимающее устройство заново вычисляет контрольную сумму и сравнивает с полученной. Совпадение принятой и вычисленной контрольной суммы Modbud RTU считается индикатором успешного обмена данными.
For the Modbus RTU Protocol, the 16-bit checksum (CRC) is calculated using the algorithm described in the [http://www.modbus.org/specs.php Modbus] specification in ''the Modbus Serial Line Protocol and Implementation Guide, CRC-generation section''. The sending device generates two bytes of checksum based on the message data, and the receiving device recalculates the checksum and compares it with the received one. The coincidence of the accepted and calculated modbud RTU checksum is considered an indicator of successful data exchange.


В случае ограниченных вычислительных ресурсов для вычисления контрольной суммы существует функция, использующая табличные значения (так же приведена в спецификации).
In the case of limited computing resources for the calculation of the checksum, there is a function that uses table values (also given in the specification).
wb_editors
14 355

правок