LEDs, 555s, Flashers, and Light Chasers

Discussion in 'General Electronics Chat' started by Wendy, Feb 8, 2009.

  1. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    LEDs, 555s, Flashers, and Light Chasers

    One of the most common requests at All About Circuits is various methods of flashing LEDs. I'll try to show most of the techniques used for this purpose that have been covered on this site, explaining how and why along the way.


    Index......................................................Skill Level

    1....LEDs...............................................Beginner
    2....Current Limiting............................o...Beginner/Intermediate
    3....The LED / Resistor Only Bargraph....... ..Beginner/Intermediate
    4....The 555 Integrated Circuit..................Beginner/ Intermediate
    5....The 555 and PWM..............................Intermediate
    6....Low Power Applications......................Intermediate
    7....The Joule Thief.................................Intermediate
    8....From Four, Twenty.............................Intermediate
    9....Light Chasers..............................o....Intermediate
    10..Transistor Drivers...............................Beginner/ Intermediate
    .......BJTs
    .......MOSFETs
    11..Making Patterns.............................,/..Intermediate
    12..Special LED Effects.........................,...Beginner/Intermediate
    .......Trobbing LEDs
    .......Fading LEDs (AKA Comet Trails)
    .......Flickering LEDs (Fire!)
    .......RGB LEDs (Millions of Colors)
    ....Conclusion
    ....Appendix

    <Continued in next post>
     
  2. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 1: LEDs

    To design a flasher to order it is important to understand how these parts work. LEDs are simple enough, but they have been around for a long time, and have changed quite a bit from their first commercial release. The old parts were fairly dim, and couldn't use much current. It is now possible to buy LEDs that will use over an amp and easily outshine most light bulbs. This article will deal with the dim to medium 5mm type of LEDs, since that is the majority simple ICs can easily power.

    LEDs are current devices. This means they operate on current once a minimum voltage is provided. Like conventional diodes, they do not limit this current, another component has to do this. Connect an LED to a power source without a resistor and it will be damaged, probably burned out. Figure 1.1 shows the conventional scheme to light up an LED.

    [​IMG]
    ..................Figure 1.1

    The forward dropping voltage, or Vf, of an individual LED is very stable. Go below this voltage and the LED stops conducting. This LED is assumed to be 2.5V, pretty standard for a modern red unit. The target current is 20ma. Going though the math (using Ohm's Law) the resistor is 325Ω. Since 330Ω is the nearest standard resistor value 330Ω it is.

    Here is the approximate Vf of most LEDs:

    ......... Older Generation ... Newer Generation
    Current ....... 10ma ................... 20ma
    Red ............ 1.5V ..................... 2.5V
    Yellow ......... 2.0V .................... 3.0V
    Green ......... 2.0V .................... 3.0V
    Blue ........................................ 3.5V
    White ...................................... 3.5V

    For the Vf of a specific device you need to refer to the datasheet, and also understand there will be some variation even within a family. Part of the reason LEDs have changed so much is their efficiencies have gone way up. A modern LED at full power can damage your eyes if held directly next to the eyeball with the light shining in. Obviously these are not toys for children. Older LEDs didn't come close to these power levels.

    LEDs can also be chained to share the same current to light more than one LED. Since this current is being used twice the apparent efficiency to light these LEDs is increased. Given that the LEDs can vary their Vf it is a really bad idea to parallel LEDs directly. Figure 1.2 shows a fairly typical example of how to do both for increased lighting.

    [​IMG]
    .........................Figure 1.2

    The reason it is such a bad idea for parallel LEDs to share their current limiting resistor is normal variations in Vf can cause one leg to draw more current than the other. This can result in the failure of one chain over time, leaving the second chain to absorb all the current. If you have a lot of LEDs in parallel this can lead to a progressive cascade failure, with LEDs popping like corn. You might be able to get by with it, but it is definitely not good design practice.

    <Continued in next post>
     
  3. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 2: Current Limiting

    If you are dealing with a stable power supply a resistor is good enough. Be sure to use a resistor that is twice the wattage (or more) than is actually needed. Wattage equals the voltage squared across the resistor divided by the resistance (P=V²/R). This is because some resistors may shift in their values if baked out, or overly stressed.

    If the LED current is critical and you need precision, or if the power supply is less than stable, as in the case of automobiles, then better might be needed. A car can vary from 12VDC (battery) to 13.7V when running. This may seem like a small change, but it can create a significant current variation in practice.

    The way around this is to use either a constant current source (current regulator) or voltage regulator. Used properly these circuits will stop power supply or LED Vf variations from affecting the design.

    The LM317 is an excellent IC for this use. It comes in a wide variety of transistor packages big and small, is easy to use, inexpensive, and has excellent performance characteristics. It can be a voltage or current regulator. It's only downside is it drops about 3 volts. Figure 2.1 shows the two ways of using it's current regulation mode, Vcc can be 5.5V up to 37V, the LED doesn't change its brightness a bit (though the LM317 will get hot, and possibly burn up if not properly heatsinked for extreme voltage). The TO220 case style is shown because it is one of the most available models, and it dissipates heat extremely well.

    [​IMG] ... [​IMG]
    ...............................Figure 2.1...................................................................................Figure 2.2

    In the figure 2.2 the current is kept constant by keeping the voltage constant. This way one regulator IC can handle many more diodes. The LM317 requires 10ma minimum on its feedback leg, so 120Ω for R1 is pretty much a requirement, though lower values can be used (with an increase in current and no improvement in performance). If there is a long length of wire between the output of the LM317 and its load (the LEDs) you should add a 0.1µF and 10µF capacitor to the input and output pins of the LM317 to prevent the regulator from oscillating.

    The 3V drop between the input and output of the LM317 IC can make it unsuitable for some uses. Lets go back to the automotive circuit, where the Vcc can vary between 12VDC and 13.7V. We'll start with this example in Figure 2.3.

    [​IMG]
    ..............................................................Figure 2.3

    Each leg the total voltage drop across all three LEDs is 10.8V. If Vcc is 13.7V, then the current through each leg is 19.3ma. These LEDs were rated at 20ma, so the number matches nicely. However, if the voltage goes to 12V the current in each leg drops to 8ma. Quite a difference, and the LEDs will be a lot dimmer. This would be unacceptable.

    If you change the resistors to 56Ω to power the LEDs with 21.4ma at 12V then they would get 51.8ma at 13.7V. Again, this is unacceptable. A regulator is needed. However, remember that the LM317 drops 3V. At 12V it could output 9V, at 13.7 it could output 10.7V. You could remove one of the resistors in the chain, but to use the same number of LEDs the total current would go up by a third.

    Being willing to remove an LED per leg may be the best choice. Sometimes we get so fixated in squeezing every bit of use out of the current the design dependability suffers. It is a personal decision, just be aware when you are skirting this edge.

    The other answer is to go to other designs for the regulator. Here are some I've come up with over time.

    [​IMG]
    ..................................................................................................Figure 2.4

    The first two designs, current regulators, work well. The voltage regulator in Figure 2.4 has an insertion drop of 0.6V, and if everything is perfect it will work. However, the zener diode VR1 has a 5% tolerance, which is 11.4 to 12.6V. The outside ranges just won't work, so it would have to be test selected and the LED resistors adjusted. A friend suggested a programmable shunt regulator that might do this job better, a TL431A. It would replace the zener with a precision value.

    A few tenths of a volt can make huge differences in these designs. If the blue LED had a Vf of 3.8V (a real world value) the voltage regulator would not work.

    For the beginners I may have terrified I apologize. Most times you can get by with a simple resistor, LEDs are pretty easy. I covered some pretty advanced ground here, but look at Figures 1.1 and 1.2, understand them, and you'll have what you need to know.

    <Continued in next post>
     
  4. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 3: The LED / Resistor Only Bargraph

    LEDs tend to drop a constant voltage when they are conducting. It’s not perfect, but it can be used. Take the following schematic in figure 3.1. I’ve included a schematic for a simple variable power supply using transistors and two 9V batteries if you want to experiment with them.

    [​IMG]
    ..........................Figure 3.1

    As you raise the voltage into the circuit you will see some of the LEDs brighten a little before others. This is due to the variations of the resistors (which are usually ±5%) and the Vf of the LEDs themselves. Ideally they should all come on at the same time.

    So what if this effect was cultivated? By using different values for the resistors, we can use the voltage divider effect to turn the LEDs on at different voltages. Once an LED turns on it will stay at the same voltage, and it’s matching resistor will not increase its current as the input voltage (Vin) continues to rise. The remaining current will be routed through LED, causing the LED to get brighter. Figure 3.2 shows how this would work. You’ll note there is an approximate 10% spread between a resistor and the next resistance down.

    [​IMG]
    .........Figure 3.2

    Analyzing what voltages will cause which LEDs to light can be tedious, but is predictable. You have to analyze the circuit from scratch every time an LED turns on, and it is critical the Vf used in the calculations match the LEDs. Small errors accumulate in this design. Start by looking at the main current limiting resistor R1. It doesn’t interact very much with the bargraph, but it does set the total current. Assuming the Vf of the red LEDs is 2.5V, six LEDs work out to be 15V, and the power supply can go to 16.8V with fresh batteries. I chose an arbitrary current of 25ma, figuring 5ma will go to the resistors. So to figure R1 use:

    R1 = (16.8V – (6 X 2.5V)) / 25ma = 72Ω ≈ 75Ω
    It = (16.8V – (6 X 2.5V)) / 75Ω = 24ma

    Next you work through the resistor network. Since R7 is the highest value it will drop the most voltage, turning D6 on first. We are assuming the Vf is 2.5V, so that is the voltage we are interested in for R7, the transition between R7 controlling the voltage and D6. This is a classic voltage divider, so plugging the numbers in looks something like:

    Rt = 75Ω + 300Ω + 330Ω + 360Ω + 390Ω + 430Ω + 470Ω = 2,355Ω
    IR7 = 2.5V / 470Ω = 5.32ma
    VD6 = 5.32ma X 2355Ω = 12.5V

    So at 12.5V the first LED turns on. At this point R7 is not figured as a resistance, but as a constant voltage, and is added to where VD6 is calculated. Repeating the procedure to find where D6 turns on:

    Rt = 75Ω + 300Ω + 330Ω + 360Ω + 390Ω + 430Ω = 1,885Ω
    IR6 = 2.5V / 430Ω = 5.81ma
    VD5 = 5.81ma X 1885Ω = 10.95V + 2.5V = 13.5V

    You repeat this procedure for each LED.

    Rt = 75Ω + 300Ω + 330Ω + 360Ω + 390Ω = 1,455Ω
    IR5 = 2.5V / 390Ω = 6.41ma
    VD4 = 6.41ma X 1455Ω = 9.33V + 5.0V = 14.3V

    Rt = 75Ω + 300Ω + 330Ω + 360Ω = 1,055Ω
    IR4 = 2.5V / 360Ω = 6.94ma
    VD3 = 6.94ma X 1055 = 7.33V + 7.5V = 14.8V

    Rt = 75Ω + 300Ω + 330Ω = 695Ω
    IR3 = 2.5V / 330Ω = 7.58ma
    VD2 = 7.58ma X 695Ω = 5.27V + 10V = 15.3V

    Rt = 75Ω + 300Ω = 375Ω
    IR2 = 2.5V / 300Ω = 8.33ma
    VD1 = 8.33ma X 375Ω = 3.13V + 12.5 = 15.6V

    So this bargraph will start at 12.5V and slowly go up and max out around 16V. You’ll note it is not very linear (though this can be tweaked), it isn’t meant to be. This is not meant for an instrument, but a simple display. There are chips that can do much better at this, such as the LM3914. This chip will do precision displays and a wide range of user options with a minimum of fuss. The schematic shown in figure 3.2 on the other hand will smear, one LED starts to light, but before it is fully illuminated the next one starts to light, so the transition is over 2-4 LEDs. The eye is very good at picking this out however.

    While this isn't meant for instrumentation, it has the potential for such. Older LEDs, with their smaller Vf, work much better for this application since each LED is a smaller increment of voltage. Newer isn't always better. You can also improve the predicted values by measuring the real Vf of each LED, and using the real values in the calculations.

    You aren’t limited to a simple bargraph. Since the resistors choose which LEDs light first you can have several LEDs light up at the same time, or use whatever sequence you choose.

    There are other ways to use the fixed Vf of an LED. Someone had a problem where they wanted the LED to go out when the glove box was closed. The catch was they wanted to turn it off when a switch closed (a magnetic reed switch), which is counter intuitive at first glance. Power to this LED would be cut when the key was removed from the ignition, which allowed for this approach.

    [​IMG]
    ..............................Figure 3.3

    R2 was used to control the wattage used by R1 when S1 is closed. If a simple short was used R1 would go over ½ watts, too much heat in a small space. With the addition of R2 this would go down to an eighth watt. Using a similar resistor divider technique I was attempting to get the voltage under the Vf of the combined diodes.

    Unfortunately the difference between theory and practice caught up with me, but this was fixed by dropping R2 down to 180Ω.

    <Continued in next post>
     
  5. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 4: The 555 Integrated Circuit

    This IC has been around for a long time, over 30 years. The 555 IC could have been designed for LEDs, it is as if they were made for each other. I've written several articles about it, and won't go to the depth I did about the LEDs. Some internals of the 555 IC do need covered, since they relate to LED voltages.

    The 555 has a digital output. It is either switched to the positive voltage (high) or the negative (low). An equivalent drawing of it's output would look something like this:

    [​IMG]
    .........................................................Figure 4.1

    Although Circuit #1 and Circuit #2 look different, they are pretty similar in performance. Generally I prefer circuit #2, but #1 will handle some special LEDs that are a red and green LED in the same package. Alternate between the LEDs fast enough, and it appears yellow. In both cases the 555 output shorts one side or the other, leaving the opposite side to light up with full power. The two internal diodes shown (which are actually two base emitter junctions) generate 1.2V, which swamps the LED Vf it is parallel to.

    So far I have been showing how to light the LEDs at full power, and how to select the resistor for this. An LED will light up with 1ma and be visible, which will work for a lot of indicator applications. Many cases, such as my experiments, I use a 1KΩ for convenience, and don't worry about it. In the above application this would work out to 6.5ma, which works well enough.

    Another issue to be aware of is what the 555 can provide in current. I've already shown it's voltage limitations, but the transistors inside the IC can only provide 200ma before being damaged. There is a general rule in electronics that you should only use half what a component can provide, to make sure the part lasts its expected life. I don't always follow this rule myself, but you need to be aware. The 555 is also rated for 4.5 VDC to 18 VDC, generally this will set the power supply limits of the circuit.

    The 555 is a very open ended ICs, and have a lot more uses than just flashers, but for the purposes of this article we'll concentrate on the flasher applications. Shown in Figure 4.2 are two basic configurations that can be used to flash LEDs.

    [​IMG]
    ........................................................ ............ .........................Figure 4.2

    Oscillator #1 is in the family of Hysteretic Oscillators, which is usually made with op amps. The 555 version adds some its own twists, since the output isn't quite rail to rail (as shown by the two diodes in the first illustration). Its duty cycle is hard to predict, as it is somewhat dependent on power supply voltage. The higher it's power supply voltage, the closer to 50% it becomes. However, for many applications the duty cycle imperfection is hard to see, so it can be used in a large number of applications with good results. You can even put a potentiometer for R1, which allows the flasher to cover a really large range of rates and frequencies.

    Oscillator #2 is straight out of the 555 datasheet. With the addition of a second resistor it overcomes all the problems with oscillator #1, including the 50% duty cycle. For 50% R1 needs to be as low as possible, which is balanced by the fact that at one point R1 is completely across the power supply, thus being one of the components that set the total current draw of the circuit.

    C2 is a bypass capacitor. For a single 555 on a battery you don't really need C2 or any other bypass capacitors, which is why I show it as a "ghost" image. There is an exception to this rule, which will be covered in the following article.

    So what if you need a single LED that is one only 10% of the time? It is simple, use the D1 side for your LED. If you need 90% then use the D2 side for your LED.

    <Continued in next post>
     
  6. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 5: The 555 and PWM

    The 555 has a use that doesn't fall under flasher nor light chaser, but deserves mentioning since it concerns LEDs. That is PWM (Pulse Width Modulation). You could vary the intensity of an LED by varying the current to it, but in many cases this isn't a preferred option, nor is it really linear. PWM allows for truly linear intensity control of a LED.

    Shown below in Figure 5.1 is how PWM works. Basically the intensity of the LED brightness is a direct function of how long the power supply is on versus how long it is off, usually expressed in a percentage. This percentage is a direct indicator of LED intensity.

    [​IMG]
    ...................................................Figure 5.1

    Part of the key to how PWM works is speed, the human eye can not perceived changes faster than 30 frames per second (33 Hz), a fact that is used by TV sets the world over. Under this frequency it is possible the on/off of the LED can be seen as a flicker, faster rates than that the average power is seen as a uniform light. The 555 can go much faster, of course, but this sets the minimum.

    One of the key features of PWM is that since it is fundamentally digital very little power is used when the light is low or off. There is also a second advantage, LEDs are not a linear device. The intensity of the LED does not vary proportionally to current, but it does vary proportionally using PWM. This makes it a preferred method for adjusting LED brightness.

    Figure 5.2 shows several ways to make a quick and easy 555 PWM controller. If you will compare this drawing to Figure 4.2 the resemblances will be obvious. The second drawing is almost the same as the Oscillator 2 in Figure 4.2, since this design has PWM inherent in its design.

    [​IMG]
    .................................................................Figure 5.2

    There are many ways to generate PWM signals, and they have many uses, such as controlling motor speeds or Class D audio amps. LEDs are only one example of how PWM can be used.

    [​IMG]
    ............................................................................................Figure 5.3

    This particular circuit, with minor modification, could be used for a Class D audio amp as well as modulate an LED brightness. It has the added ability to adjust the PWM frequency independently of the PWM percentage, which can be very useful. The LM393 dual comparator and the LM339 quad comparator absolutely require a pull up resistor as shown with R7, usually a 10KΩ resistor. Unused comparators need grounded as shown to prevent unwanted oscillations and current surges. It does not matter if the ouput is grounded or not, but grounding it can make for a simpler printed circuit board design. Since the max current from both chips is 16ma, I've added a transistor driver to reduce its load, and R8 can be tweaked for maximum LED brightness.

    Of course, you may want the 555's drives characteristics, 200 ma both ways is nothing to sneeze at. You can use the following 556 circuit in Figure 5.4 to do the same thing

    [​IMG]
    ...................................................................Figure 5.4

    <Continued in next post>
     
    zola1, garethc and bytraper like this.
  7. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 6: Low Power Applications

    While the 555 isn't a power hog, it is a product of the 70's. It has 15KΩ resistance, not counting the rest of the circuitry. It will drain a battery very quickly, in days if not hours. Several manufacturers have come out with low power CMOS versions, such as the TLC555 and the 7555. These parts are pretty similar to each other, though not exact. They can both drive an LED going to ground (low), but have about 10% the current capability going to Vcc (high). As the power supply voltage drops the current they can provide radically reduces, so with really low voltages you will have to use a transistor to light an LED to full brightness. On the other hand the CMOS versions draw about one hundredth the current for its internal circuitry, so they definitely have their uses.

    Figure 6.1 shows some low power long duration flashers.

    [​IMG]
    ....................................................Figure 6.1

    Oscillator #4 uses a capacitor voltage multiplication to boost the 3V from the battery to almost double that, enough to drive the 3.5V Vf of the blue LED. The Schottky diode drops a fraction of what a conventional diode does, or a Germanium diode could be used for much the same reason.

    Capacitor C2 was added after experimentation showed that it was necessary for maximum life. Without it the circuit basically dimmed and died after two weeks, using AAA alkaline batteries. Adding the capacitor extends the flash life, my test circuit has worked more than 3 months using AAA batteries. This is because the circuit is only on 3% of the time, the remaining 97% the capacitor takes on a charge. I suspect this is a unique case, but it is interesting.

    <Continued in next post>
     
  8. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 7: The Joule Thief

    The classic Joule Thief uses transistors. The basic principle, using an inductor to kick the voltage from the battery up until it will power an LED has also been applied to the 555 also. Figure 7.1 is a redrawn schematic, the original source was uploaded on another thread.

    [​IMG]
    .............................................Figure 7.1

    The 555 has been so useful over time that a dual version, two complete 555s, have come out. They also have their CMOS versions. I applied this to the following schematic.

    [​IMG]
    .............................................................................Figure 7.2

    These schematics use a feature that hasn't been shown to date. Pin 4 is an Enable pin for the 555, it is possible to use a 555 oscillator to control the second one, the voltage booster. This design works, and should make a battery or two last a very long time, but it could be improved quite a bit. Using two batteries to make 3V improves the brightness of the LEDs substantially. You may notice there is no current limiting resistor. This is because at 3V there simply isn't enough voltage to turn the LEDs on, all the current driving these LEDs is coming from the inductive kick of the coil.

    <Continued in next post>
     
  9. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 8: From Four, Twenty

    There is a way to flash 20 different LEDs from 4 555 ICs. Each LED would have it's own flash pattern, no two alike (though some are inverted from others), half of the LEDs will be on at any time for a total of 100ma. Basically we're merging Circuit #1 and Circuit #2 together, and using the way the 555s switch on the outputs for this effect. This could be used in a Christmas Tree, or just a light panel for a kinetic sculpture, or some other special effect. The base idea could be expanded even further for more LEDs, however the current draw on the 555s quickly approaches their limit. For 10ma per LED, 5 would be the max (150ma, 30 LEDs). At 6 would be 42 LEDs (210ma). The colors shown in Figure 8.1 were selected at random, and are by way of example.

    [​IMG]
    .............................................................................................Figure 8.1

    <Continued in next post>
     
  10. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 9: Light Chasers

    Light Chasers take a flasher to the next step. Many cases they are done with microcontrollers, small computers, but that isn't really necessary unless some kind of computation for the display is really needed. Two nifty ICs, the CD4017 and CD4022, are perfect for this kind of application. They will sequence almost any number of outputs. The data sheet shows how to cascade even more 4017s for more than 10 outputs, and one 4017 can do 2-10 outputs. For CMOS this chip has incredible drive, rated up to 6.8ma best case! I have designed it using 10ma for direct drive of LEDs, though this is definitely not recommended by the manufacturer, and may not work in everyones build.

    Figure 9.1 is an old design of mine. This circuit has worked for over 25 years, though not continuously (figure several months on that level). Again, the CD4022 is very stressed, so this isn't a recommended design (but I would use it again in non critical uses).

    [​IMG]
    ..........................................................................................Figure 9.1

    The thing to note about this design is it makes absolutely no difference how many LEDs are in each chain, as long as you are under the Vcc/Vf limit (and don't forget the LM317 3V drop). Why is this important? Take the following circuit in Figure 9.2 as an example.

    [​IMG]
    ..............................................................................Figure 9.2

    With this circuit there are 3 lights apparently chasing around the square. We have all seen variations of this effect on signs and in supermarkets. The thing to remember is this was done by how the LEDs were arranged and wired. It could have as easily been runway lights. I have done this in friends cigarette ashtray with good effect. The arrangement of the lights is more important that the circuit driving them in many cases.

    Note how the CD4022 was limited to 4 counts. This is a common theme in using these chips. The 4017 is probably more popular, but it can be limited in a similar way. This is important when you want to generate patterns, which will be discussed later.

    <Continued in next post>
     
  11. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 10: Transistor Drivers

    The CD4017/4022 low current output means we have to have some means of increasing this drive. It is easy to become spoiled by the 555, with its relatively huge output currents. It can be fun to cheat a little with something like the 4017, forcing it to go beyond it's ratings, but at some point everything will go permanently dark. These chips can work for decades if kept within their ratings. Fortunately it is easy to use transistors as simple switches, to fully drive modern LEDs. A lot of the schematics have already shown this to one degree or another. Most moderate LEDs seem to focus around 20ma. In some cases much more current is needed, either because the LED requires it or there is a large quantity of LEDs.


    BJTs (Bipolar Junction Transistors)

    The humble 2N2222A NPN transistor has been around for many decades, as has its compliment, the 2N2907A PNP transistor. They perform admirably as a switching transistor, with a rated max of 0.6A. If we derate it to 0.3A this will still drive a lot of LEDs. If a job comes up that is too big for this part there are many other much higher rated transistors to choose from.

    There are two ways of using a transistor. The common collector mode shown previously and in Figure 10.1 is a variation of the voltage regulator. It works because CMOS tends to get quite close to the power supplies rails (the plus or minus voltages). The loading on the CMOS chip is the LED current divided by the gain of the transistor. So if a LED array is pulling 100ma, and the gain of the transistor is 50 (which is pretty low, a minimum spec) the current from the CMOS device is 2ma. This design will generate some heat, since the emitter is 0.6V below Vcc (at a minimum). 0.6V X 100ma is 0.06 watts. In extreme cases the transistor can get a lot hotter.

    [​IMG]
    .....................................................................Figure 10.1

    The common emitter mode has a different bag of advantages and disadvantages. The transistor acts like a switch because the collector is very close to the emitter voltage, so it generates very little heat. The two most efficient states for any transistor in terms of wattage is when they are fully on (dropping almost no voltage) or fully off (drawing almost no current). Since wattage is voltage times current (V X I), and you have moved one of the variables close to zero the wattage is a very low number. The disadvantage of this configuration is input current, which has to be controlled by R6. A general rule of thumb is the base current should 1/10 the collector current. This isn't always practical, and the collector current should be the base current times the gain of the transistor (Ic = ßIb), but since gain is such a wildly variable number even within a family, the rule of thumb exists.

    The way around this is to increase the gain of the transistors. Fortunately this is pretty easy to do with only minor drawbacks. Darlington transistors (aka Darlington pair) and a Sziklai pair. The gain is the two transistors gains times each other, and the only major drawback is the collector emitter will have a minimum of 0.6 volts (as opposed to less than 0.1V for a single transistor in common emitter mode). Shown in Figure 10.2 are examples of the two types in use. In both cases the value of R6 can be increased dramatically.

    [​IMG]
    ........................................................................Figure 10.2

    MOSFETs (Metal Oxide Semiconductor Field Effect Transistors)

    Another common transistor used is a MOSFET, this chapter will deal with N channel enhancement. The N channel refers to polarity while the enhancement designation deals with the transistors internal construction. P channel MOSFETs (or pMOSFETs) are similar in the same way that PNP is to NPN on BJTs.

    In many ways this type of transistor is superior to BJTs. Its advantages include almost no switching current (there is an extremely short surge when they switch) and they conduct extremely well when they are on, which means that they rarely get hot. They can conduct extremely high currents, 10 amps or more is not uncommon. Their disadvantages include increased sensitivity to static electricity and at least 10V to switch cleanly, 12V is typical. There is a family of MOSFETs called logic level MOSFETs that can use less voltage to switch (3V to 5V) but they tend to be harder to find.

    MOSFETs are voltage controlled devices. They have a large capacitance on the Gate, which is why they have a surge current. You want to switch these devices as fast as you can to prevent them from getting hot, something that only happens when they are partly on. Something like a 555 does this nicely. Unless you have logic level MOSFETs you really need 12V on the 555 due to the 10V limit on the gate.

    A gate resistor is needed to prevent something called ringing, which might cause the MOSFET to not switch cleanly. This resistor needs to be as close to the Gate as is practical. Shown below is a typical circuit you might use to power a bunch of LEDs, and a typical package for a MOSFET sold by Radio Shack, an IR510. Not all MOSFETs use the same pin outs, you need to look at the data sheet for each part number.

    [​IMG]
    ............................................Figure 10.3


    Driving A MOSFET

    As mentioned, MOSFETs take a lot of short term current to switch cleanly. Their gate looks like a capacitor, with as much as 0.01µF capacitance in extreme cases. If they are being turned on and off infrequently this isn't a problem, once they settle down the current drawn through the gate practically indetectable. However, many of the applications (such as PWM) switches the MOSFET constantly. The large capacitance on the gate can slow the switching speed of the MOSFET, especially if there is a large resistance feeding the gate. The slow switching rates can make the MOSFET run very hot, but if the gate is switched properly the same part will run very close to room temperature.

    The way to address the problem is to provide a buffer to help the gate of the MOSFET switch as quickly as possible. Using the PWM circuit shown in Figure 4.3 with a MOSFET and a NPN and PNP transistor (shown in figure 10.4) can be used to correct the issue. Chips are made to do the same job, but this is a quick and dirty method.

    [​IMG]
    ........................................................................Figure 10.4

    The two BJT transistors will convert the low current drive into a high current drive, which is exactly what the MOSFET needs. The current surges through the BJT transistors aren't enough to cause heating. Normal CMOS gates and a CMOS 555 will also drive a MOSFET nicely by themselves, because while they don't have much drive they can handle the surges the MOSFET needs very well. The transistors used inside a CMOS gate is very similar to a MOSFET.

    <Continued in next post>
     
  12. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Chapter 11: Making Patterns

    Light chasers are cool, but sometimes you want to do more. By steering the current from the 4017 IC sequence other special effects can be created, such as this one.

    [​IMG]
    ...................................................................Figure 11.1

    This circuit will make the LED light sweep back and forth, a popular Hollywood effect. We have also added transistor drivers that will give the LEDs 20ma without significantly loading U2, which means this particular circuit should last. You may need to add some power supply capacitors, but in general battery circuits are pretty stable without them, as the batteries share some of the same characteristics as capacitors. The voltages from 9V batteries tend to drop fast, down to 7.5 volts, and then stabilize, so be aware. The 555 oscillator will go as low as one cycle every 3 seconds, with the other end being faster than the eye can follow, so it is very open ended for the user.

    Another popular design shown in Figure 11.2 is the flasher used in emergency vehicles. This can get you a ticket if you try to use it on a street vehicle, but the basic design is pretty simple.

    [​IMG]
    .................................................Figure 11.2

    [​IMG]
    .......................................................Figure 11.3


    Of course, a design like this practically screams bright lights, so I've shown several options in Figure 11.3. Toys usually use 9V batteries, which can drop as low as 7.5, so this limits what can be done. Some blue LEDs can have a Vf of 3.8V (and 3.8V X 2 = 7.6V). I'd use single transistor in Common Collector configuration shown in Figure 11.3 (also shown in Figure 9.1) to drive individual chains. If the circuit is drawing 100ma for the LEDs, and the transistor has a gain of 50, the current pulled from the CD40XX chips is around 2ma. At 9V and a Vf of 3.8V the LED current is are getting 21ma, if the Vf is 3.5V the LED current is 22ma. At 7.5 and Vf of 3.8 the LED current is 14ma. These calculations show this circuit tries to minimize the current variance for the LEDs. This was covered in the Current Limiting chapter.

    If you have a stable 12V then the options are more open. Since you can put more LEDs per chain the total current per LED is reduced a bit. The calculated current for this layout is 21ma. If the Vf is 3.5 then the current would be 24ma. Again, the variation is minimized.

    But what if you want a lot of LEDs, say 100 of them (50 chains)? This would be a current of 1 amp. A transistor with a gain of 50 would use 20ma through the base, more than the CMOS IC could provide. This would be a good time to use a Sziklai pair as shown. Q2 would definitely have to be a power transistor, but other than that it is pretty straight forward. This would bring the CMOS requirement to 0.4ma, which solves the problem. You could also use the MOSFET shown in Figure 10.3, which is probably the best solution.

    I mentioned earlier that the CD40XX ICs could go above their individual counts. The datasheet shows how to do this, as well as Bill Bowden's Website. Figure 11.4 shows how this is done.

    [​IMG]
    .................................................................Figure 11.4

    The number of transistors and resistors used makes the method shown in Figure 9.1 to drive LEDs more appealing, doesn't it? U3 can be repeated for even more counts, if need be. R5 can be shared as long as you are only turning one LED at a time and using the same color (same Vf). I will be showing some special effects in a later chapter where this won't work.

    <Continued in next post>
     
  13. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    12. Special LED Effects

    Throbbing LEDs

    A common theme with LEDs is to slowly turn them on and slowly turn them off. Some people have called this throbbing, and there are quite a few ways to do it. It can be done simply with a 555 and a couple of transistors. Figure 12.1 shows how this is done.

    [​IMG]
    ................................................................Figure 2.1

    While you can buy Darlington transistors prepackaged you don't want to use them in this case, because they also have a built in resistor that will interfere with the circuit. Instead use two separate transistors, such as 2N2907's. It also requires 9V as a matter of course, due to the way the voltages work out. You can also flip the LED/Transistor upside down and use NPN (2N2222) transistors as shown.

    The voltage needs of the circuit above is a key point against it. You can do something similar with PWM. With PWM the voltage can be less than a volt above the Vf of the LED, a major advantage. It also can handle a lot more power without anything getting hot, another major advantage. Figure 12.2A shows the basic setup for doing this. Note the similarity of the schematic to Figure 4.3. Due to the low power supply voltage a CMOS 555 was used. I also used a LM393, which is a dual comparator similar to the quad LM339 shown earlier. Both chips require a pull up resistor on the output, and in the case of the MOSFET, a more robust driver.

    [​IMG]
    ........................................................................Figure 12.2

    Since this circuit requires two 555's as a matter of course I've also included how you would wire a 556 (a dual 555) to do the same job in Figure 12.2B. I've assumed that D1 and D2 Vf is 2.2V, different dropping voltages would require adjustments in R5 and R6. What if D2 were a blue LED that dropped 3.6V? The power supply would have to be increased, Figure 12.2C shows how the end result might look.

    Another side feature of this design is the LEDs will be in complete sync, they will become dark and hit their maximum brightness together, even though the individual LED legs are quite different.

    I mentioned that this design could achieve much higher power levels. Figure 12.2D shows how this is done with a 12VDC power supply. If used in a car be careful how you implement it, as it could get you a traffic ticket for having emergency lights without a license.


    Fading LEDs (AKA Comet Trails)

    The sweeping lights shown in Figure 11.1 are interesting and dramatic, but they can be improved if the lights fade slowly, creating a trail behind the sweeping pattern. This mode has also been called a comet trail, and can be accomplished by using the circuit shown in Figure 12.3A, which is attached to the outputs of the 4017 shown in Figure 11.1. There the emitter following transistor circuit work with the capacitors to delay the LED going out just a little, creating a trail of fading LEDs behind the LED actively being lite.

    A friend of mine who goes by the handle of Fenris did this in one of his projects, and posted the details at Project: Knight Rider style sweeping light. It has schematics as well as some videos of the final product.

    The first example shown works, but charging the capacitor can overload the 4071's feeding it, so Figure 12.3B shows how this loading could be reduced, putting the brunt of the current on Q2 to charge the cap. If you need more than one input (which sweeping lights will need) you can use Figure 12.3C. Note that the extra transistors are also replacing the diodes in the circuit.

    Figure 12.3D shows how you would use this concept in a total circuit. It is pretty similar to the schematic shown in Figure 11.4, but I simplified it somewhat to reduce the size of the schematic.

    [​IMG]
    .........................................................................Figure 12.3


    Flickering LEDs (Fire!)

    Another effect that is often wanted is flickering LEDs. The flicker is harder than it sounds, it isn't a simple circuit. MicroControllers often use tables and other tricks to create a pseudo random number that controls the brightness of the LED, but there is an older technique that works quite well.

    Back in the day of tube radios model train enthusiasts would use a small light bulb connected to an AM radio in place of the speaker. The bulb would glow a dim red and flicker, almost like a camp fire, when the radio was tuned to a station.

    Modern portable radios don't have anything like the voltages older tube radios used, but you can still use the base concept. It doesn't matter if it is AM or FM. Feed the earphone output of the radio into either one of the following circuits.

    [​IMG]
    ........................................................................................Figure 12.4

    If you need a small light the simple transistor circuit in Figure 12.4A would work, while the Figure 12.4B would be for a bigger flame, such as you might see in a Halloween Cauldron that is often commercially available, the kind that uses fans, ribbons, and lights to create a large flame effect.

    If the source is a stereo radio then you could have two banks of LEDs almost in sync with each other. This would make for an even better effect.

    This circuit is basically a single channel color organ. Add audio frequency filters and it would be straight out of the sixties.


    RGB LEDs (Millions of Colors)

    Now we come to a fairly new device, a LED that has 3 colors (and 3 LEDs) built in. They can be common anode or common cathode (in other words, the direction of the LEDs can be different), but they are usually 4 lead devices, with one of the leads being shared by all 3 LEDs.

    [​IMG]
    ........................................................................................Figure 12.6[/SIZE]

    While a 555 or 556 would work well for this design there is another way that will dramatically cut parts count. The CMOS chip 40106 has 6 Schmitt Trigger inverters in one package with a power supply spec of 3V to 15V, and since we need four of them this one chip can replace two 556 chips (or four 555's). As usual the unused gates are tied off to prevent oscillations and other unwanted problems.

    This design has 3 independent oscillators, which will all fade the LEDs all the way on and all the way off. You will probably want to vary R2, R5, and R8 a little to make them oscillate at slightly different frequencies, but even simple variations in tolerances of the components will cause them to vary. Over time, every possible intensity of RGB will be displayed, each with its own color (much like a color TV). It will cover the entire visible spectrum, baring imperfections in the LED itself.


    <Continued in next post>
     
  14. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Conclusion

    LEDs are among the more fun circuits to build. They are easy to construct, give instant feedback when they work, and can be tweaked in many different ways. Your imagination can take these basic ideas even further. The field is still advancing very quickly, future models of LEDs will probably replace light bulbs, and we'll be building circuits to make them do wild and crazy things right along side. If you are interested in the history of these LEDs, I would recommend the online LED Museum.

    <Continued in next post>
     
  15. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    Appendix

    People have been coming up with schematics based off of the work here. I'll link or attach the schematics for easy access. As they come out with them I'll post them here. Many cases the schematics will be slightly modified as to fit their requirements, but a working PCB layout is always easier to wire than prototyping.


    For Figure 11.4
    25 LED Open Ended Sequencer

    An approach from nerdegutta

    Another good idea I'll be posting soon.

    100 LED chaser
     
    Last edited: Jan 17, 2016
  16. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    <edit 3/1/2013>

    As mentioned in the header, some of the following information is obsolete. I will leave it intact for archive purposes.

    This is the second thread I've used to write this article, the first thread is here.

    Some people commented on it before I had a brainstorm about how I wanted to format this article, so the second thread became necessary. Unfortunately the time date stamp limitations won't allow us to merge the new and old threads (without messing it up in the way I was avoiding by starting this new one). Convoluted enough for you?

    Anyhow, I value the comments (even the one that stated that this was a waste of time, and went on from there) had some points I used to improve this article. I do not want to delete them, and this would be contrary to the spirit of this site anyhow so it wouldn't happen. Any future comments should be made here.

    Thank you.

    If you don't feel like clicking the link here is the summery.

     
    Last edited: Mar 1, 2013
  17. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Why not finish your book, then post it?
    I get too many "reply to thread" from you while you post the bits and pieces.
     
  18. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,765
    2,535
    If I knew what you were talking about I might have an answer. I've written this in widely separated locations, whenever I had an internet connected computer. I had a major push on to finsh 95% of it tonight. There will be some minor editing required, both in the images and content.

    Besides, I wasn't writing this for you, you already know it all! :p :D
     
  19. Jure George

    Active Member

    Dec 28, 2008
    51
    0
    Mr. Marsden

    Could you modify your Fig. 8 circuit with the Two LEDs ? I need one that will work on a battery voltage of 6v to 12v and I know the 555 I.C will handle that range. Also I need a variable resistor of 50k, I have lots of them in stock, so that I can have Either One LED or use Two but can adjust the flashing rate to simulate a flame in a wood stove. Can you please include all the parts in a circuit that I can put together ?

    P.S. I am the same person who sent you a P.M about this.

    Thanks For Time and Help.

    Jure George
     
  20. Audioguru

    New Member

    Dec 20, 2007
    9,411
    896
    Hi Bill,
    You have a problem with the polarity of the diodes in figure 20.
     
Loading...