Featured Projects in the Current Issue


  • Planet Jupiter Receiver
  • Ultra-LD 200W Power Amplifier - Part 2
  • Low voltage Adjustable Regulator
  • Balance/Unbalanced converter for Audio Work
  • Ingenuity Unlimited
 
Home


Controlling Tri-Color LEDs PDF Print E-mail
Clive 'Max' Maxfield
Clive 'Max' Maxfield
I love playing with tri-color LEDs, but controlling them can be a real pain. I find it really surprising that there aren’t any cheap-and-cheerful control devices out there. Fortunately, my friend Joe Farr came to the rescue... I'm currently working on a hobby project that shall remain nameless (the other folks at EPE say that they are tired of my waffling on about my "Display-O-Meter" ... Oooops!)

As part of this project, I intend to have a lot of colorful LEDs on the front panel. Originally I was planning on using the usual suspects (Red, Green, Yellow, Orange...). The problem with these is that they are either On or Off. This means that if I have a two-way switch-LED combo, for example, then when the switch is in one position the LED will be on ("Ooooh, Shiny"), but when the switch is in its other position the LED will be off ("How Boring").

One alternative would be to use bi-color LEDs . For example, you can get a Red-Green combo in a single package. In the case of a 2-pin package, applying a potential across the terminals one way turns the Red LED on and disables the Green LED; reversing the potential activates the Green LED and disables the Red LED. By comparison, in the case of a 3-pin package, one pin will be a common anode (or a common cathode) and the other two pins will control the LEDs individually.

This is obviously more interesting but ... if we're going to do this at all, let's do it with style and employ  tri-color LEDs . In this case, we have three LEDs (Red, Green, and Blue) in a single 4-pin package. Once again, one of these pins will be a common anode (or a common cathode), while the other three pins will control the LEDs.

These tri-color LEDs used to be mega-expensive... indeed, they still are if you purchase them individually from places like  Radio Shack , which charges $2.99 each for the little rascals. However, you can get good deals if you look around, and
I managed to pick up a pack of 50 of the little scamps for only $10 on eBay (I LOVE the Internet).

Now, if we intend to simply turn the LEDs full on or full off, we can achieve only eight combinations (including them all being Off = Black) as illustrated below:
 
Tri-Colored LEDS
Tri-Colored LEDS

As we see, ideally we should be able to achieve Red, Green, Blue, Green+Blue = Cyan, Red+Blue = Magenta, Red+Green = Yellow, and Red+Green+Blue = White.

But there's a problem. If we have only one LED on it will have a certain intensity or brightness. If we turn two LEDs on the resulting hue will be twice as bright as for a single LED. And when we have all three LEDs full on the result is dazzling to say the least.

Thus, we need some way to control the relative intensity of each LED so as to maintain a constant brightness across all of the colors. But wait... there's more... because if we can vary the intensities, we can achieve an entire gamut of colors as illustrated below:
Achieve an entire gamut of colors
Achieve an entire gamut of colors

Cool Beans indeed, but this is not as easy as it looks, because we can’t vary the intensity of a LED by simply modulating its supply voltage as we could for an incandescent light, for example. Basically a LED is either On or Off, but that's not a problem, because using some form of electronic control system we can switch each LED On and Off very quickly.

For example, suppose we start with only the Red LED On; not surprisingly we will get a bright Red light. Now suppose we turn the Red LED Off for a short time ... then On ... then Off ... then On ... then Off... and so forth. If we have the LED On for 50% of the time and Off for the other 50% of the time, the result will be 1/2 the original brightness ... if we have the LED on for 75% of the time and Off for 25% of the time, the result will be 3/4 the original brightness ... and if we do all of this very quickly (hundreds of thousands of times a second) then we won’t see any flickering.

All of this is called Pulse Width Modulation (PWM). Now consider our LEDs. Let's assume that we have a counter that counts from 0 to 255 over and over again. Also that we have three count values; one each for the Red, Green, and Blue LEDs, and that we use these values to determine the mark-space ratio of their associated LEDs. For example, if we associate count values of 245, 228, and 73 with the Red, Green, and Blue LEDs, respectively, the result is a rather nice yellow-ish color:

 
Pulse Width Modulation (PWM)
Pulse Width Modulation (PWM)

In practice things aren’t quite this simple, but the underlying theory is sound. Anyway, my friend Joe Farr in England is an expert with anything to do with PICs and programming and all sorts of other stuff. Joe has created a small circuit board with a 40-pin PIC microcontroller as illustrated below:
40-pin PIC microcontroller
40-pin PIC microcontroller


This microcontroller has 24 output pins configured to perform pulse width modulation as discussed above, which means I can use the board to control eight tri-color LEDs (only one LED is populated in this image ... the bright purple one ... the little green one just indicates that the board is powered-up).

In fact Joe has built eight of these boards for me, which allows me to control 64 tri-color LEDs, which should be more than enough to satisfy my display cravings (at least in the short term). The idea is that I can use my main PICAXE microcontroller to issue simple commands along the lines of "LED number 'n', I want you to set your RGB values to X,Y,Z", and then let the appropriate LED driver board deal with the fiddly details involved in generating the appropriate signals.

All of this is very, very Cool Beans indeed. I now have some serious experimenting and playing around to perform that should keep me busy for a while... I shall doubtless report back on my progress in the not-so-distant future. Until next time, have a good one!
 
< Prev   Next >

 


Get Involved and follow EPE on TWITTER

 Signup and follow  EPEMAG on TWITTER, share tips, ask questions

Current Subscribers to EPE Online or Radio Bygones

Image

Image 

Printed circuit boards for most recent EPE constructional projects are available from the the online store. These are fabricated in glass fi bre, and are fully drilled and roller tinned. Double-sided boards are NOT plated through hole and will require ‘vias’ and some components soldering to both sides.

PCB masters for boards published from the March ’06 issue onwards can also be downloaded from the ‘Library’.

Image

All software programs for EPE Projects previously published can be downloaded free from the Library on our website, accessible via our
home page.

 

 

EPE / RadioBygones Login






Please Note

This site is best supported by Microsoft Internet Explorer 7.0® or FireFox® 3.0. Pop-up blocker must be disabled and automatic cookie override should be used. Please download Microsoft Internet Explorer 7.0 now (you will be taken to the Microsoft© web site). or FireFox now (you will be taken to the FireFox® web site )

 

Polls

Would you be interested in an magazine email service?
 

Who's Online

We have 28 guests and 1 member online

Syndicate