Author Topic: RGB LED Rainbow effect  (Read 9230 times)

0 Members and 1 Guest are viewing this topic.

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
RGB LED Rainbow effect
« on: July 20, 2015, 04:55:23 pm »
Hello,

So essentially I want to have an RGB led array that cycles through all the colors of the rainbow (thus Rainbow RGB) without using a micro-controller.

I found this tutorial here: Rainbow Led.

And this is my schematic that I put on the breadboard:


R1 - Pot - I tried both a 5K and 500K pot.
R2-R6 = 10k
IC1 - NE555
IC2 - CD4029BE - binary counter
T1-T3 = PH2369 transistor (I had in the parts bin -> 200mA / 15V NPN)
RGB Leds - 5mm / 20mA LEDs (individual)
C2-C4 - I tried 47uF, 100uF, 220uf (all 25V). The only difference, @ 220uF is the slowest flicker.

So, I was expecting the LEDs to create different colors, ie as Red would wind down and start to blend with Green it would create a color and so on with Blue. The only thing that is happening is that they are all flashing together (flickering) and the slowest flicker is with the 220uF caps. But they do it at the same time. They don't progressively fade in out in order to create a rainbow effect.

Here is what I essentially want to happen:


Any ideas?




Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: RGB LED Rainbow effect
« Reply #1 on: July 20, 2015, 05:22:12 pm »
Your circuit appears to be designed to give a "hard count" from 0 to 7 and each bit drives one of the primary colors.  So, we would expect that as it counts from zero to seven, it will give you these "hard" colors:

0. dark
1. red
2. green
3. yellow (red + green)
4. blue
5. magenta (blue + red)
6. cyan (blue + green)
7. white (red + green + blue)

In order to "smoothly blend" from one color to the other, you must have something more than "hard on/off" control of your LEDs.
Typically, that means using pulse-width modulation (PWM) to vary the apparent intensity of the LEDs.

While you could do PWM without using a microcontroller, it would be enormously complex, expensive, difficult, and fiddly.
Using a microcontroller, OTOH, is simple, cheap, easy and foolproof.
It appears that your design goals are at odds with your desired outcome.  You can't have it both ways. Select one.
 

Offline German_EE

  • Super Contributor
  • ***
  • Posts: 2399
  • Country: de
Re: RGB LED Rainbow effect
« Reply #2 on: July 20, 2015, 05:49:53 pm »
Try moving the 47 uF capacitors from the 4029 outputs to the emitters of the driver transistors.
Should you find yourself in a chronically leaking boat, energy devoted to changing vessels is likely to be more productive than energy devoted to patching leaks.

Warren Buffett
 

Offline Dongulus

  • Regular Contributor
  • *
  • Posts: 232
  • Country: us
Re: RGB LED Rainbow effect
« Reply #3 on: July 20, 2015, 05:58:53 pm »
I think you're looking for something like a ring counter instead of a binary counter.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: RGB LED Rainbow effect
« Reply #4 on: July 20, 2015, 06:15:53 pm »
You could sort of achieve something similar by doing the following:

1) Put the LEDs and resistors in the collector circuit of each transistor, get rid of the caps on the 4029 outputs (very bad idea anyway).
2) Integrate the clock output from the 555 and buffer it, and connect the buffered output to the LED anodes.

You now have a ramp driving the LEDs, and on each ramp cycle a different combination of LEDs will be active.  This won't get you the mixing profile you have posted, but you will get a range of colours.

Alternatively just drive the LEDs from 3 separate triangular waveforms running at different (non-integer divisible) frequencies.
« Last Edit: July 20, 2015, 06:18:36 pm by mikerj »
 

Offline djococaud

  • Regular Contributor
  • *
  • Posts: 78
  • Country: fr
  • General rule : Simpler is Better
    • Djo Labs
Re: RGB LED Rainbow effect
« Reply #5 on: July 21, 2015, 09:42:21 am »
Simply put the 47µF capacitors between transistors bases and ground, after the base resistors (it's just a little mistake on the schematic !).

This makes Resistor/capacitors smooth filters, followed by the transistors.

You can play a little with the resistor/capacitor values to adapt to the fading speed you want.

This circuit will work with only LED per channel (Vf<3~4V)
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: RGB LED Rainbow effect
« Reply #6 on: July 21, 2015, 10:09:30 am »
Simply put the 47µF capacitors between transistors bases and ground, after the base resistors (it's just a little mistake on the schematic !).

This makes Resistor/capacitors smooth filters, followed by the transistors.

You can play a little with the resistor/capacitor values to adapt to the fading speed you want.

This circuit will work with only LED per channel (Vf<3~4V)

Yeah, I made a mistake in the schematic. IRL the caps are between Base and GND.

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: RGB LED Rainbow effect
« Reply #7 on: July 21, 2015, 10:11:46 am »
Your circuit appears to be designed to give a "hard count" from 0 to 7 and each bit drives one of the primary colors.  So, we would expect that as it counts from zero to seven, it will give you these "hard" colors:

0. dark
1. red
2. green
3. yellow (red + green)
4. blue
5. magenta (blue + red)
6. cyan (blue + green)
7. white (red + green + blue)

In order to "smoothly blend" from one color to the other, you must have something more than "hard on/off" control of your LEDs.
Typically, that means using pulse-width modulation (PWM) to vary the apparent intensity of the LEDs.

While you could do PWM without using a microcontroller, it would be enormously complex, expensive, difficult, and fiddly.
Using a microcontroller, OTOH, is simple, cheap, easy and foolproof.
It appears that your design goals are at odds with your desired outcome.  You can't have it both ways. Select one.

You're probably right, although right now I would of course be happy with it just doing what you mentioned - A hard switch between the primary colors as opposed to all of them flickering on simultaneously.

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: RGB LED Rainbow effect
« Reply #8 on: July 21, 2015, 10:10:02 pm »
LED ring oscillator:



I've made these using 2n7000 mosfets, they work fine. Vary the capacitor and resistor values for different timings.
« Last Edit: July 21, 2015, 10:13:24 pm by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: RGB LED Rainbow effect
« Reply #9 on: July 21, 2015, 10:18:09 pm »
Of course if microprocessors are allowed, you can do a lot more. Here's my Arduino-based "mood light". It uses a single RGB combo LED but of course you can use 3 individual ones or arrays as well.

The easiest person to fool is yourself. -- Richard Feynman
 

Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: RGB LED Rainbow effect
« Reply #10 on: July 22, 2015, 12:40:05 pm »
OMG!!!! Yes. I will try this now.

It's not that micros are not allowed, I do want to do one with the MSP430, I just wanted to see if it can be done "passively" first.


Offline made2hackTopic starter

  • Frequent Contributor
  • **
  • Posts: 424
  • Country: 00
    • Made2Hack
Re: RGB LED Rainbow effect
« Reply #11 on: July 22, 2015, 02:29:29 pm »
Hey,

So I got it to work, but I have some questions which may appear stupid or obvious to some of you.

I didn't have any 2N7000 mosfets on hand. So I used 2N2222 BJTs. I noticed that I needed a large amount of capacitance to slow down the transition (on the order of 1000s of uF). Ok, I switched to some IRF634As I had around, which made things somewhat better. With 220uF I can say that I am satisfied by the speed of the transition.

Is this the only way to slow down the transition?

And, is there a way I can calculate using the datasheets of a Mosfet how much capacitance will give me how large of a transition?


Side note, thanks for telling me about a ring oscillator. Now I can use that search term as opposed to "rainbow led".

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: RGB LED Rainbow effect
« Reply #12 on: July 23, 2015, 01:14:13 am »
Just for fun I checked to see if I could build something similar. Right away I knew I needed a 4017B and not a 4029.
I ended up using 100uf capacitors but that all depends on how fast your clock is.
I breadboarded it then realised that I only have common anode three colour LEDs so I modified the circuit a bit and I now have an LED the fades from red, green, cyan, blue, magenta, red etc... It can't seem to make anything close to yellow for some reason :)
You seem to have a common cathode LED so my first circuit should work.
Where you see the 1Hz clock is where the output of the slowly oscillating 555 timer goes.

Doing this with a microcontroller is still better because you can then fade the LEDs using PWM plus you can make lots more controllable colours but this was still a fun experiment.
« Last Edit: July 23, 2015, 02:18:29 am by dentaku »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf