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

Обновление для соответствия новой версии исходной страницы.
(Обновление для соответствия новой версии исходной страницы.)
Строка 2: Строка 2:
<!-- {{DISPLAYTITLE:Управление модулями реле  Wiren Board по протоколу Modbus}} -->
<!-- {{DISPLAYTITLE:Управление модулями реле  Wiren Board по протоколу Modbus}} -->


== Modbus parameters ==
{{:Modbus_control_common}}


=== Modbus address ===
== Настройка устройства ==
[[Файл:modbus_address_mr14.png|150px|thumb|left|Modbus-address set on manufacture]]
Modbus-address of the Wiren Board devices is easy to determine — it is printed on the sticker (the address is in decimal format). The new address of the device is written by the command WRITE_SINGLE_REGISTER to the storage register (holding register) with the address 128 (0x80). For details on how to determine (if the address has been changed) or change the Modbus address of the module, see [[Определение и изменение Modbus-адреса устройств Wirenboard/en|Define and change the Modbus address of Wiren Board devices]].


=== Modbus commands supported by the device ===
=== Безопасный режим ===
 
В этом режиме при прекращении обмена данными по Modbus устройство отключает реле по прошествии заданного времени.  
The Wirenboard relay modules support all major Modbus commands. Read more here: [[Протокол_Modbus/en#Register reading and writing function codes|Register reading and writing function codes]].
 
=== Safe mode ===
In this mode, when the Modbus communication is terminated, the device disconnects the relay after a specified time.  


To enable Safety timer, you must write a value other than 0 to the storage register with the WRITE_SINGLE_REGISTER command at 8. This value is a timeout in seconds. A value of "0" disables safe mode.
To enable Safety timer, you must write a value other than 0 to the storage register with the WRITE_SINGLE_REGISTER command at 8. This value is a timeout in seconds. A value of "0" disables safe mode.
Строка 19: Строка 13:
===Relay operation in case of power failure ===
===Relay operation in case of power failure ===


In the latest firmware versions (starting with 1.5.3) for WB-MR devices, it is now possible to remember the output status when power is off. The mode is controlled by the Modbus register 6. If the register is set to '0', the state of the outputs will not be saved and all relays will be switched off when power is supplied. If the entry in the register unit, when the power is resumed everything is included before the crash relay is switched on again.
Для устройств WB-MR существует возможность запоминать состояние выхода при отключении питания. Режим контролируется Modbus-регистром 6. Если в регистре записано значение '0', то состояние выходов не сохраниться и при подаче питания все реле буду выключены. Если в регистре записана единица, то после возобновления питания все включенные до аварии реле включатся снова.
Этот функционал появился в модулях с прошивкой, начиная с версии 1.5.3.


=== Digital inputs ===
=== Digital inputs ===
Строка 34: Строка 29:
** '''Mapping-matrix''' (see detailed description below)
** '''Mapping-matrix''' (see detailed description below)


<div class="mw-translate-fuzzy">
The mode can be set separately for each channel. To do this, register 5 must have a value of "0", and the mode for each channel is written to the storage registers starting from address 9 for the first channel, etc.
The mode can be set separately for each channel. To do this, register 5 must have a value of "0", and the mode for each channel is written to the storage registers starting from address 9 for the first channel, etc.
</div>


<div class="mw-translate-fuzzy">
There is an outdated method - setting the mode for all channels at the same time. To do this, write the appropriate number in the storage register with address 5.
There is an outdated method - setting the mode for all channels at the same time. To do this, write the appropriate number in the storage register with address 5.
</div>


==== Mapping-matrix ====
==== Mapping-matrix ====
Строка 42: Строка 41:
Starting from firmware v.1.9.0, '''mode 2''' is also provided for individual channels-disable all outputs, and '''operating modes (4 and 5)''' in accordance with the mapping matrix (see below).In this and later versions of firmware versions modules have flexible settings of the interaction of inputs and outputs of relay modules using a special mapping matrix: a table in which for each input is encoded change of any relay output state when the state of this input changes. A detailed description can be found in [[I/O_Mapping_Matrix/en|I/O Mapping Matrix]].
Starting from firmware v.1.9.0, '''mode 2''' is also provided for individual channels-disable all outputs, and '''operating modes (4 and 5)''' in accordance with the mapping matrix (see below).In this and later versions of firmware versions modules have flexible settings of the interaction of inputs and outputs of relay modules using a special mapping matrix: a table in which for each input is encoded change of any relay output state when the state of this input changes. A detailed description can be found in [[I/O_Mapping_Matrix/en|I/O Mapping Matrix]].


=== Relay module register card ===
= Карта регистров модулей реле =
 
В таблице:
* '''x''' — number of relay outputs;  
* '''x''' — количество релейных выходов;  
* '''y''' is the number of digital inputs.
* '''y''' — количество цифровых входов.
(for modules WB-MRM2 see registers map at the description page of [[WB-MRM2/en|this module]])
Для устаревших модулей WB-MRM2 (не путать с современными WB-MRM2-mini) карту регистров смотрите на отдельной странице [[WB-MRM2]].


<div class="mw-translate-fuzzy">
{| border="1" class="wikitable" style="text-align:center; width:1000px;"
{| border="1" class="wikitable" style="text-align:center; width:1000px;"
!Register / address
!Register / address
Строка 81: Строка 81:
| 8 || holding || RW|| 0 || seconds || safe mode timeout ||
| 8 || holding || RW|| 0 || seconds || safe mode timeout ||
|-
|-
</div>


<div class="mw-translate-fuzzy">
| rowspan="3"  | 9 .. (9+'''x'''-1)  
| rowspan="3"  | 9 .. (9+'''x'''-1)  
| rowspan="3"  | holding  
| rowspan="3"  | holding  
Строка 94: Строка 96:
|
|
|-
|-
</div>




Строка 130: Строка 133:




| 20 .. (20+'''x'''-1) || holdreg || RW || 50 || 0 - 100 || время защиты от дребезга в миллисекундах || Начиная с прошивки 1.13.0
|-




 
<div class="mw-translate-fuzzy">
 
 
 
 
| 32 .. (32+'''y'''-1) || input || R|| 0 || 16-bit unsigned int || input counter 1 .. '''y''' ||  
| 32 .. (32+'''y'''-1) || input || R|| 0 || 16-bit unsigned int || input counter 1 .. '''y''' ||  
|-
|-
</div>


| 104-105 || input || R|| || 32-bit unsigned int || uptime counter in seconds ||
|-
| 120 (0x78) || holding || RW|| 0 || other than 0 || writing to the register causes the module to restart without saving the state ||
|-
| 121 (0x79) || holding || R || - || mV || module current supply voltage ||
|-
| 128 (0x80) || holding || RW|| 1 || 1 — 247
|| Modbus device address ||
|-
| 129 (0x81) || holding || RW|| 0 || 0 or 1 || Go to [[WB-MCU-Flasher|bootloader mode]]
|1.10.0
|-
| 200-205 || holding || R || {'X','X','X','X','X','X'} || || device signature (see table below) ||
|-
| 220-241 || holding || R | | | / _date__ _ _ time__|| firmware build date ||
|-
|250-266
|input
|R
|
|string, null-terminated
|firmware version|| 
|-
|270-271
|input
|R
|
|32-bit unsigned int
|unique identifier (S/N)
|-
| 384-447 || holding || RW|| 0 || || registers [[I/O_Mapping_Matrix/en|mapping-matrix]] || Since firmware version 1.9.0
|-
|}
In firmware version 1.6.0 and later, additional registers for setting data exchange parameters via RS-485 are supported:
{|  border="1" class="wikitable" style="text-align:center; width:1000px;"
!Register / address
!Type
!Read/write
!Value by default
!Format
!Function
|-
| 110 || holding || RW || 96 ||  baud rate / 100 ||  RS-485 port speed, '''divided by 100'''. Permissible speeds: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 <br>([[UART_Communication_Settings/en|UART Communication Settings for Wiren Board devices  ]])
|-
| 111 || holding || RW || 0 || || set the parity bit of the RS-485 port. Valid values: 0 - no parity bit (none), 1 - odd , 2 - even
|-
| 112 || holding || RW || 2 || || umber of stop bits of RS-485 port. Valid values: 1, 2
|-
|}
The 6-byte module signature is stored at address 200. The signature is unique for each model of Wiren Board devices and allows to identify the model by Modbus:
{| class="wikitable"
! style="font-weight: bold;" | Module
! style="font-weight: bold;" | Signature
|-
|WB-MRPS6
|MRPS6
|-
| WB-MR6C
| WBMR6
|-
| WB-MR3xV
| WBMR3
|-
| WB-MR6xV
| WBMR6
|-
| WB-MR14
| WBMR14
|-
| WB-MR11
| WBMR11
|-
| WB-MRM2
| WBMR2
WBMR2m
|}
To get the signature of a device you need to run command READ_HOLDING_REGISTERS at 200 (length of 6 registers). Writing to this area of memory is not supported, and error 3 is returned when attempting to write to an invalid location. Empty spaces in the signature text are clogged with the value 0x00.
Starting from register 220, the firmware build date is recorded, in the format ''number'''x00'''time'''x00''''' as a string (example: 'Jan 27 2017 17:01:13'). The length of the record is 21 registers.
The status value of each relay is stored in flag registers (coil). The 1st relay register address is 0, the 2nd it's 1, etc.
== Command-line device management ==
The Wiren Board controller software includes  modbus_client utility to work with devices connected to the RS-485 outputs, via Modbus Protocol, the detailed description of the command is on the page [[Modbus-client/en| Modbus client]]. Access to the command line is described in [[SSH/en| SSh]].
==== Register reading example ===
Let's check whether it is true that we are connected to the module of the desired type. (Service wb-mqtt-serial needs to be stopped). At address 200, a unique signature of 6 registers is stored. Let's read 6 registers, starting with the address 200, and convert the received hexadecimal answer into a character string:
<syntaxhighlight lang="bash">echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 \
-a1 -t0x03 -r200 -c 6 | \
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'` </syntaxhighlight>
As a result of the command we receive string  '''WBMR6'''. The WB-MR6 module in the example has Modbus address 1.
=== External input control type selection ===
The relay modules have two modes of relay channel control: via external inputs and via RS-485 Protocol.
In relay modules, you can select mode 0 when a button is connected to the external input (without locking), or mode 1 when a conventional switch (with locking) is used to control. Mode 3 disables external control, but it still retains the ability to control RS-485 and read the status of external inputs. Mode 0 is enabled by default.


In the external control mode, the relay is triggered by the fall of the logic level: the external inputs are connected to the pull-up resistors to the +5V line and the relay of the corresponding channel is triggered when the input is connected to the GND.
The relay status of each channel is stored in the controller memory until reboot, by default, when power is on, all relays are off. After initialization of the module, external inputs are polled and relays of all channels are transferred to the appropriate state.


The type of external control can be selected for each channel separately via 9 — (9+x) registers. To do this, the value 0 must be written in the holding register 5:
{{:Common_Modbus_Registers}}
<syntaxhighlight lang="bash">
modbus_client --debug -mrtu -pnone -s2 /dev/ttyAPP1 -a1 -t0x06 -r5 0
</syntaxhighlight>


To initialize the register at the start and through setup web-interface, see [[RS-485:Configuration_via_Web_Interface/en| RS-485: Configuration via web interface]].
Регистры настройки параметров обмена данными по RS-485 поддерживаются начиная с прошивки версии 1.6.0
wb_editors
14 355

правок