I/O Mapping Matrix/en: различия между версиями

Новая страница: «Leaving input 1 closed, turn off and turn on the relay power: after 20 minutes, relays 1, 2 and 3 will turn on again.»
(Новая страница: «To disable the interaction of inputs and relays (for example, if we want to control the relay only through the controller rules engine), write the value 0 in regi…»)
(Новая страница: «Leaving input 1 closed, turn off and turn on the relay power: after 20 minutes, relays 1, 2 and 3 will turn on again.»)
 
(не показано 18 промежуточных версий этого же участника)
Строка 169: Строка 169:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r9 3 3 3 3 3 3</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r9 3 3 3 3 3 3</syntaxhighlight>


Теперь нажатия на кнопки или переключение выключателей не будет изменять состояние реле: ими можно управлять только программно, по Modbus.
Now clicking on the button or toggle switch will change the relay status you can manage only programmatically via Modbus.
При этом функция аварийного входа 0 сохраняется: кратковременное нажатие на кнопку, подключенную ко входу 0, выключит все реле.
In this case, the function of the emergency input 0 is saved: a short press on the button connected to the input 0 will turn off all the relays.


Если мы хотим отключить и вход 0, то запишем значение 3 в регистр 16:
If we want to disable and input 0, then write the value 3 in register 16:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r16 3</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r16 3</syntaxhighlight>




=== Использование Mapping-матрицы ===
=== Using the Mapping matrix ===
Более сложные сценарии взаимодействия входов с реле можно реализовать с помощью Mapping-матрицы.
More complex scenarios of interaction between inputs and relays can be implemented using a Mapping matrix.
Для использования Mapping-матрицы запишем в holding-регистр 5 значение 0:
To use the Mapping matrix, write the value 0 in the holding register 5:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r5 4 </syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r5 4 </syntaxhighlight>
А в регистры настройки взаимодействия входов/выходов значение 4:
And registers the settings of the interaction of inputs/outputs value 4:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r 9 4 4 4 4 4 4 </syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r 9 4 4 4 4 4 4 </syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r16 4</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r16 4</syntaxhighlight>


В заводской поставке Mapping-матрица заполнена нулями. Если вы не уверены в этом и хотите стереть всю матрицу, запишите 0 в каждый из 64 holding-регистров, начиная с 384:
Mapping mapping-the matrix is filled with zeros. If you are unsure and want to erase the entire matrix, write 0 in each of the 64 holding registers starting with 384:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 $(printf ' 0%.0s' {1..64})</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 $(printf ' 0%.0s' {1..64})</syntaxhighlight>


==== Вход 0 включает и выключает все реле ====
====Input 0 turns all relays on and off ====


Запрограммируем матрицу таким образом, чтобы вход 0, работая в режиме кнопки (выключателя без фиксации) последовательно включал и отключал все реле модуля при замыкании.
Program the matrix in such a way that the input 0, working in the mode of the button (switch without fixation), sequentially turns on and off all the relays of the module when closed.


Для этого обратимся к карте регистров mapping-матрицы и увидим, что входу 0 соответствуют регистры 440 — 447. Причем за взаимодействие со входами 1 — 6 отвечают регистры 440 — 445.
To do this, we turn to the register map of the mapping matrix and see that the input 0 corresponds to the registers 440 — 447. And for interaction with inputs 1 — 6 registers 440 — 445 are responsible.




Мы хотим, чтобы вход работал, как выключатель без фиксации и срабатывал при нажатии (по переднему фронту), а при размыкании ничего бы не происходило. При каждом нажатии состояние всех реле должно инвертироваться. Это соответствует комбинации 11 00: (12, 0x0C) — Изменить состояние выхода при замыкании:
We want the input to work as a switch without locking and triggered when pressed (on the rising edge), and when opened, nothing would happen. The state of all relays must be inverted each time they are pressed. This corresponds to a combination of 11 00: (12, 0x0C) — Change the output state when shorted:
[[File:Mm_1100.png|frameless|270px]]<br>
[[File:Mm_1100.png|frameless|270px]]<br>
Запишем в регистры 440 — 445 значение 12:
Write in the registers 440 — 445 the value of 12:


<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r440 12 12 12 12 12 12</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r440 12 12 12 12 12 12</syntaxhighlight>


Проверим работу: при первом замыкании входа 0 все реле включаются, при втором все реле выключаются.
Let's check the operation: at the first circuit of input 0 all relays are switched on, at the second all relays are switched off.




==== Инвертированный выключатель с фиксацией ====
= = = = = Inverted switch with locking ===
Настроим входы таким образом, чтобы при замкнутых входах реле были бы выключены, а при разомкнутых -- включены.
Set up the inputs so that when closed inputs relay would be disabled, and open -- is included.
Для этого при замыкании входа (передний фронт) соответствующий выход должен выключаться (01), а при размыкании входа (задний фронт) — включаться (10). Это соответствует значению 6: [[File:Mm_0110.png|frameless|270px]]<br>
For this closing input (rising edge) the corresponding output shall be switched off (01), and upon opening the entrance (back front) — included (10). This corresponds to the value 6: [[File:Mm_0110.png|frameless|270px]]<br>
В матрице нужные регистры взаимодействия вход 1 — выход 1, вход 2 — выход 2 и т.д. расположены по диагонали. Это регистры 384, 393, 402, 411, 420, 429. В них надо записать значение 6:
In the matrix, the desired interaction registers input 1 — output 1, input 2 — output 2, etc. are located diagonally. These are registers 384, 393, 402, 411, 420, 429. They need to write the value 6:
<syntaxhighlight lang="bash">for i in 384 393 402 411 420 429; do modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r$i 6; done</syntaxhighlight>
<syntaxhighlight lang="bash">for i in 384 393 402 411 420 429; do modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x06 -r$i 6; done</syntaxhighlight>


Обратите внимание: изменение состояния реле происходят только при изменении состояния ввода.
Note: the relay state changes only when the input state changes.


==== Датчик протечки ====
==== Leak sensor ====


Пусть датчик протечки подключен ко '''входу 1''', а '''реле 1 и 2''' управляют приводами шаровых кранов. '''Реле 3''' управляет сигнальной лампой или зуммером. При смачивании датчика протечки '''реле 1 и реле 2''' замыкаются и приводы закрывают шаровые краны. '''Реле 3''' замыкается и включает зуммер. '''Вход 2''' запрограммируем для сброса тревоги и открытия шаровых кранов.
Let the leak sensor be connected to the '''input 1''', and the '''relays 1 and 2''' control the ball valve actuators. '''Relay 3''' controls the warning lamp or buzzer. When wetting the leakage sensor '''relay 1 and relay 2''' are closed and the actuators close the ball valves. '''Relay 3''' closes and switches on the buzzer. '''Input 2''' will be programmed to reset the alarm and open the ball valves.


Очистим mapping-матрицу:
Clear the mapping matrix:
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 $(printf ' 0%.0s' {1..64})</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 $(printf ' 0%.0s' {1..64})</syntaxhighlight>


Применим в нашем случае режим, когда состояние входа повторяется каждые 20 минут, для этого запишем в регистр 9 значение 5 (управлять в соответствии с mapping-матрицей, через 20 минут повторно имитировать состояние ввода), а в остальные значение 4 (управлять в соответствии с mapping-матрицей).
Apply in our case, the mode when the input state is repeated every 20 minutes, for this write in the register 9 value 5 (control in accordance with the mapping matrix, after 20 minutes to re-simulate the input state), and the rest the value 4 (control in accordance with the mapping matrix).


<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r9 5 4 4 4 4 4</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r9 5 4 4 4 4 4</syntaxhighlight>


Для входа датчика протечки (вход 1) используем режим 1000 (8) — включать при замыкании. [[File:Mm_1000.png|frameless|270px]]<br> Для входа кнопки сброса (вход 2) используем режим 0100 (4) — выключить при замыкании. [[File:Mm_0100.png|frameless|270px]]<br>
To enter the leakage sensor (input 1) use the mode 1000 (8) — turn on when the circuit. [[File:Mm_1000.png|frameless|270px]]<br> To enter the reset button (input 2) use mode 0100 (4) — turn off when closing. [[File:Mm_0100.png|frameless|270px]]<br>


По карте mapping-регистров определяем, что для входа 1 надо записать значение 8 в регистры 384, 385, 386, а для входа 2 — записать значение 4 в регистры 392, 393, 394:
On the map mapping-registers we determine that to enter 1, you need to write the value 8 in the registers 384, 385, 386, and to enter 2 — write the value 4 in the registers 392, 393, 394:


<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 8 8 8</syntaxhighlight>
<syntaxhighlight lang="bash">modbus_client --debug -mrtu -pnone -s2 /dev/ttyRS485-1 -a1 -t0x10 -r384 8 8 8</syntaxhighlight>
Строка 230: Строка 230:




Проверка: замкнем вход 1 и iGND и оставим его замкнутым. Должны включиться реле 1, 2 и 3. Затем замкнем и разомкнем вход 2 — все три реле реле выключились. Ждем 20 минут. Поскольку вход 1 остается замкнутым (протечка не устранена), через 20 минут реле 1, 2 и 3 снова включатся.
Checking: close input 1 and iGND and leave it closed. Relays 1, 2 and 3 must be switched on. Then we close and open the input 2 — all three relay relays are off. Wait 20 minutes. Since input 1 remains closed (leakage is not eliminated), relays 1, 2 and 3 will switch back on after 20 minutes.


Оставляя вход 1 замкнутым, выключим и включим питание реле: через 20 минут реле 1, 2 и 3 снова включатся.
Leaving input 1 closed, turn off and turn on the relay power: after 20 minutes, relays 1, 2 and 3 will turn on again.
12 063

правки