Build a LED Gizmo
|
Build a high tech microcontroller based flashlight, learn how step up converters work and get the most out of your batteries with the LED Gizmo.
There are a number of specialized chips available that perform some of the functions of the LED Gizmo. But these were not employed here, in part because this LED Gizmo is for understanding step up converters, but also to keep the part count and costs low. Factor in the ability to add functionality by changing software, and lets not forget, this is more fun!
|
|
LEDs are solid-state semi-conductor devices that convert electrical energy into light. They generate light without as much heat generated as from a conventional incandescent light. Because they are semi-conductor devices, they have a life expectancy much greater than that of an incandescent light. Still they are not quite ready to replace incandescent lighting just yet, at least not in all cases.
In some cases, low heat, power conservation or particular light color are needed, LEDs are a good fit.
The color of an LED is determined by their chemical composition, as is their supply requirements. For example the LED voltage drop for various colors of LED range from 1.7 volts for non-high-brightness red, to 4.6 volts for bright blue
A little about Batteries
The common household Alkaline AA battery is a 1.5 volt cell. In practice they produce a voltage that varies over their life. They generally do start at 1.5 volts, sometimes a little more. They are considered exhausted when they reach 0.9 volts.
The LED Gizmo can power the whole range of LEDs from just 3 volts, and can maintain LED voltage, even as the batteries lose power. It does this by utilizing step-up power converter technology.
How does it work?
The LED Gizmo uses basic properties of inductors. An inductor stores energy by building up a magnetic field, generated by passing a current through it. When the current flow is interrupted, the inductor uses the stored energy of the magnetic field to try to main current flow. In doing this it will induce a voltage to push the current that has built up through a load. The voltage induced can be greater that the supply voltage, however the available current is limited to what has been stored in the inductor.
Hardware
|
In the LED Gizmo circuit this principal is employed using a MOSFET transistor (Q1) to switch the supply voltage to an inductor (L1) on and off. During the on period energy is stored in the inductor, the time that the switch is on determines how much energy is built up. In this state diode D1 does not conduct, so the capacitor C1 must sustain the load. During the off time, the inductor is attempting to maintain current flow, producing a voltage. This voltage flows through D1 and is stored in C1. The capacitor is then discharged though the load, in this case the LED1. By repeating this cycle a voltage is produced that is greater than the input voltage.
|
Click on image for a larger view
|
If everything were constant, this would be enough to supply our LED(s). However batteries lose voltage over time, which means if we want to maintain a constant output, we need to compensate in some manner. The LED Gizmo does this by monitoring the voltage supplied to the LED. This is done using a microcontroller (IC1), operating at 4 Mhz. The microcontroller turns on Q1 causing L1 to begin building a magnetic field. After a fixed period the microcontroller turns off Q1, and begins monitoring voltage. It will not turn Q1 on again until the voltage at the LED falls below a set point. The set point is determined by comparing a constant voltage supplied by a voltage reference (IC2) to a value derived from the LED voltage using a voltage divider, (P1). Both the reference voltage, and the LED voltage provide input to a comparator internal to the microcontroller. When the voltage falls below the set point, the micro-controller will start the cycle over again. This process forms a feedback loop which allows the off time of the switch to vary, compensating for battery voltage that is dropping.
The set point is determined by potentiometer (P1), this allows the set point to be adjusted to meet the needs of the particular LED(s) used. For this project a very powerful 22000 mCd blue-green LED is used, however other LEDs, and even multiple LEDs can be used. Depending on the LED(s) that you use, you may need to use a different value for the current limiting resistor R2.
An additional MOSFET device, Q2 is used to disconnect the load. If this device were not present, a path through the inductor and diode would allow the load to draw current, even when we want it to be off.
Software
The software that is the heart of the LED Gizmo consists of multiple cooperating tasks. The primary task controls the on/off state of the inductor. It turns on Q1 for a fixed time, switches it off and begins monitoring an internal comparator. This process loops forever, and executes whenever there is nothing else to do.
Another task performs the work needed to control the various modes of operation. This task is a state-machine that decides what to do based on the current mode. There are eight modes of operation, ranging from full power on to full power off. To implement these modes, this task turns on and off Q2, stops the background task when no step up voltage is require, etc. This task also implements a power-down state. In this mode everything that can be turn off is, and the microcontroller enters a low-power standby mode.
In order to manage power and to achieve greater efficiency, the microcontroller controls:
- Q1 the inductor on/off
- Q2 the load on/off
- IC2 the voltage reference
It also manages it's own power usage. In the lowest power mode, with all devices turned off and the microcontroller “sleeping” current consumption is so low that the batteries should last their entire shelf time. As a result, there is no on/off switch!
The final task performs scan and debounce of the mode selection button. Note that in addition to this task scanning the keys, the switch is connected to Pin 0 of Port B on the microcontroller. This pin is capable of interrupting the microcontroller even during standby mode. This enables the microcontroller to “wake up” from sleep mode when switch S1 is closed.
Construction and Checkout
The LED Gizmo is simple enough that it can be constructed on a piece of perfboard using standard construction techniques. Get the Firmware
When assembling the board, double-check the polarity of IC1, it is best to use a socket for this component.
After you have completed assembly, it's a good idea to double check for bad or missed solder joints, and reversed polarity of components. If all is well, it's time to “let the smoke out”.
Now that you have completed construction, you are ready to see it work. You will need a source of 3 volts, a pair of ordinary 1.5 volt AA batteries connected in series will do nicely.
With power applied, the LED may start flashing, this indicates that the circuit is receiving power. Don't be alarmed if the LED is not flashing, this may indicate that the set point needs to be adjusted.
Setup/Adjustment
To set up the LED Gizmo you will need a VOM set to measure voltage in the less than 3 volt range. It is helpful to use a precise digital meter, though it's not critical. You will need to measure the voltage present at TP1. Adjust the potentiometer P1 until the voltage less than 1.225 volts. If the LED is not blinking, it should begin to as the adjustment is made. If the LED is not blinking proceed to the trouble shooting section.
One more adjustment needs to be made, the voltage at TP2 needs to be set to the voltage required by the LED. If you are using the LED in the parts list, the voltage should be 3.6 volts. Adjust P1 until this voltage is measured.
At this point the LED Gizmo should be operational, if not proceed to the trouble shooting section.
Troubleshooting
The most likely problem is some component is reversed. Remove power and carefully check for a polarized component that is not correct.
It's also a good idea to check all of you solder joints for joints that are not good, or pins that might have been missed. It's easy to do.
Check the voltage at TP1, it should be below 1.225 volts, if not follow the setup/adjustment steps.
Operation
Hopefully you now have a blinking LED. This is simply a power up indicator. The LED Gizmo has several modes of operation:
- 100% Brightness
- 80% Brightness
- 60% Brightness
- 40 % Brightness
- 20 % Brightness
- 100 % Brightness, 1/2 second strobe
- Short duration pulse, find me mode
- LED off, low power mode
Pressing switch S1 steps through these modes.
Performance
|
You may find that the LED(s) that you are using operate more efficiently when operated below spec, many of the new high output devices do. I have found that I get almost as much light at a lower voltage, and power consumption is much lower. The chart shows performance of the LED Gizmo with one blue-green LED set for 3.4 volts. The graph compares the battery voltage, LED voltage, and the frequency of operation each hour. Batteries were to alkaline 1.5 volt cells, they were considered exhausted when the voltage fell below 2 volts.
|
Click on image for a larger view
|
Further experiments
There are a number further experiments or changes that you might find interesting.
This circuit uses a constant on-time for the inductor. Greater efficiency might we achieved if the on-time of the inductor varied with the supply voltage. This would reduce current demand, possibly extending the already high operating time.
Higher voltage can be generated, you could connect several LEDs in series. You will need to adjust P1 to keep the voltage in the proper range. You will also need to consider if you are exceeding the operating specifications of any of the components.
The feedback loop uses voltage for the feedback. The circuit could be changed to operate in current mode. For example the measuring the voltage drop across the current limiting resistor (R2) might be used to determine current in the circuit.
What other interesting things can you do with the circuit?
PARTS LIST FOR THE LED GIZMO
| SEMICONDUCTORS |
| IC1 | PIC16C620P MicroChips microcontroller |
| IC2 | National LM4041 1.225 volt Voltage reference
|
| Q1, Q2 | BS170P MOSFET transistor
|
| D1 | UF1001P - High speed switching diode
|
| LED1 | 22000 mCd Light Emitting Diode
|
| RESISTORS |
| R1 | 1,000-ohm 1/8-watt
|
| R2 | 100-ohm 1/2-watt
|
| P1 | 10,000-ohm potentiometer
|
| CAPACITORS |
| C1 | 22-mf 25-WVDC, tantalum
|
| C2 | 4.7-mf 16-WVDC, tantalum
|
| ADDITIONAL PARTS |
| X1 | 4 Mhz ceramic resonator
|
| L1 | 1000 mH inductor
|
| S1 | Single-pole, momentary contact, PC mount
|