wb_editors
14 355
правок
(Новая страница: «==== WB-MRGBW-D ==== WB-MRGBW-D is a four channel dimmer to control the led strip. Can control RGB+W tape or four single color tapes independently.…») |
FuzzyBot (обсуждение | вклад) м (FuzzyBot переименовал страницу Драйвер wb-mqtt-serial:Примеры написания шаблонов/en в Wb-mqtt-serial templates/en без оставления перенаправления: Часть переводимой страницы Драйвер wb-mqtt-serial:Примеры написания шаблонов.) |
||
(не показаны 24 промежуточные версии 1 участника) | |||
Строка 1: | Строка 1: | ||
<languages/> | <languages/> | ||
=== The general structure of the device template | === The general structure of the device template=== | ||
A device template file is a [https://en.wikipedia.org/wiki/JSON JSON] structure that describes device parameters. The template allows comments. The JSON structure is written inside the space between the opening and closing braces:<code> { ... }</code> | A device template file is a [https://en.wikipedia.org/wiki/JSON JSON] structure that describes device parameters. The template allows comments. The JSON structure is written inside the space between the opening and closing braces:<code> { ... }</code> | ||
Строка 101: | Строка 100: | ||
==== WB-MS-THLS v.2 ==== | ==== WB-MS-THLS v.2 ==== | ||
The [[WB-MS_Modbus_Sensor/en|WB-MS | The [[WB-MS_Modbus_Sensor/en|WB-MS]] device is a universal combined Modbus sensor for temperature, humidity, lighting and sound pressure. The device provides access to data via Modbus input registers. The initial settings of the device are recorded in the holding registers, but are not used to obtain data and control the device, so the template is not included.You can see the full template code via the following link. | ||
<div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | <div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | ||
Строка 185: | Строка 184: | ||
---- | ---- | ||
==== WB-MRGBW-D ==== [[WB-MRGBW-D|WB-MRGBW-D]] is a four channel dimmer to control the led strip. Can control RGB+W tape or four single color tapes independently. Brightness settings are stored in holding registers; the template describes which registers can be changed to get the desired brightness of the channels, track the dimmer button presses and get the value of the number of clicks. | ==== WB-MRGBW-D ==== [[WB-MRGBW-D/en|WB-MRGBW-D]] is a four channel dimmer to control the led strip. Can control RGB+W tape or four single color tapes independently. Brightness settings are stored in holding registers; the template describes which registers can be changed to get the desired brightness of the channels, track the dimmer button presses and get the value of the number of clicks.You can see the full template code via the following link. | ||
<div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | <div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | ||
Строка 275: | Строка 274: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</div> | </div> | ||
In this template, the RGB composite channel sets the brightness of three color ribbon components stored in three holding registers at the same time and is described as follows: | |||
<syntaxhighlight lang="JSON"> | <syntaxhighlight lang="JSON"> | ||
{ | { | ||
Строка 297: | Строка 296: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The white channel is controlled separately, | |||
<syntaxhighlight lang="JSON"> | <syntaxhighlight lang="JSON"> | ||
{ | { | ||
Строка 307: | Строка 306: | ||
}, | }, | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The maximum value that can be set for the white brightness slider is 255: | |||
<syntaxhighlight lang="JSON">"max": 255</syntaxhighlight> | |||
The serial number of the device (channel "Serial NO") is read as an unsigned 32-bit integer: | |||
<syntaxhighlight lang="JSON">"format": "u32"</syntaxhighlight> | |||
---- | ---- | ||
==== WBIO-DO-R10A-8 ==== | ==== WBIO-DO-R10A-8 ==== | ||
Устройство [[WBIO-DO-R10A-8_Relay_Module|WBIO-DO-R10A-8]] — | Устройство [[WBIO-DO-R10A-8_Relay_Module/en|WBIO-DO-R10A-8]] — is a relay side module that connects directly to the controller's WBIO connector and is not Modbus controlled. But when it is connected via a WB-MIO or WB-MIO-E expansion device, it becomes a full-fledged Modbus device for which there is a corresponding template.You can see the full template code via the following link. | ||
<div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | <div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | ||
Строка 421: | Строка 421: | ||
In this template, you should pay attention to the following device settings. | |||
<syntaxhighlight lang="JSON"> | <syntaxhighlight lang="JSON"> | ||
"protocol": "modbus_io", | "protocol": "modbus_io", | ||
Строка 430: | Строка 430: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Option ''' ''protocol'': ''modbus_io'' ''' indicates that the device connects to the extension module via special protocol. The parameters '''"stride": 1000''' and '''"shift":500''' set the shift of registers depending on the order in which the modules are connected to the extension module. | |||
Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift; | |||
Here stride — DeviceConfig()->Stride, a shift — DeviceConfig()->Shift. | |||
Register shift (the number to be added to the base register number) is calculated by the formula:<syntaxhighlight lang="C++">Shift = (((SlaveId.Secondary - 1) % 4) + 1) * DeviceConfig()->Stride + DeviceConfig()->Shift;</syntaxhighlight> Здесь stride — ''DeviceConfig()->Stride'', a shift — ''DeviceConfig()->Shift''. Each connected device has a serial number (''SlaveId.Secondary'') starting with 1 for the first device. (Here the sign "%" shows modulу division.) | |||
For example, substituting the values of shift and stride in the formula: <syntaxhighlight lang="C++">Shift = ((( 1 - 1) % 4) + 1) * 500 + 1000 = (0 + 1) * 500 + 1000 = 1500</syntaxhighlight> So, you need to add 1500 to all registers specified in the template. | |||
Another important parameter — setup-section, array | |||
<syntaxhighlight lang="JSON"> | <syntaxhighlight lang="JSON"> | ||
"setup": [ { | "setup": [ { | ||
Строка 446: | Строка 451: | ||
...] | ...] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
It describes the registers and values that are entered once in these registers when the device is initialized (when WB-mqtt-serial is started or restarted). It can be used to configure devices to operate in a particular mode, set the initial values of brightness, servo position, relay status, mode of operation with the inputs of relay modules, etc. | |||
---- | ---- | ||
Строка 452: | Строка 457: | ||
==== WB-MAP3H ==== | ==== WB-MAP3H ==== | ||
[[WB-MAP3H_Power_Meter/en|WB-MAP3H]] — three-channel electricity meter. It measures a large number of electrical network parameters. Since it can take quite a long time to poll all registers of such a device, there are several templates that contain the optimal set of parameters for the current task. We'll look at the basic pattern. You can see the full template code via the following link. | |||
<div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | <div class="mw-collapsible mw-collapsed" style="width:500px; overflow: hidden;" > | ||
Строка 864: | Строка 869: | ||
</div> | </div> | ||
What is so important in this template? First of all, we specify in the device parameters that no more than 60 registers should be read at the same time, so as not to stop for a long time the polling of other devices: | |||
'''"max_read_registers" : 60'''. Also the parameter describing the accumulated reactive energy in the phase L1 is indicative: | |||
<syntaxhighlight lang="JSON"> | <syntaxhighlight lang="JSON"> | ||
{ | { | ||
Строка 879: | Строка 884: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Here you should pay attention to the fact that the address of the register can be set in hexadecimal form:''' "address": "0x1224" ''', the real scaling factor can be set in the exponential notation:''' "scale": 3.125 e-05'''', when reading the value round it to the desired order:''' "round_to": 0.0001''', and also take into account that the number in the Modbus-registers is stored in order from the youngest to the oldest: '''"word_order": "little_endian"'''. Storage formats for 16-bit Modbus registers are described as follows: | |||
<pre> | <pre> | ||
big-endian : ( [0xAA 0xBB] [0xCC 0xDD] => 0xAABBCCDD ) | big-endian : ( [0xAA 0xBB] [0xCC 0xDD] => 0xAABBCCDD ) | ||
little-endian : ( [0xAA 0xBB] [0xCC 0xDD] => 0xCCDDAABB ) | little-endian : ( [0xAA 0xBB] [0xCC 0xDD] => 0xCCDDAABB ) | ||
</pre> | </pre> | ||
The default format is big-endian. | |||
The types of variables used in the templates are listed in the following table: | |||
{| class="wikitable" | {| class="wikitable" | ||
! | ! Designation !! Type | ||
|- | |- | ||
| s16 || Signed 16-bit integer | | s16 || Signed 16-bit integer | ||
Строка 926: | Строка 930: | ||
|} | |} | ||
=== | === Information resources === | ||
This article describes the basic rules for creating device templates for Wiren Board controllers. The information changes and is updated as the SOFTWARE is updated and new products are released. The most complete and up-to-date information can be found in the following sources: | |||
* | *in the WB-mqtt-serial service description on GitHub; | ||
* | *in the template files | ||
in the [https://github.com/contactless/wb-mqtt-serial/blob/master/wb-mqtt-serial.schema.json wb-mqtt-serial.schema.json] file on GitHub. |