Light control on ZigBee

Hello friends! Today I want to tell you about one interesting development of a remote lighting control system.

image

A modern house is a huge number of wires to at least somehow reduce and streamline their number radio comes to the rescue. In reality, such a system is not new, but in the context of a limited budget, it has fully justified itself.

Looking ahead, I want to immediately show the functional diagram of the control system.

image
Fig. 1 I

am interested in someone under cat.

The logical question is why all this is needed? The use of a wireless light control system gives:

  • Reducing the number of wires going from each switch to the junction box in the room.
  • Possibility of implementing walk-through switches.
  • The flexibility to control any loads from any switch as well as the use of normally closed normally open buttons.
  • The ability to implement any time delay for operation on / off.

The technical task, in the beginning, was just in words and looked very muddy and incomprehensible. The point is that in a two-story cottage with an area of ​​208 sq.m. it is necessary to control on / off internal lighting, the system should be powered from 220v and switch 21-23pcs. loads (lamps) with a capacity of not more than 200W. At the time of the first inspection of the object it look like this


Figure. 2. The main part of the communications is laid in the floor, then it is all poured with concrete screed


Fig. 3. Place for installing a distribution cabinet on the second floor

The strong recommendation was to use as few wires as possible. Ideally, only those that are already laid in the floor, walls and ceiling, they go from the installation site of the switchboard to each light bulb. Due to the electromagnetic compatibility of all devices in the house, it was not recommended to use ordinary wi-fi because there are countless such devices and the customer on this account has a fad in his head that the devices in the house will begin to live their own lives and the included slow cooker will affect the light in the bathroom or toilet. The first thing I did was to outline the block diagram, as I imagine the solution to this problem. On fig_4 this option.


Fig. 4. Functional diagram of lighting control.

The basis was taken by the Texas Instruments CC2530 radio module which supports ZiegBee technology and is quite simply programmed in C ++ using IAR-studio 5.5. Directly switching loads is performed using the WB-MR6 relay modules (wirenboard), I chose this element because in the compact housing on the din rail, six relays with independent channels are installed on the 16A control, all the features of switching general-purpose power loads are taken into account in t. h with high starting currents: control of LED lamps, incandescent lamps, switching power supplies. Plus, each relay contact is protected against overvoltage by a varistor. Six of these modules had to be installed in order to calmly manage a given number of loads. All WB-MR6 are connected via ModBus interface into a single network. Each relay module is set to an address corresponding to the connection diagram, and the whole system with input blocks, fuses, circuit breakers is pretty tightly mounted in two switchboards SHCHMP2-1 500x400x450. For compact placement of input 46 cables 3x1.5 (single-core copper), it was necessary to change the traditional position of din-rails to vertical.


Fig. 5. Switchboard with placement of lighting control devices.

It should be noted that the incredibly useful function of WB-MR6 was the ability to control relay outputs by simply connecting normally open buttons to the bottom terminal block, this is what you need for a temporary wiring diagram. T.K. ModBus control appeared five months later, after the assembly and installation of switchboards. During this time, all cables going to each load were fully tested and numbered. And a detailed switching scheme has been drawn up, with the control logic of the switch - the light bulb in Fig_6.


Fig. 6. Lighting control scheme and load placement and polling modules.

As for the survey modules, I can say the following, the functional diagram shown in Fig_7 turned out to be quite functional. There was practically no need to redo anything, the ss2530 RF module allows you to assign any inputs to any outputs. The only exception is UART (pin20-Tx, pin21-Rx). Most of the list of elements was bought on ali. Printed circuit boards were ordered on resonate. I soldered all twenty pieces with my hands, it’s hard, it took a week, it didn’t work out right away necessary. But gained invaluable experience installing SMD components.


Fig. 7. Functional diagram of the button polling module

The process of debugging the system and bringing it into a fully operational state took a little more than three months. The first steps after assembling the Rice_8 boards, checking for power and connecting to the programmer, was to write a button polling program and generate control commands for the WB-MR6 relay modules via the ModBus bus.


Fig. 8. Button polling module.

It turned out pretty quickly and simply. One button polling module is connected to one relay module via RS485 so far without a network interface. Immediately managed to apply the obtained success on the object pic_9, twisted pair UTP, from the buttons located in the bedroom, was laid in advance. With the fastening of the modules, I didn’t become very sophisticated, self-adhesive pads and plastic clamps help a lot.


Fig. 9. Attaching button polling modules.

Then he programmatically added the address of each module, which was set using the dip-switch and the corresponding switching card, the master / slave operating mode and the transmission of commands by radio. A step forward was serious and therefore there were many difficulties in debugging. The most serious is the transfer of information about the pressed button to the master module connected to the Modbus bus as soon as the zig-bee data transfer protocol was activated, everything turned out to be much more complicated. For those who have read up to here, I can say that the problem was that the timers in the processor core work unpredictably, more precisely in the IAR compiler, you need to constantly specify its settings when calling the time counting procedure. To find a way to solve this problem, monitoring and control functions of data sent by radio were added. Button click control in service mode, instantly displayed in the hyper-terminal of the computer, which is connected via the RS485-USB adapter to the polling module. Another serious problem in organizing the lighting control network was the inadequate range of the radio interface. More or less, with confidence everything switched only within the limits of the table on which the layout was assembled. This is a consequence of the features of the energy-saving mode of the SS2530, it defaulted to the function of reducing the radiation power, after the link is formed, I don’t know why this was done, but it was found out via jtag in the step-by-step debugging mode. After switching off this mode, the network began to work within only one floor in the cottage, in fact, the on / off light commands were processed by the server, only from the polling modules located within a radius of 12-14 m. Provided there were no walls. To solve this problem, we chose the way to replace the CC2530 module with a planar antenna with a module with an external antenna (with IPEX connector), all the more so since it was very successful to buy three modules in the E18-MSI-IPX version plus an antenna and cable in one of St. Petersburg online stores. All this was quickly soldered, the corners for mounting the antennas were made and screwed to the adapter plates Fig_10.


Fig. 10. Use of an external antenna

The result of such an upgrade was very puzzling to me - because the range has not changed much, I would even say that it has slightly decreased. I began to look for a way out of this situation in optimizing the algorithms of the program, the initial settings of the SS2530 had to re-read the datasheet car and forums on this topic. The goal was to make each module on the network work as a repeater, especially since such a function is enabled by default and is supported by any device running the Zig-Bee protocol. But in my case it was not obvious. As a result, I decided to introduce an additional module into the system, which would have a unique firmware activated by raising only pin_6 on the dip-switch. He had to, was on the ceiling of the first floor and just broadcast the received commands, i.e. be a signal booster.

I will say right away that this was a dead end. But during the implementation of this idea, I accidentally measured the parameters of the “black” antenna, which I sold in an online store along with the CC2530 and cable. The network analyzer showed a SWR 1.9 at a frequency of 2.4 GHz - comments are unnecessary, you need to make your own antenna. A request to the search engine immediately gives the correct answer, the Clover antenna and detailed manufacturing instructions.


Fig. 11. Antenna and device for its manufacture.

Literally in the evening I made three pieces of these antennas, checked their SWR for no worse than 1.2. I can not say about the other characteristics, radiation pattern and gain. But the fact is that the range of reliable reception and sending of commands has doubled. Fig_12


Fig. 12. Antenna measurement

As a result, we managed to achieve normal server signal reception on all 12 polling modules installed in the cottage. T.O. the requirement for TK is fully fulfilled on time; I practically met the deadlines. The customer is satisfied.

Also popular now: