WB-MSx Consumer IR Manual/en: различия между версиями

Материал из Wiren Board
(Новая страница: «To write the signal number <code>i</code> from the remote control to memory, write 1 to the flag register at <code>5300 + i</code>. Then point the remote control…»)
(не показана 21 промежуточная версия 1 участника)
Строка 28: Строка 28:
'''Warning!''' Numbers used Modbus registers have changed since firmware version '''3.2.0'''. The instructions stated the new numbers of registers. If you are using a device with older firmware, the general principle remains the same, but the numbers of the registers are shifted; as it is — see the [[#Map registers, flags, and inputs (Inputs and Coils)|Map registers, flags, and inputs (Coils and Inputs)]]. A full description of IR device registers can be found in this article under [[#Register map|Register map]].
'''Warning!''' Numbers used Modbus registers have changed since firmware version '''3.2.0'''. The instructions stated the new numbers of registers. If you are using a device with older firmware, the general principle remains the same, but the numbers of the registers are shifted; as it is — see the [[#Map registers, flags, and inputs (Inputs and Coils)|Map registers, flags, and inputs (Coils and Inputs)]]. A full description of IR device registers can be found in this article under [[#Register map|Register map]].


At the physical level, the module is connected via [[RS-485/en| RS-485]]  interface. Modbus RTU Protocol is used to control the devices. In Wiren Board devices, Modbus data is transmitted over RS-485 communication lines. See the [[Протокол Modbus/en|Modbus Protocol]] page for details. Modbus-address of the device is set at the factory and marked on the label. The address can be changed programmatically.
At the physical level, the module is connected via [[RS-485/en| RS-485]]  interface. Modbus RTU Protocol is used to control the devices. In Wiren Board devices, Modbus data is transmitted over RS-485 communication lines. See the [[Протокол Modbus/en|Modbus Protocol]] page for details. Modbus-address of the device is set at the factory and marked on the label. The address can be changed programmatically. Details refer to the [[#Modbus control| Modbus control]].


In devices with firmware version "'3.1.0"' and later it is also possible to change the settings of data exchange parameters — see [[#Register map|Modbus register map]].
In devices with firmware version "'3.1.0"' and later it is also possible to change the settings of data exchange parameters — see [[#register Map|Modbus register map]].


The control of the IR receiver is made through the flags of Modbus registers; a full list can be found in the description of the map registers. There are 3 types of operations with signals:
The control of the IR receiver is made through the flags of Modbus registers; a full list can be found in the description of the map registers. There are 3 types of operations with signals:
Строка 53: Строка 53:
</syntaxhighlight>
</syntaxhighlight>


==== Playback of a signal from ROM ====
==== Воспроизведение сигнала из постоянной памяти ====
To play back the signal number <code>i</code> from memory, write 1 to the flag register at <code>5100 + i</code>. If the signal number <code>i</code> has not been recorded before, an error will be returned. While the signal is playing, the flag register at <code>5100 + i</code> will be set to 1 and then set to 0. While the signal is being played, no other operations with the IR transceiver via Modbus will be available.
Чтобы воспроизвести сигнал под номером <code>i</code> из памяти, запишите 1 в регистр флага по адресу <code>5100 + i</code>. Если сигнал под номером <code>i</code> не был записан ранее, будет возвращена ошибка. Пока идёт воспроизведение сигнала, регистр флага по адресу <code>5100 + i</code> будет установлен в 1, а затем сам установится в 0. Пока идёт воспроизведение сигнала, никакие другие операции с ИК-приёмопередатчиком по Modbus не будут доступны.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
#Give the command to play the signal with the number 1. The device connected to port /dev/ttyRS485-1 has Modbus 16
#Отдаём команду воспроизвести сигнал с номером 1. Устройство подключено к порту /dev/ttyRS485-1 и имеет Modbus-адрес 16
root@wirenboard:~# modbus_client --debug -m rtu -b9600 -s2 -pnone /dev/ttyRS485-1 -a16 -t5 -r5101 1
root@wirenboard:~# modbus_client --debug -m rtu -b9600 -s2 -pnone /dev/ttyRS485-1 -a16 -t5 -r5101 1
</syntaxhighlight>
</syntaxhighlight>
==== Edit the signal in ROM ====
==== Редактирование сигнала в постоянной памяти ====
To edit the signal number <code>i</code> or record it via Modbus (without remote control), write 1 in the flag register at <code>5200 + i</code>. After that, the signal in the form of a sequence of natural numbers (see the figure "Example of the contents of the WB-MIR operational buffer") will be written to the consecutive storage registers, starting with the register <code>2000</code>. At the end of the sequence there will be two consecutive storage registers containing 0. If the signal number <code>i</code> has not been recorded before, the storage registers <code>2000</code> and <code>2001</code> will contain 0. To make changes to the sequence (including writing a Modbus command), you must write the correct sequence to the storage registers using the <code>WRITE_SINGLE_REGISTER</code> and <code>WRITE_MULTI_REGISTERS</code>commands. At the end of the modified sequence, there must also be an end-of-sequence marker - two consecutive storage registers containing 0. To remove the signal, write 0 in the first two storage registers (<code>2000</code> and <code>2001</code>). After editing, write 0 in the flag register at <code>5200 + i</code>. Until the flags register at the address <code>5200 + i</code> will not be a 0, no other operations, including over other signals will not be available.
Чтобы отредактировать сигнал под номером <code>i</code> или записать его по Modbus (без пульта ДУ), запишите 1 в регистр флага по адресу <code>5200 + i</code>. После этого сигнал в виде последовательности натуральных чисел (смотрите рисунок "Пример содержимого оперативного буфера WB-MIR") будет записан в подряд идущие регистры хранения, начиная с регистра <code>2000</code>. В конце последовательности будут два подряд идущих регистра хранения, содержащих 0. Если сигнал под номером <code>i</code> не был записан ранее, в регистрах хранения <code>2000</code> и <code>2001</code> будут находиться 0. Для внесения изменений в последовательность (в том числе для записи команды по Modbus) нужно записать правильную последовательность в данные регистры хранения с помощью команд <code>WRITE_SINGLE_REGISTER</code> и <code>WRITE_MULTI_REGISTERS</code>. В конце изменённой последовательности всё также должен быть маркер конца последовательности - два подряд идущих регистра хранения, содержащих 0. Чтобы удалить сигнал, запишите в первые два регистра хранения (<code>2000</code> и <code>2001</code>) 0. После окончания редактирования запишите 0 в регистр флагов по адресу <code>5200 + i</code>. До тех пор пока в регистре флагов по адресу <code>5200 + i</code> не будет стоять 0, никакие другие операции, в том числе и над другими сигналами, не будут доступны.


=== Removing all signals from ROM ===
==== Удаление всех сигналов из постоянной памяти ====
To remove all recorded signals, write 1 to the flag register at <code>5000</code>.
Чтобы удалить все записанные сигналы, запишите 1 в регистр флагов по адресу <code>5000</code>.


== Operating mode ==
== Оперативный режим ==
=== Recording the signal to the RAM from the remote control ===
=== Запись сигнала в оперативную память с пульта ДУ ===
To write a signal (only one) from the remote control to the RAM without putting it in the ROM - write 1 in the flag register at <code>5001</code>. Further actions occur in the same way as described above to record the signal in ROM. After the recording is stopped in the storage registers at <code>2000</code>, the signal will be stored as a sequence of numbers. You can edit this sequence as described above. Note: the contents of these storage registers are not stored when the device is powered off!
Чтобы записать сигнал (только один) с пульта в оперативную память, не помещая при этом в ПЗУ - запишите 1 в регистр флага по адресу <code>5001</code>. Далее действия происходят так же, как описано выше для записи сигнала в ПЗУ. После прекращения записи в регистрах хранения по адресу <code>2000</code> и дальше будет храниться сигнал в виде последовательности чисел. Эту последовательность можно редактировать, как описано выше. Внимание: содержимое этих регистров хранения не сохраняется при отключении питания устройства!
=== Playing a signal from memory ===
=== Воспроизведение сигнала из оперативной памяти ===
To play the signal from memory, write 1 to the flag register at <code>5002</code>. The signal recorded in the storage registers starting with <code>2000</code>will be played. In the absence of the marker of the end of the command will return an error. While the signal is playing, the flag register at <code>5002</code> will be set to 1 and then set to 0. While the signal is being played, no other operations with the IR transceiver via Modbus will be available.
Чтобы воспроизвести сигнал из оперативной памяти, запишите 1 в регистр флага по адресу <code>5002</code>. Будет воспроизведён сигнал, записанный в регистрах хранения, начиная с <code>2000</code>. В случае отсутствия маркера конца команды будет возвращена ошибка. Пока идёт воспроизведение сигнала, регистр флага по адресу <code>5002</code> будет установлен в 1, а затем сам установится в 0. Пока идёт воспроизведение сигнала, никакие другие операции с ИК-приёмопередатчиком по Modbus не будут доступны.


The control of the IR receiver is made through the Modbus registers flags (a full list can be found in [[#Map registers, flags, and inputs (Inputs and Coils)|Inputs and Coils]]). There are 3 types of operations with signals:
Управление ИК-приёмопередатчиком производится через регистры флагов Modbus (полный список можно найти в [[#Карта_регистров_флагов_(Coils)|Карта регистров флагов (Coils)]]). Есть 3 типа операций с сигналами:
* entry signal in the memory with the remote control,
* запись сигнала в память с пульта ДУ,
* play a signal from memory,
* воспроизведение сигнала из памяти,
* edit signal in memory.
* редактирование сигнала в памяти.
* in future versions it is expected to implement direct write from the operational buffer to ROM.
* в следующих версиях предполагается реализовать непосредственную запись из оперативного буфера в ПЗУ.


As in the case of registers of the permanent storage every time you can only perform one operation only one signal. Since during the execution of any operation one of the registers of flags is set to 1, and after the operation is completed there is set to 0, at any time among all the registers of flags related to the IR transceiver, only one register can be set to one. Attempting to write 1 to IR-related flag registers with an existing unit will result in a <code>BUSY</code> error
Как и в случае работы с регистрами постоянного хранения, в каждый момент времени можно выполнять только одну операцию только над одним сигналом. Так как во время выполнения любой операции в один из регистров флагов ставится 1, а после завершения операции туда же ставится 0, в каждый момент времени среди всех регистров флагов, относящихся к ИК-приёмопередатчику, только один регистр может быть установлен в единицу. Попытка записи 1 в регистры флагов, связанных с ИК, при уже имеющейся единице приведёт к ошибке <code>BUSY</code>.


=== Removing all signals from permanent memory ===
=== Удаление всех сигналов из постоянной памяти ===
To delete all recorded signals, write 1 to the flag register at <code>5000</code>.
Чтобы удалить все записанные сигналы, запишите 1 в регистр флагов по адресу <code>5000</code>.


== Register map ==  
== Карта регистров ==  


===Holding Registers===
=== Карта регистров хранения (Holding Registers)===


{| border="1" class="wikitable" style="text-align:center"
{| border="1" class="wikitable" style="text-align:center"
!Register/ address
!Регистр/ адрес
!type
!тип
!read-write
!чтение/ запись
!default
!значение по умолчанию
!format
!формат
!appointment
!назначение
|-
|-
|6
|6
|input
|input
|R
|R
|0x7FFF — sensor not connected or defective
|0x7FFF — датчик не подключен или неисправен
|°C × 16 (signed)
|°C × 16 (signed)
|Temperature from external sensor
|Температура с внешнего датчика
|-
|-
|7
|7
|input
|input
|R
|R
|0x7FFF — sensor is not connected or defective
|0x7FFF — датчик не подключен или неисправен
|°C × 16 (signed)
|°C × 16 (signed)
|Temperature from external sensor
|Температура с внешнего датчика
|-
|-
| 110 || holding || RW || 96 (0x60) || 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|configure RS-485 communication parameters for wiren Board modbus devices]])
| 110 || holding || RW || 96 (0x60) || baud rate / 100 || скорость порта RS-485, '''делённая на 100'''. Допустимые скорости: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 <br>([[UART_Communication_Settings|Настройка параметров обмена данными по RS-485 для modbus-устройств Wiren Board]])
|-
|-
| 111 || holding || RW|| 0 || || configure the RS-485 port parity bit. Valid values: 0 - no parity bit (none), 1 - odd (odd), 2 - even (even)  
| 111 || holding || RW || 0 || || настройка бита чётности порта RS-485. Допустимые значения: 0 - нет бита чётности (none), 1 - нечётный (odd), 2 - чётный (even)  
|-
|-
| 112 || holding || RW|| 2 || || number of stop bits of RS-485 port. Valid values: 1, 2
| 112 || holding || RW || 2 || || количество стоп-битов порта RS-485. Допустимые значения: 1, 2
|-
|-
| 120 (0x78) || holding || RW|| 0 || non-0 || writing to the register causes the module to restart without saving state
| 120 (0x78) || holding || RW || 0 || отличное от 0 || запись в регистр вызывает перезагрузку модуля без сохранения состояния
|-
|-
| 121 (0x79) || input || R || - || mV || current supply voltage of the module
| 121 (0x79) || input || R || - || mV || текущее напряжение питания модуля
|-
|-
| 128 (0x80) || holding || RW|| 1 || || Modbus device address
| 128 (0x80) || holding || RW || 1 || || Modbus-адрес устройства
|-
|-
| 200-206 || input || R || {'x','x','x','x','x','x'} | | | signature
| 200-206 || input || R || {'x','x','x','x','x','x'} || || сигнатура
|-
|-
| 220-241 || input || R | | | | _date__ _time__|| firmware build date
| 220-241 || input || R || || __date__ __time__||   дата сборки прошивки
|-
|-
| 250-269 || input || R | | | / string, null-terminated || firmware version
| 250-269 || input || R || ||  строка, null-terminated || версия прошивки
|-
|-
| 270-271 || input || R|| || 32-bit unsigned int || unique identifier (S/N)
| 270-271 || input || R || || 32-bit unsigned int || уникальный идентификатор (S/N)
|-
|-
| 2000-2509 || holding || RW|| || || IR transceiver period Buffer (2000-2201 in WB-MIR firmware versions up to 4.1.0)  
| 2000-2509 || holding || RW || || || Буфер периодов IR-приемопередатчика (2000-2201 в прошивках WB-MIR версий до 4.1.0)  
|-
|-
|}
|}


=== Map registers, flags, and inputs (Inputs and Coils) ===
=== Карта регистров флагов и входов (Coils и Inputs) ===




{| border="1" class="wikitable" style="text-align:center"
{| border="1" class="wikitable" style="text-align:center"
!Starting address || Type || Quantity || Purpose || In modifications
!Начальный адрес || Тип || Количество || Назначение || В модификациях
|-
|-
| 5000 || coil|| 1 || style="text-align:left" | Clear all IR command banks || I
| 5000 || coil || 1 || style="text-align:left" | Очистка всех банков ИК-команд || I
|-
|-
| 5001 || coil|| 1 || style="text-align:left" | Write IR commands from IR receiver to Modbus storage registers (2000-2509) (RAM), without saving to command Bank || I
| 5001 || coil || 1 || style="text-align:left" | Запись ИК-команды с ИК-приёмника в Modbus регистры хранения (2000-2509) (RAM), без сохранения в банк команд || I
|-
|-
| 5002 || coil|| 1 || style="text-align:left" | Play IR command from Modbus storage registers (2000-2509) (RAM) || I
| 5002 || coil || 1 || style="text-align:left" | Воспроизведение ИК-команды из Modbus регистров хранения (2000-2509) (RAM) || I
|-
|-
| 5100 (firmware 3.1.0 and earlier - 0) || coil || number_of_banks || style="text-align:left" | Play IR command from the corresponding ROM Bank (Play) || I
| 5100 (в прошивке 3.1.0 и ранее - 0) || coil || number_of_banks || style="text-align:left" | Воспроизведение ИК-команды из соответствующего банка ROM (Play) || I
|-
|-
| 5200 (firmware 3.1.0 and earlier - 1000) || coil || number_of_banks|| style="text-align:left" | edit IR commands (ROM) with copying to RAM (ROM -> RAM) || I  
| 5200 (в прошивке 3.1.0 и ранее - 1000) || coil || number_of_banks|| style="text-align:left" | Редактирование ИК-команд (ROM) с копированием в RAM (ROM -> RAM) || I  
|-
|-
| 5300 (in firmware 3.1.0 and earlier - 2000)|| coil || number_of_banks || style="text-align:left" | Write to IR command Bank using IR receiver (Learn)|| I
| 5300 (в прошивке 3.1.0 и ранее - 2000)|| coil || number_of_banks || style="text-align:left" | Запись в банк ИК-команд с использованием IR-приёмника  (Learn)|| I
|-
|-
| 5400 || input || number_of_banks || style="text-align:left" | IR command data Size in bytes || I
| 5400 || input || number_of_banks || style="text-align:left" | Размер данных IR-команды в байтах || I
|-
|-
|}
|}


In the latest firmware versions, the value of number_of_banks is 80, that is, for example, command size registers have values from 5400 to 5479.
В последних версиях прошивок значение number_of_banks равняется 80, то есть, например, регистры размера команд имеют значения от 5400 до 5479.


== 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]].
Программное обеспечение контроллера Wiren Board включает в себя утилиту modbus_client для работы с устройствами, подключенными к выходам RS-485, по протоколу Modbus, подробное описание команды находится на странице [[Modbus-client]]. Доступ к командной строке описан в статье [[SSH]].


=== Register reading example ===
=== Пример чтения регистров ===
Let's check whether it is true that we are connected to the module of the desired type. (Module 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 answer from hexadecimal digits into a character string:
Проверим, верно ли, что мы подключились именно к модулю нужного типа. (Модуль wb-mqtt-serial должен быть предварительно остановлен). По адресу 200 хранится уникальная сигнатура длиной в 6 регистров. Прочтем 6 регистров, начиная с адреса 200, и преобразуем полученный ответ из шестнадцатеричных цифр в символьную строку:


<syntaxhighlight lang="bash">echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 \
<syntaxhighlight lang="bash">echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 \
Строка 166: Строка 166:
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'` </syntaxhighlight>
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  '''WBMIR'''. The WB-MIR module in the example has Modbus address 1.
В результате выполнения команды получаем строку, например '''WBMIR'''. В этом примере модуль WB-MIR имеет Modbus-адрес 1.

Версия 11:22, 19 июля 2019

Другие языки:


Instructions for IR transceiver settings for WB-MS, WB-MSW, WB-MIR devices

Purpose

Infrared transceiver, installed in devices WB-MS, WB-MSW modification I and WB-MIR, is designed to record signals from IR remote controls of household devices and further control of household appliances: air conditioners, TVs, etc. Modules WB-MIR V. 2 and WB-MSW V. 3 supports about 80 IR commands (depends on the amount of memory).

Warning! All modules (except for WB-MSW v.3) IR control is only possible with short distances (< 1 m).

Operating principle

The signal from the remote control is recorded by the IR receiver and stored in the device memory, where it can be played on command from the controller or other control devices. All signals in the devices are stored in permanent memory (ROM) and one in the operational buffer (RAM). The IR signal can also be recorded not from the remote control, but transmitted as a sequence of numbers via Modbus. The stored signal is reproduced by the IR transmitter when the corresponding Modbus command is received.

The device has two modes of operation: permanent (working with ROM-buffers) and operational (RAM-buffer).

In continuous mode (ROM), the recorded signals are stored in the Flash ROM of the device and stored when the power is turned off. Every time the signal is overwritten, the physical resource of the device's processor ROM is consumed — in total, the signal can be overwritten no more than 1000 times.

Method of signal presentation and storage

The example of the contents of the operational buffer WB-MIR

The signal is stored in the device memory as a sequence of natural numbers (each from 0 to 65535), where each number is the duration of the logical 0 or 1 in the signal in quanta of 10 microseconds. Therefore, the maximum duration of each zero or unit must be no more than 65535 * 10 µs = 655350 µs = 0.655 seconds. The first number of the sequence is the duration of the first logical unit. The end of the sequence is marked with two periods of duration 0.

In operating mode, the IR signal (only one) is stored in the device's memory. It is recorded there from the control panel when the corresponding Modbus command is given or by writing values to the appropriate registers from an external Modbus device (e.g. from the controller Wiren Board 6/en), and the IR signal can be copied from a Flash ROM. The IR signal can be played from the RAM and then overwritten; the ROM resource is not consumed. When the power is turned off, the signal is not stored in the RAM.

The latest firmware versions of WB-MIR v.2 and WB-MSW v.3 sequences of commands are compressed by a special algorithm to provide a higher storage density. The sequences are unzipped before playback.

Modbus module control

Warning! Numbers used Modbus registers have changed since firmware version 3.2.0. The instructions stated the new numbers of registers. If you are using a device with older firmware, the general principle remains the same, but the numbers of the registers are shifted; as it is — see the Map registers, flags, and inputs (Coils and Inputs). A full description of IR device registers can be found in this article under Register map.

At the physical level, the module is connected via RS-485 interface. Modbus RTU Protocol is used to control the devices. In Wiren Board devices, Modbus data is transmitted over RS-485 communication lines. See the Modbus Protocol page for details. Modbus-address of the device is set at the factory and marked on the label. The address can be changed programmatically. Details refer to the Modbus control.

In devices with firmware version "'3.1.0"' and later it is also possible to change the settings of data exchange parameters — see Modbus register map.

The control of the IR receiver is made through the flags of Modbus registers; a full list can be found in the description of the map registers. There are 3 types of operations with signals:

  • entry signal in the memory with the remote control,
  • play a signal from memory,
  • edit the signal in memory.

Only one operation can be performed on only one signal at a time. Since during the execution of any operation one of the registers of flags is set to 1, and after the operation is completed there is set to 0, at any time among all the registers of flags related to the IR transceiver, only one register can be set to one. Attempting to write 1 to IR-related flag registers with an existing unit will result in a BUSY error.

Constant mode

In constant mode, the IR commands are stored in the device memory and are available after a power reset. Each command is stored in a separate "Bank" of memory. The number of memory banks depends on the device flashing. Prior to firmware 3.7.2 inclusive, the devices had 7 memory banks of IR commands. Starting with version 4.4.0 32 banks are supported. Intermediate versions allowed to record up to 80 commands, but in some cases did it incorrectly.

Signal record in ROM with the remote control

Note: For more about work in command line mode, see the section Control module from the command line.

To write the signal number i from the remote control to memory, write 1 to the flag register at 5300 + i. Then point the remote control at the IR receiver and press the button on the remote. After releasing the button, complete the signal recording by writing 0 to the flag register at 5300 + i.

#Start recording signal number 1. The device connected to port /dev/ttyRS485-1 has Modbus 16
root@wirenboard:~# modbus_client --debug -m rtu -b9600 -s2 -pnone /dev/ttyRS485-1 -a16 -t5 -r5301 1
#Direct the remote to the receiver window and press the button on the remote control
root@wirenboard:~# modbus_client --debug -m rtu -b9600 -s2 -pnone /dev/ttyRS485-1 -a16 -t5 -r5301 0
#Finish the entry signal number 1

Воспроизведение сигнала из постоянной памяти

Чтобы воспроизвести сигнал под номером i из памяти, запишите 1 в регистр флага по адресу 5100 + i. Если сигнал под номером i не был записан ранее, будет возвращена ошибка. Пока идёт воспроизведение сигнала, регистр флага по адресу 5100 + i будет установлен в 1, а затем сам установится в 0. Пока идёт воспроизведение сигнала, никакие другие операции с ИК-приёмопередатчиком по Modbus не будут доступны.

#Отдаём команду воспроизвести сигнал с номером 1. Устройство подключено к порту /dev/ttyRS485-1 и имеет Modbus-адрес 16
root@wirenboard:~# modbus_client --debug -m rtu -b9600 -s2 -pnone /dev/ttyRS485-1 -a16 -t5 -r5101 1

Редактирование сигнала в постоянной памяти

Чтобы отредактировать сигнал под номером i или записать его по Modbus (без пульта ДУ), запишите 1 в регистр флага по адресу 5200 + i. После этого сигнал в виде последовательности натуральных чисел (смотрите рисунок "Пример содержимого оперативного буфера WB-MIR") будет записан в подряд идущие регистры хранения, начиная с регистра 2000. В конце последовательности будут два подряд идущих регистра хранения, содержащих 0. Если сигнал под номером i не был записан ранее, в регистрах хранения 2000 и 2001 будут находиться 0. Для внесения изменений в последовательность (в том числе для записи команды по Modbus) нужно записать правильную последовательность в данные регистры хранения с помощью команд WRITE_SINGLE_REGISTER и WRITE_MULTI_REGISTERS. В конце изменённой последовательности всё также должен быть маркер конца последовательности - два подряд идущих регистра хранения, содержащих 0. Чтобы удалить сигнал, запишите в первые два регистра хранения (2000 и 2001) 0. После окончания редактирования запишите 0 в регистр флагов по адресу 5200 + i. До тех пор пока в регистре флагов по адресу 5200 + i не будет стоять 0, никакие другие операции, в том числе и над другими сигналами, не будут доступны.

Удаление всех сигналов из постоянной памяти

Чтобы удалить все записанные сигналы, запишите 1 в регистр флагов по адресу 5000.

Оперативный режим

Запись сигнала в оперативную память с пульта ДУ

Чтобы записать сигнал (только один) с пульта в оперативную память, не помещая при этом в ПЗУ - запишите 1 в регистр флага по адресу 5001. Далее действия происходят так же, как описано выше для записи сигнала в ПЗУ. После прекращения записи в регистрах хранения по адресу 2000 и дальше будет храниться сигнал в виде последовательности чисел. Эту последовательность можно редактировать, как описано выше. Внимание: содержимое этих регистров хранения не сохраняется при отключении питания устройства!

Воспроизведение сигнала из оперативной памяти

Чтобы воспроизвести сигнал из оперативной памяти, запишите 1 в регистр флага по адресу 5002. Будет воспроизведён сигнал, записанный в регистрах хранения, начиная с 2000. В случае отсутствия маркера конца команды будет возвращена ошибка. Пока идёт воспроизведение сигнала, регистр флага по адресу 5002 будет установлен в 1, а затем сам установится в 0. Пока идёт воспроизведение сигнала, никакие другие операции с ИК-приёмопередатчиком по Modbus не будут доступны.

Управление ИК-приёмопередатчиком производится через регистры флагов Modbus (полный список можно найти в Карта регистров флагов (Coils)). Есть 3 типа операций с сигналами:

  • запись сигнала в память с пульта ДУ,
  • воспроизведение сигнала из памяти,
  • редактирование сигнала в памяти.
  • в следующих версиях предполагается реализовать непосредственную запись из оперативного буфера в ПЗУ.

Как и в случае работы с регистрами постоянного хранения, в каждый момент времени можно выполнять только одну операцию только над одним сигналом. Так как во время выполнения любой операции в один из регистров флагов ставится 1, а после завершения операции туда же ставится 0, в каждый момент времени среди всех регистров флагов, относящихся к ИК-приёмопередатчику, только один регистр может быть установлен в единицу. Попытка записи 1 в регистры флагов, связанных с ИК, при уже имеющейся единице приведёт к ошибке BUSY.

Удаление всех сигналов из постоянной памяти

Чтобы удалить все записанные сигналы, запишите 1 в регистр флагов по адресу 5000.

Карта регистров

Карта регистров хранения (Holding Registers)

Регистр/ адрес тип чтение/ запись значение по умолчанию формат назначение
6 input R 0x7FFF — датчик не подключен или неисправен °C × 16 (signed) Температура с внешнего датчика
7 input R 0x7FFF — датчик не подключен или неисправен °C × 16 (signed) Температура с внешнего датчика
110 holding RW 96 (0x60) baud rate / 100 скорость порта RS-485, делённая на 100. Допустимые скорости: 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
(Настройка параметров обмена данными по RS-485 для modbus-устройств Wiren Board)
111 holding RW 0 настройка бита чётности порта RS-485. Допустимые значения: 0 - нет бита чётности (none), 1 - нечётный (odd), 2 - чётный (even)
112 holding RW 2 количество стоп-битов порта RS-485. Допустимые значения: 1, 2
120 (0x78) holding RW 0 отличное от 0 запись в регистр вызывает перезагрузку модуля без сохранения состояния
121 (0x79) input R - mV текущее напряжение питания модуля
128 (0x80) holding RW 1 Modbus-адрес устройства
200-206 input R {'x','x','x','x','x','x'} сигнатура
220-241 input R __date__ __time__ дата сборки прошивки
250-269 input R строка, null-terminated версия прошивки
270-271 input R 32-bit unsigned int уникальный идентификатор (S/N)
2000-2509 holding RW Буфер периодов IR-приемопередатчика (2000-2201 в прошивках WB-MIR версий до 4.1.0)

Карта регистров флагов и входов (Coils и Inputs)

Начальный адрес Тип Количество Назначение В модификациях
5000 coil 1 Очистка всех банков ИК-команд I
5001 coil 1 Запись ИК-команды с ИК-приёмника в Modbus регистры хранения (2000-2509) (RAM), без сохранения в банк команд I
5002 coil 1 Воспроизведение ИК-команды из Modbus регистров хранения (2000-2509) (RAM) I
5100 (в прошивке 3.1.0 и ранее - 0) coil number_of_banks Воспроизведение ИК-команды из соответствующего банка ROM (Play) I
5200 (в прошивке 3.1.0 и ранее - 1000) coil number_of_banks Редактирование ИК-команд (ROM) с копированием в RAM (ROM -> RAM) I
5300 (в прошивке 3.1.0 и ранее - 2000) coil number_of_banks Запись в банк ИК-команд с использованием IR-приёмника (Learn) I
5400 input number_of_banks Размер данных IR-команды в байтах I

В последних версиях прошивок значение number_of_banks равняется 80, то есть, например, регистры размера команд имеют значения от 5400 до 5479.

Управление модулем из командной строки

Программное обеспечение контроллера Wiren Board включает в себя утилиту modbus_client для работы с устройствами, подключенными к выходам RS-485, по протоколу Modbus, подробное описание команды находится на странице Modbus-client. Доступ к командной строке описан в статье SSH.

Пример чтения регистров

Проверим, верно ли, что мы подключились именно к модулю нужного типа. (Модуль wb-mqtt-serial должен быть предварительно остановлен). По адресу 200 хранится уникальная сигнатура длиной в 6 регистров. Прочтем 6 регистров, начиная с адреса 200, и преобразуем полученный ответ из шестнадцатеричных цифр в символьную строку:

echo  -e `modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 \
-a1 -t0x03 -r200 -c 6 | \
grep Data | sed -e 's/0x00/\\\x/g' -e 's/Data://' -e 's/\s//g'`

В результате выполнения команды получаем строку, например WBMIR. В этом примере модуль WB-MIR имеет Modbus-адрес 1.