Nikkei Electronics Asia -- June 2009
Insights
Intelligent LED Driver from Analog Peripherals on MCU

E-Mail Article
Tweet This
Digg This
Share this with friends on Facebook
Buzz Up!
Jun 16, 2009 16:30 Nikkei Electronics Asia

While many power-supply systems require quick response times using information from output-feedback networks, converters for general LED lighting may settle for a simpler approach. Because many applications only have access to an AC power source, a flyback converter operating in discontinuous mode can satisfy LED power requirements nicely.

Exploiting the fact that LEDs have a relatively constant forward-voltage drop allows designers to monitor the flyback supply's other more readily available characteristics and be assured of a steady output. LED applications usually demand a low-cost design, so a minimal amount of components and inexpensive feedback are required. This article shows how the peripherals found on an economically priced 8-bit microcontroller (MCU) can be used to supervise a constant power source for general LED lighting.

LED Supervision

The flyback design provides electrical isolation from the AC input. The first item that needs to consider, and the most important, is how to monitor the output current on the secondary side. An isolated flyback converter often requires a feedback network in the form of either a galvanic or opto-isolated sensor, but this increases the cost and complexity of the circuit. Since cost is a primary factor driving the design, finding an alternative solution is therefore crucial.

For this application, the converter is operated in discontinuous conduction mode (DCM), in which the current in the primary winding ramps to its peak value during the ON cycle. As the switch is turned off, the current returns to zero and all of the stored energy is transferred to the secondary winding. When operating in this mode, the output power is a function of the peak current on the primary side, which is easily accessible. Using a simple current-sense resistor to determine the primary inductor current, the right amount of power to deliver to the load can be determined.

Analog Parts on MCU

One of the MCUs which is suitable for this application is the PIC16HV785 from Microchip. There are many analog peripherals onboard on this MCU, so the power control can be handled with very little firmware. These analog peripherals include comparators, pulse-width modulation (PWM) modules, analog-to-digital converters (ADC), op amps, an internal voltage reference, timers, and general I/O. Only a couple of the peripherals are required to implement the core flyback converter. In addition to these peripherals, the internal shunt regulator allows powering of the MCU directly from the rectified high-voltage input.

The Fig illustrates how the MCU is connected in the application. The primary current sense is connected to one of the inputs of a comparator module. The other inputs can be supplied by the internal reference voltage, or they can be generated externally. The voltage reference is produced using one of the onboard PWMs, which provides high-resolution control over the reference voltage.

To drive the gate of the flyback MOSFET, another PWM is employed. The frequency of this PWM is set by an internally configurable time base, and its pulse width is controlled by the previously setup comparator module. To begin the cycle, the timer initially drives the PWM on. As current begins to flow through the inductor, the sense-resistor voltage will rise until the comparator determines it is equal to the reference voltage. At this point, the comparator is configured to shut the PWM off and wait for the timer to start the cycle again.

Code Writing

After the peripherals are setup to handle the hardware, the only thing left to do is to add some intelligence. It is worth noting that up to this point any code have yet to be written, except for a few lines to configure the peripherals. The voltage reference was originally created using a PWM. With just a little bit of code, the reference level can be controlled by writing different values to the PWM register. The adjusted reference value allows for more or less power to be transferred to the output, thus controlling the light levels.

There are still more on-chip peripherals to be used. Other ADCs may be used to collect information from temperature sensors, occupancy sensors, or even to monitor the input voltage. Additionally, more code can be written to make intelligent decisions. Within the context of code writing, the limitation lies in the individual's own imagination.

It is also useful to monitor the voltage on the bias-supply winding. A side effect of this design is the high voltage generated at the output when the load is reduced. In the event that the load is disconnected, the secondary voltage begins to rise to potentially unsafe levels. The higher voltage will also be reflected into the bias winding. Being able to monitor this every few milliseconds will allow the MCU to react accordingly. In this application, the MCU should shutdown the PWM, generate an error condition, and attempt to restart the converter every 10ms. There are plenty of other options that can be implemented within the code.

By using an MCU with analog peripherals, a constant-power flyback converter suitable for general LED lighting can be setup easily. This approach allows us to manage the power section of the inverter and execute firmware for decision making. Firmware enables designers to expand the basic LED into an intelligent lighting source. The examples provided in this article are just a few of the many possibilities.

by Frank Hammerschmidt,
Applications Engineer,
Microchip Technology Inc