Design of dimming controller based on ATmegal 28

Publisher:sigma28Latest update time:2011-03-31 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction
Energy saving is an important indicator in lighting control. At present, there are analog dimming control systems and digital dimming control systems. The analog dimming control system includes an analog dimming console (dimmer controller) and an analog dimmer. Among them, the analog dimming console outputs a 0-10 V control voltage, and adjusts the light intensity of the lamps it carries through the 0-10 V interface of the analog dimmer. The digital dimming control system includes a digital dimming console (dimmer controller) and a digital dimmer. The protocol it adopts is the DMX512 control protocol, and the physical interface of the protocol is RS485. Although the digital dimming control system has
its advantages, it cannot completely replace the analog control system in a short time due to the cost, and analog dimming control still accounts for a large proportion. Most of the existing analog dimming consoles use pull rods, knobs, switches, etc. to convert analog signals. Their control accuracy is not high, the volume is large, and they only realize the on-off control of lamps. Therefore, it is very necessary to develop a dimming controller with high control accuracy, moderate volume, and the ability to achieve a variety of lighting effect changes. In recent years, PCs are often used in simple industrial control due to their graphical interface and easy operation, and the cost of single-chip microcomputers has gradually decreased. This paper combines PCs and single-chip microcomputers to design an analog dimming controller, which can realize the control of various lighting effects through the dimming software of the host computer.

1 Overall design
The overall design of the analog dimming control system is shown in Figure 1. The control software running on the PC host sends control commands through the RS232 serial port, and the dimming controller generates corresponding 0-10 V control signals (256 levels) according to the given instructions. Through the 0-10 V interface of the dimmable electronic ballast and the LED dimmable driver, the brightness of the corresponding lamps is further controlled according to the corresponding control voltage to achieve the purpose of dimming. In addition, the light intensity sensor collects the real-time light intensity of the scene and sends it to the dimming controller. The host computer reads the light intensity through the instruction and displays it on the control interface, and then adjusts the control voltage according to the given value to realize the closed-loop control of the light. This paper focuses on the design method of the dimming controller.



2 Hardware Implementation
2.1 Single Chip

Microcomputer The single chip microcomputer uses Atmel's 8-bit low-power CMOS microprocessor ATmegal28 based on AVR RISC structure. It has 128 KB Flash, 53 general-purpose I/O ports, 4 flexible timers/counters with comparison mode and PWM function, 2 USARTs, 8-channel 10-bit ADC (with optional programmable gain), JTAG on-chip debugging interface, and 6 power saving modes that can be selected by software. By integrating the 8-bit CPU and the programmable Flash in the system into one chip, ATmegal28 provides a flexible and low-cost solution for many embedded control applications.
ATmegal28 can provide two serial port functions: one serial port is used to communicate with the host computer; the other serial port is reserved for DMX512 digital control mode, so that the controller can be used as an analog dimming control to output 0~10 V analog control signal in the future, and can also be used as a digital dimming controller to output digital control signals that comply with the DMX512 control protocol.
2.2 Power module
ATmegal28 needs 5 V power supply, AD7226 needs 15 V power supply and 10 V voltage as reference voltage. The external power supply uses a 15 V switching power supply, and the 5 V power supply of the microcontroller and the 10 V reference voltage of AD7226 are realized by the voltage regulator chips LM2940T-5 and LM2940T-10 respectively.
2.3 Key module
The key module provides dimming shortcut operation on the dimming controller. The 4 keys are 25%, 50%, 75%, and 100% dimming, respectively connected to the PE4, PE5, PE6, and PE7 external interrupt pins. When the key is pressed, the external interrupt is triggered.
2.4 Serial port module
The serial port module of the microcontroller is used to communicate with the host PC. Since the level of the PC RS232 serial port is inconsistent with the level definition of the microcontroller UART serial port, the level conversion is performed here through the MAX232 chip.
2.5 A/D module
The light intensity sensor uses the YSCG-X new light intensity sensor from Beijing Yishengtaihe Technology Co., Ltd., with a range of 0 to 2000 lux and a standard output of 4 to 20 mA. The output of the sensor is connected to pin PF0, and the current is converted into voltage through a resistor outside the PF0 pin for sampling. Since the input of A/D sampling is up to 5 V, the resistor should be a 249 Ω resistor. In addition, in order to ensure the accuracy of sampling, a voltage follower is added to the circuit.
2.6 D/A conversion module
The D/A conversion module is actually the output module of the dimming controller. The AD7226 of ADI is used to generate a voltage of 0 to 10 V. AD7226 has a 4-channel D/A converter with 8-bit accuracy and a minimum resolution of 4 mV, which can meet the design accuracy requirements. Each channel has an input latch that can latch the input digital quantity, and the output end has an output buffer amplifier. The hardware circuit of the D/A conversion module is shown in Figure 2.


Among them, /WR is the control line, A0 and A1 are two address lines, and different D/A channels can be selected through the address lines. The controller is designed to have 12-channel output, so three AD7226 chips are used. The connection method of the data line and address line is the same as that of the microcontroller, except that the control line /WR is connected to different microcontroller pins as the chip latch pin, and the control lines of the three chips are connected to PA4, PA5, and PA6 respectively.

3 Software Design
3.1 Variable Definition
The controller contains 12 independent channels and needs to send the light intensity collected on site to the host computer for display, so the array channelData[13] is defined. Among them, channelData[O]~channelData[11] store the actual control voltage (0~255) of the corresponding channels 1~12, and channelData[12] stores the on-site light intensity sampled by the sensor. The variable write_end indicates whether the value of channelData[O]~channelData[11] has been modified. Write_end=1 indicates that the modification is completed.
3.2 Main Program
The host computer controls the dimming controller through serial port interrupts, the shortcut keys on the dimming controller are implemented through I/O external interrupts, and the sampling interval of the sensor is implemented through timer interrupts. The priority of the three interrupts is; timer interrupt>I/O external interrupt>serial port interrupt. The main program flow is shown in Figure 3.


When the serial port interrupt is responded, first determine whether the host computer's instruction is a read operation or a write operation. If it is a write operation, return the same instruction as the response instruction, change the value of the corresponding channel in channelData[] according to the instruction, and set write_end to 1. If it is a read instruction, return the data of the corresponding channel in channelData[] or the on-site light intensity according to the address as a response.
When the timer interrupt is responded, sample the on-site light intensity through the sensor. In order to ensure the accuracy of the data, the algorithm uses the average value of 16 samples as the effective value and stores it in channel-Data[12]. When
the I/O external interrupt is responded, first determine whether it is caused by key jitter. If it is jitter, return; otherwise, change the value of channelData[O]~channelData[11] to the voltage value represented by the shortcut key, and set write_end to 1.
Finally, determine whether the variable write_end is 1. If write_end=1, execute the function DAOperation(channelData, 12), output the corresponding channel values ​​(0~255) in channelData[0]~channelData[11] with 0~10 V voltage, and then clear write_end to 0.

4 Experimental results
When the host computer adjusts the control voltage of channel 1 to 2.5 V, the actual measured voltage of channel 1 is shown in Figure 4. It can be seen from the figure that the actual voltage is 2.46 V, of which the voltage drop of 0.04 V is caused by the 100 Ω resistor of the AD7226 chip pin.


In actual measurements, it was found that when the power supply was not connected, there was an interference voltage of 40 mV and 50 Hz in the controller, as shown in Figure 5. In order to reduce this low-frequency interference, a 47 μF capacitor was connected to the D/A output pin (see Figure 2), and a good effect was achieved.



5 Summary
The 8-bit ATmegal28 microcontroller can accurately realize a multi-level adjustable 0-10 V control voltage with a resolution of 40 mV. The light intensity of each channel can be quickly adjusted through 4 buttons on the dimming controller. In addition, the independent dimming of a single channel, the fast dimming of all channels and the closed-loop control of the light can be realized through the host computer.

Reference address:Design of dimming controller based on ATmegal 28

Previous article:Subdivision Control of Instrument Stepper Motor Based on ATMEGA48 Single Chip Microcomputer
Next article:Design of frequency converter based on TMS320F2808 direct torque control

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号