Design of Intelligent Lighting System Based on DALI Protocol

Design of Intelligent Lighting System Based on DALI Protocol Zhang Kaiyu, Liu Wei, Lu Yang (School of Information Engineering and Automation, Kunming University of Science and Technology, Kunming 650051, China) The paper introduces the working principle, system composition and system design method of DALI protocol. The PIC chip is used to realize the hardware architecture of the system, the command code used for communication between the computer and the system is defined, and the system application software and hardware interface driver are designed.

0 With the improvement of society and the improvement of the quality of life, people's requirements for lighting equipment are no longer satisfied with simple switch control, but an intelligent lighting control system with energy saving, high efficiency and flexible operation is needed. At present, there are many kinds of lighting control protocols commonly used, among which the Digital Addressable Lighting Interface (DALI) protocol shows its characteristics in the field of intelligent lighting control because of its low development cost, difficulty in system development, easy expansion, and practicability. Strong advantage.

The DALI protocol is an open asynchronous serial digital communication protocol for lighting system control. The DALI system adopts a master-slave structure. The system can connect up to 64 slave units. Each DALI slave uses a unique individual identification address. This address is set during system initialization. The slave address can be modified according to requirements during use. The slave unit can be divided into up to 16 groups (differentiated by group address), each slave can belong to several different groups, and each group of devices can set 16 scenes. The host and the slave use two signal lines to communicate. The data is encoded by Manchester coding. The rising edge of the signal indicates '1', the falling edge indicates “0”, and the communication rate is 1.2 kbaud/s. The host uses two types of communication. Different data frame formats: send frame (host sent to slave) and receive frame (slave sent to host).

The DALI protocol defines a two-byte instruction set for implementing system functions. The instructions are divided into two categories: standard instructions and dedicated instructions. The first byte of the standard instruction is the address byte for addressing the DALI slave; the second byte is the command byte, which is used to control the addressed DALI slave. Using standard instructions, the main controller can implement group control, dimming control, scene setting and other functions for DALI slaves. The dedicated command does not contain the address byte. The two bytes are command codes and are sent by broadcast. They are mainly used to initialize the address of the DALI system. The first byte of the DALI instruction has the following four forms: to specifically identify each group of lighting devices, indicating the range 0~16. The DALI system command is issued by the main controller, and the slave only generates an answer signal when receiving the inquiry command, thereby Signal collisions on the bus are avoided.

2 system function This system is designed to realize intelligent lighting control based on DALI protocol. There are two control modes that can be realized: using computer to control lighting equipment: communication between lighting control system and computer using RS "232 serial protocol, use The computer implements control of the lighting device.

Control the lighting with the main controller: The main controller has simple control buttons and screens, and several common control functions can be realized through a simple menu.

By using the above two control modes of the main controller, the lighting device can realize the following functions: centralized control: the main controller sends commands to centrally control each lighting device.

Separate control: Enables startup, shutdown, dimming, and status monitoring for each lighting device.

Group control: The lighting devices in the system can belong to different device groups, and each group of devices can realize startup, shutdown, and dimming control.

Scene control: Set the scene through the command of the main controller to realize scene switching to meet different lighting control requirements. The parameters of each group of scenes can be modified and saved as needed.

3 system design system design is divided into two parts: main controller design and slave design. 3.1 The main controller design The main controller uses the PIC16F877 MCU as the CPU. The PIC16F87X series MCU is a high-performance 8-bit CMOS microprocessor from Microchip Corporation of the United States. The PIC16F877 has five I/O ports, which are RA, RB, RC, RD, and RE. In addition to the general-purpose I/O functions, these ports also have different dedicated functions, such as PWM output, counter input, and external level interrupt. , I2C bus interface, etc. The PIC16F877's dedicated registers and general-purpose registers are uniformly addressed, for a total of 368 8-bit wide RAM cells (some cells remain unused).

The system main controller is composed of DALI module, RS"232 module, display control module and power supply. The system structure is as shown.

Half-bridge U-lamp ballast diagram i system structure receiving data structure The main controller uses interrupt mode to handle various system functions. The interrupt signals used are: external level change interrupt of RB4 port, used to receive DALI signal; RB0 port INT interrupt, used to call the display control module; RS "232 interrupt, used to process the data obtained by the RS "232 interface.

The system main program first completes the initialization of each function register, then enters the energy-saving sleep state and waits for the interrupt signal.

The interface DALI interface mainly implements the following functions.

1) Conversion of DALI level standard to CMOS level standard DALI level standard stipulates: The signal that the sender considers to be between -4. +4.5V indicates logic* (T, signal representation logic between 11.5V~20.5V) '1'; the receiver considers the signal between -6.5V and +6.5V to indicate logic. The signal between 22.5V represents a logic "1". This is different from the CMOS level standard. In addition to the level shift function, The DALI circuit also has the ability to limit the maximum current flowing through the DALI bus. The DALI protocol specifies that the current on the system bus cannot exceed 250 mA. The system's DALI interface circuit is shown.

When the CPU generates a high level signal, the signal gets a low level through the inverter, so that T3 is turned off; when T3 is turned off, T1 is turned on, and the output is high. When the CPU generates a low level signal, the signal is asserted high by the inverter to turn T3 on, thus turning T1 off and outputting low. R1 is a current limiting resistor. When the current on the DALI bus exceeds 250mA, T2 turns on, which turns off T1 and closes the output interface.

When the DALI interface receives a high level signal, a low level output is generated by the voltage comparator, and then a high level signal is sent to the CPU through the action of the inverter; when the interface receives the low level signal, the comparator generates a high level. The level signal is sent to the CPU through the inverter and sent to the CPU. The host controller uses the PIC4F877's RB4 port to receive the interface level-converted data signal. The port has a system that triggers when the pin external level changes. The function of interrupt processing.

The data frame received by the main controller in the DALI system contains various states of the DALI slave. The data has a logical *CT as a start bit and two non-coded high levels as an end marker. The format is as shown.

The line signal potential DALI system uses two signal lines to transmit data. The voltage difference between the two signals indicates logic "(T and logic" 1*. When there is no number on the bus, the high voltage difference is maintained between the two signal lines. When the data frame is received, the voltage difference is reduced by half a cycle, and then the half cycle is raised (the data frame initial pressure change causes the system interrupt, the interrupt processing completion validity check (the walking bit, the end bit is normal), and the data decapsulation ( The start bit, the node are removed, and the DALI data is extracted (decoded from the data stream).

The DALI protocol has a transmission rate of 1.2 kbaud/s and a signal period of 833 ms. The main controller samples the bus twice per cycle. The sampling delay interval is T/2=417 ms, and the sampling error is 0.08%. Implemented by software. The data receiving function decodes the received data stream using the Manchester encoding rule to obtain DALI data. The data is stored in the register RCDATA (address 0X198). If a data exception occurs during the receiving process, the register RCDATA is cleared. The function flow is as shown.

The data receiving process flow sends the data structure function), 2 (connects to RA4, implements the submenu or "OK" function), and S3 (connects RA5 to implement the function of returning to the previous menu). The transition between menus is as shown.

Before sending, first convert the data into the target data to be sent according to the Manchester encoding rule, and put it in the send buffer (address bits 0X199 ~ 0X19C). The hold time of each target data transmission is 417ms. 1.2 Control, display block master controller control, display module realizes LCD menu control on the main controller. The implemented control functions include group device startup and shutdown, device brightness adjustment, single device startup, shutdown, and scene conversion.

Enter the different control branches via the control buttons. The main controller uses four control buttons, namely: Reset (connecting the system restart end of PIC16F877), 1 (connecting RB0, switching between the same level menus. This article describes the use of PIC microcontroller to implement DALI control protocol. Running in the sleep state, when the menu control is needed, the INT interrupt of the RB0 pin is used to wake up the system and enter the menu control operation.

The 232 module system communicates with the computer using the RS "232 serial protocol, and the lighting control command is input through the computer's super terminal. The input command is decoded on the main controller to generate corresponding DALI control signals, and the main controller will The control signal is transmitted to the slave to set the slave parameters and control the lighting system.

Do level shifting.

The port and the registers TXSTA, RCSTA, TXREG, RCREG, SPBRG implement the RS"232 communication function. The transmission rate is determined by setting the value of the register SPBRG. The calculation formula of the transmission rate is (select high-speed communication): transmission rate = 16 (X + 1) The 6864MHz quartz crystal can accurately generate the transmission rate (in kbaud/s) by changing the initial value of SPBRG: 1. 2, 2.4, 9.6, 19.2, 28.8, 57.6. Configuration register RCSTA selects 10, 11-bit frame Format: Register RCREG is a receive register, which is used to store the received data, and generates an interrupt request when the received data is full of RCREG. The RS"232 transmission rate used by this system is 9.6kbaud/s, and the data format is without parity. 8-bit data of the check digit.

In order to achieve the purpose of computer control system, a set of user command format used on the computer is developed, as follows: (command code) + (address) (command code) control command is input through the computer's super terminal, car"

The key is used as a command input terminator. The main controller uses the general-purpose registers COMREG0~COMREG15 (the address is the received command. The command handler obtains the DALI command code corresponding to the user command according to the received command lookup table (the comparison table between the user command code and the DALI command code), and completes the user. The command to DALI command code conversion, the converted DALI command code is sent by the sending module. The command comparison table (partial) is shown in Table 1.

The design of the power supply part takes into account the controller's volume limitation. It decides to use the resistor and capacitor divider to connect the AC/DC power converter chip MAX612 to provide +5V voltage output. The output voltage is then passed through the boost circuit composed of MAX629 to provide +12V, 16V. The power output meets the system power requirements.

Table i Command Comparison Table User Command Code DALI Code Description Directly turn off the lighting device Use the selected fade rate to light the device Use the selected fade rate to turn off the device. Increase the brightness level directly by 1 level. Reduce the brightness level directly by 1 level. Set the current brightness. Set to the maximum brightness value. The slave status value is restored to the factory setting. Delete the selected scene. Delete the selected slave from the group. Monitor whether the slave works normally. Monitor whether the lighting device is working properly. 3.2 Using the DALI ballast in the slave design system As a DALI slave. The DALI ballast consists of two parts, DALI and ballast control. This system uses the PIC16F877 as the DALI chip and the UBA2104 as the ballast controller. The PIC16F877 EEPROM stores the parameters of the DALI ballast, such as the current intensity level, the ballast power-on level, individual address, search address, random address, group ID, scene intensity value, status information, version number, and so on. The parameters of the ballast are set by the main controller during system initialization. After receiving the initialization command, the ballast calls the EEPR0M write operation and writes the parameters to EEPR0M. It can be modified as needed during the running process. The on-chip EEPROM of the PC16F877 has a total of 256 bytes, and the address range is 00H~FFH. The DALI software of the slave is similar to the DALI software design of the host.

The difference is that the DALI data received by the main controller is single-byte data, and the double data is transmitted; the slave receives double-byte data and transmits single-byte data. Therefore, in software design, the DALI of the slave and the DALI of the host differ only in the number of bits of data received and transmitted.

Slave DALI hardware uses opto-coupled methods to acquire data from the DALI bus. The optocoupler circuit isolates the interference on the one hand and converts the logic signal to a CMOS level on the other hand.

Depending on the command, choose different processing calls (each command has a corresponding handler). These processing programs modify the slave state parameters in the EEPROM, convert the brightness level in the DALI control command into the corresponding pulse width modulation (PWM) signal output, and the PWM signal is converted into an analog signal of 0~10V through the RC converter circuit. UBA2014, controlling the brightness of lighting equipment.

4 Conclusion of the software and hardware design, discussed how to achieve high-reliability intelligent lighting control, detailed analysis of DAL Micro-core Technology Co., Ltd. PIC microcontroller macro assembly and integrated development environment. Shi Chaolin, translated. Beijing: Tsinghua University Press, 2002 Li Xuehai. PIC microcontroller practical tutorial basics. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002 Li Xuehai. PIC microcontroller practical tutorial to improve the article. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002 Dou Zhenzhong, Wang Lisen. PIC series microcontroller application design and examples. Beijing: Beijing University of Aeronautics and Astronautics Press, 1999

Tie Clip

We are customized tie clip, tie clip and cufflink gift set, brass tie clip according to your design, size, color . It`s made by zinc alloy, iron, brass and so on. Used for decoration of Tie. In order to make the tie looks be more tidy, people usually choice this accessory. The process of this item could be stamping or die casting. Plating some color on it comes popular, such as gold, silver, nickel , copper, bronze and so on, Mens Tie Clips are depend on your specific request .

Tie Clip,Gold Tie Clip,Silver Tie Clip,Mens Tie Clips

Shenzhen MingFengXing Art & Craft Products CO., LTD. , https://www.enamelkeychain.com