📜 ⬆️ ⬇️

Our devices to control the lighting in the smart home

image

Hello!


Almost a year ago, we first introduced our automation controller, Wiren Board Smart Home . Soon we will launch sales of its new version - Wiren Board 4 , and today we will tell about our two new devices from the class of budget wire peripherals for home automation.

To create a smart home with one central controller is indispensable: some additional actuators are also required.
The Wiren Board controller was previously positioned as a universal center of a smart home that controls third-party actuators.
However, it became clear that the choice of periphery for budget installations is very limited, and the problem is particularly acute, oddly enough, in the most common area of ​​home automation - in lighting control.


')

1. What are the options?



Among the ready-made wireless devices to control the light of the budget segment, the choice consists of unidirectional (without feedback) devices operating at 433 MHz:


The lack of feedback, together with the use of the 433.92 MHz noisy range, makes the use of these devices in home automation very inconvenient. The closest-priced devices with feedback (Z-wave) are several times more expensive.

With wired devices, the situation is slightly better: in the budget segment there are devices based on Modbus or ADICON protocols, which are produced by several manufacturers: ICP-DAS, “Smart House”, Uniel. Many products of these manufacturers are successful, but in general the price of devices and the price per channel in those actuators that are not terrible to use is not as low as we would like. Some manufacturers do not work with retail customers, and few who always have them in stock.

Seeing this sad situation, we decided to launch our line of wired peripherals.

As a trial balloon, a dimmer for LED strips and a relay unit that works using the Modbus protocol, RS-485 standard, were chosen.


2. Why was Modbus chosen?



Modbus RTU is an open communication protocol based on a master-slave architecture. Widely used in industry. It is very simple to implement. RS-485 is a standard for transmitting data using a differential signal over a twisted pair cable of the “common bus” type, therefore the communication line is reliable and noise-resistant. The price paid for this is the need to lay a cable.

In home automation, RS-485 is convenient in that it can be bred using conventional CAT5 twisted pair for Ethernet. In this case, one pair is used for data, two more - for power, one remains free. All devices are connected in parallel to the same cable. Branches, “stars” and rings in the network topology are not allowed by the standard, but in practice even such networks work well at distances of tens of meters.




3. Local management



Modules are controlled both via Modbus and locally by connecting two external control buttons. This allows the modules to work completely autonomously. Therefore, by connecting a wall switch, you can control the lighting from it. This is convenient and generally improves the reliability of the entire system: if the central controller fails or the RS-485 bus fails, the lighting continues to operate normally - simply without automation.

Different operation modes of the buttons are supported: non-latching switches (most conveniently), regular latching switches.

Since the modules work in standalone mode, and almost all PLCs and controllers for home automation support the Modbus protocol, the modules can be laid during repair for future connection to the home automation system.

On modules it is also possible to assemble groups of pass-through switches, including using more than two switches connected in parallel. It will work even without a central controller.


4. Centralized management



A bus with devices needs to be connected to a home automation controller for management. We developed devices for use with the Wiren Board controller, but there are no restrictions on using modules with other controllers that support Modbus RTU. A description of all registers is available on our wiki .

Each Modbus device on the bus must have a unique address, so the standard for installations on Modbus is the procedure of pre-setting the address. The address is set by sending a broadcast write command to the appropriate register, with only one device connected to the port.
We tried to simplify the life of users in this place as much as possible, and distribute devices with predefined addresses that are written on the modules.

In addition to standard operations — setting the color for the LED dimmer and the relay status for the relay module — several other interesting features are realized in the devices.

The relay module has a “Safety timer” function, which allows you to turn off the relay if the module has not been interrogated by the central controller for a specified time. The function is useful, for example, to control heaters in thermostats, when it is important that the load does not remain turned on in emergency situations, for example, when the bus is broken or if there is a problem with the central controller.

image

Both devices allow the controller to read the current state of the buttons. Each button is also associated with a register counter, which stores the number of clicks on the corresponding button. This allows the use of buttons connected to devices in user rules.

All these functions are available through the Modbus registers and are supported by the appropriate software on the Wiren Board (the code, as usual, is open and works on any device with Linux).

In addition, the modules have several service blocks of registers. In one of these blocks, a model identifier is recorded, which allows automatic identification of devices on the bus. In one more block, the firmware version is recorded.


5. Design features of the modules:



The use of one-sided surface mounting allows the modules to be made quite compact and easy to manufacture. The packageless version (shrinkable tubing) significantly reduces the cost.

image


The brains of the modules are an inexpensive STM32F0 microcontroller, with a large margin of possibilities.
The consumption of the microcontroller and transceiver RS-485 is quite small, which allows the use of linear regulators for their power. The operating voltage range of the modules is 8-24V .
Such a wide range of operating voltages is due to the lack of a single standard in home automation: in different systems, both 12V and 24V are used. In addition, we wanted to ensure stable operation even when the voltage on the cables subsided.

In order for the relay module to work in a wide voltage range, the following trick was used: the relays have a working voltage of 12 volts, but the MC measures the input voltage and controls the relay coil using PWM with a duty cycle of D = 12V / Ui, i.e. the average current through the relay coil remains nominal even at high input voltages. Also after switching on the relay, the holding current is set to half the nominal - this reduces the heating of the relay and the total consumption of the device by 4 times.

When using PWM, there is a feature: at low frequencies, the relays work as a speaker. So that the devices do not squeak, the PWM frequency is output outside the audio range and is 24 kHz.

Power transistors LED dimmer WB-RGB - IRF8736 (Vmax = 30V, the resistance of the channel only ~ 5mOhm). Buffer 74HC125 increases the control voltage from 3.3V from MK to 5V on the gates. This allows such a small scarf to remain cold even at a current of 5A per channel.

PWM is used to control the brightness of LED strips in the LED dimmer. In the overwhelming majority of competing products, the frequency of PWM is in the region of 100-200 Hz, and in particularly bad cases this leads to a noticeable flicker of illumination. In our device, PWM operates at a higher frequency. As in the case of the relay, the frequency is displayed on the border of the audio range, but here it is done to avoid peeping of some not very high-quality power supplies of LED strips.

Obviously, the function of maintaining the state of the module when power is turned off is highly desirable. STM32F0 has an unpleasant feature in this regard: it does not have a built-in EEPROM, only flash-memory with a very limited rewriting resource.
Writing to flash memory each time a new value is received is too wasteful, so the state is stored in RAM and flushed to the flash only when power is lost. The moment of switching off is monitored by a voltage drop below a certain threshold.

It’s not enough to save the state when turned off. The number of overwrites per cell is limited to a thousand cycles. Therefore, the next level of optimization is to use all free memory, i.e. write values ​​evenly using different cells.

The operation of writing a bit (i.e. setting a single value) to flash memory is fast, but erasing is performed only page by page, takes a lot of time and requires a lot of energy. If there are no free cells left, you need to erase the entire page before writing the new value. For this, you would have to put a huge capacitor for "backup power" when you turn it off.

We use the following technique: when turning on the MK, we first check the availability of free space for recording in flash, if it is not there, then we free up space for future recording by erasing pages.
image



6. Prices and plans



Since our main goal is to expand the ecosystem for Wiren Board controllers, we set fairly affordable prices for new modules, which are lower than those of competing products:
  1. two-channel relay on a DIN rail WB-MR2-DIN costs 2000r
  2. the same two-channel relay WB-MR2 in heat shrink - 1500r
  3. RGB-dimmer WB-MRGB: 2100 rubles .


We plan to expand the line of devices on Modbus, so we will be happy to receive feedback in the vote and in the comments about which modules you would like to see on sale.

Source: https://habr.com/ru/post/255657/


All Articles