Author Topic: RGB LED circuit  (Read 5894 times)

0 Members and 5 Guests are viewing this topic.

Offline darinsquaredTopic starter

  • Contributor
  • Posts: 39
  • Country: ca
RGB LED circuit
« on: February 10, 2018, 04:12:47 pm »
I want to make a LED light (6-8 LED's) with RGB LED's.  When the main switch is ON I want the Red to illuminate.  I also will have two momentary switches in the circuit.  When I hold one switch the green will illuminate and when I hold the other switch the Blue will illuminate.  I am not sure how to design this circuit.  Would it be simpler to have three sets of colored LED's?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #1 on: February 10, 2018, 04:44:27 pm »
I want to make a LED light (6-8 LED's) with RGB LED's.  When the main switch is ON I want the Red to illuminate.  I also will have two momentary switches in the circuit.  When I hold one switch the green will illuminate and when I hold the other switch the Blue will illuminate.  I am not sure how to design this circuit.  Would it be simpler to have three sets of colored LED's?
So you mean, with power on and no switches are pressed, the red light will  be on, when one switch is pressed, both red and green will be illuminated, producing yellow light and when the other switch is pressed, the blue LED will light, giving magenta light and when both switches are pressed, all the LEDs will light giving white?

Start with a table showing what colour light is desired, when different switches are pressed. It's possible this can be implemented passively, with just switches and current limiting resistors. Another possibility is diode logic, logic gates (74HCxx is probably best here) or a microcontroller, f more than four gates are required.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: RGB LED circuit
« Reply #2 on: February 10, 2018, 04:58:33 pm »
^^ What he said about design clarification.

Separate sets would be cheaper, space and other considerations permitting, but they're almost the same thing electrically. The basic version of RGB LED's are just 3 LED's in a four-pin package, with one pin for each color and a common anode or cathode (you can get them either way - that means all 3 LED's are connected together on one side only).
 

Offline darinsquaredTopic starter

  • Contributor
  • Posts: 39
  • Country: ca
Re: RGB LED circuit
« Reply #3 on: February 10, 2018, 07:04:37 pm »
sorry for poor explanation.  Yes red is on with "main" on switch.  I will then have a switch for Green and switch for Blue.  I am making a light to guide direction.  So when no switch is pressed this tells people to stop.  If I want them to move forward I will press switch for green lights and the red turning off.  When switch is released the red comes back on indication people to stop.  Blue light works the same to notify moving backwards/reverse.

  I am maybe leaning towards having three individual lights and using a three position rotary switch.  I was only considering RGB LED's for saving space.
 

Offline Cyberdragon

  • Super Contributor
  • ***
  • Posts: 2676
  • Country: us
Re: RGB LED circuit
« Reply #4 on: February 10, 2018, 07:54:12 pm »
Just have the red on an inverter and connected to the other two buttons. You could be dirty and just short the LED with a transistor across it. Or you could use something more efficient like this. Note: remember to use diodes between the switches and inverter input or both lights will come on together.

If you're using batteries, use the more efficient method as the shorting method wastes power and can stress the resistor depending on the power levels in this circuit.

« Last Edit: February 10, 2018, 07:57:02 pm by Cyberdragon »
*BZZZZZZAAAAAP*
Voltamort strikes again!
Explodingus - someone who frequently causes accidental explosions
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #5 on: February 10, 2018, 09:11:45 pm »
sorry for poor explanation.  Yes red is on with "main" on switch.  I will then have a switch for Green and switch for Blue.  I am making a light to guide direction.  So when no switch is pressed this tells people to stop.  If I want them to move forward I will press switch for green lights and the red turning off.  When switch is released the red comes back on indication people to stop.  Blue light works the same to notify moving backwards/reverse.

  I am maybe leaning towards having three individual lights and using a three position rotary switch.  I was only considering RGB LED's for saving space.
A NOR function is required. This can be implemented as an AND with the two inputs inverted, or just a NOR gate. See attached schematics. The right one shows a NOR gate. The left and middle, an AND gate with the inputs inverted. The left one uses two normally closed contacts, both in series with the red LED. The middle, two transistors, which aren't critical: the 2N7000 will do. When the push-button switches aren't pressed, the transistors will both be on, because their gates will be near +V. When a switch is pressed, to turn the green or blue LED on, the gate is pulled down to 0V, causing the transistor to turn off. Because the transistors are in series, they both need to be on for the red LED to light.



The resistor values can be calculated, using the calculator linked below:
http://www.ohmslawcalculator.com/led-resistor-calculator
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #6 on: February 10, 2018, 09:38:13 pm »
One RGB or 3 separate LEDs makes no huge difference. But figuring out your interface does. That will drive the actual circuit. 

Your 3 way switch approach is conceptually simple - just 3 separate circuits. Make the middle one red so it's the intermediate state. Then it's just the LEDs and current limiting resistors.

A more elegant solution is to have two buttons - one for forward, one for back.  When neither are pressed, red lights up. There are some simple circuits to do this. See the schematic for one. D1 and D2 are any small diodes - 1n4148 is a common one.

How will you turn this whole thing on/off?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #7 on: February 10, 2018, 10:35:08 pm »
One RGB or 3 separate LEDs makes no huge difference. But figuring out your interface does. That will drive the actual circuit. 

Your 3 way switch approach is conceptually simple - just 3 separate circuits. Make the middle one red so it's the intermediate state. Then it's just the LEDs and current limiting resistors.

A more elegant solution is to have two buttons - one for forward, one for back.  When neither are pressed, red lights up. There are some simple circuits to do this. See the schematic for one. D1 and D2 are any small diodes - 1n4148 is a common one.
The problem with using a silicon diode is, it will have the same voltage drop as Q1's base-emitter junction, which will mean Q1 will not properly turn off and R5 won't help matters. Use Schottky diodes, omit R5 and reduce the value of R4, to give Q1 sufficient base drive.



Quote
How will you turn this whole thing on/off?
Presumably a toggle switch?
« Last Edit: February 10, 2018, 10:38:40 pm by Hero999 »
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2812
  • Country: nz
Re: RGB LED circuit
« Reply #8 on: February 10, 2018, 10:54:25 pm »
You could do this purely mechanically, with a single pole toggle switch to turn it the power on, then two dual pole dual throw (DPDT) pushbutton switches for the green and blue LEDs.

Wire the normally open contact of one pole of the "green" pushbutton to turn on the green LEDs, and likewise wire the blue LEDs to the other push button.

Then wire the other pole of the two pushbuttons in series, using the normally closed contacts to the red LEDs. That way when either button is pushed the red LEDs will be extinguished.

Piece of cake.

Have you considered using 12V RGB LED strips? The resistors are build into the strips, and they usually use a common anode (positive) connection - you will then need to put your switches between the negative battery terminal and the strip. Were you to do this you would only need the battery/power source, an LED strip, the three switches and some hookup wire.
« Last Edit: February 10, 2018, 11:11:40 pm by hamster_nz »
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #9 on: February 11, 2018, 05:58:10 am »
I simulated the circuit on LTSpice and it works just fine. The silicon diode drop isn't that much.
« Last Edit: February 11, 2018, 06:00:09 am by phil from seattle »
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: RGB LED circuit
« Reply #10 on: February 11, 2018, 04:08:36 pm »
Simples.  :)
.  That took much longer than I thought it would.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #11 on: February 11, 2018, 04:47:09 pm »
Simples.  :)

heart of simplicity.  that one gets my vote.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #12 on: February 12, 2018, 10:14:18 am »
I simulated the circuit on LTSpice and it works just fine. The silicon diode drop isn't that much.
So have I. The silicon diode voltage drop, is still enough to bias Q1 into conduction, causing the red LED to dimly light. Removing R5 helps and using Schottky diodes for D1 and D2 eliminates the problem. Another option is to use a P-MOSFET for Q1, such as the BS250.

Simples.  :)
Good idea. The downsides are: increased power dissipation and that the RGB LED will need both the anodes and cathodes of each element to be accessible, i.e. it can't be common anode/cathode.
 

Offline darinsquaredTopic starter

  • Contributor
  • Posts: 39
  • Country: ca
Re: RGB LED circuit
« Reply #13 on: February 12, 2018, 04:20:18 pm »
thank you everyone for the help.  Once I get a few more of the components I will give this project a try.  Just a note to the Admin, this is one of the best electronics forums.  People do not get upset when a newbie that does electronics on a limited basis asks simple questions.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #14 on: February 13, 2018, 02:05:28 am »
I simulated the circuit on LTSpice and it works just fine. The silicon diode drop isn't that much.
So have I. The silicon diode voltage drop, is still enough to bias Q1 into conduction, causing the red LED to dimly light. Removing R5 helps and using Schottky diodes for D1 and D2 eliminates the problem. Another option is to use a P-MOSFET for Q1, such as the BS250.
Hmmm. Depends on what voltage you supply. Even with 5V and 220 ohm current limiting resistors I still get at least 8 mA through all 3 LEDs. The one driven by the transistor is slightly less - 8.15 mA vs 8.76 mA for the others. I doubt some one would see the difference if they were the same LEDs. Since they aren't and different different limiting resistor values would be used, it's complete a non-issue.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #15 on: February 13, 2018, 09:07:04 am »
I simulated the circuit on LTSpice and it works just fine. The silicon diode drop isn't that much.
So have I. The silicon diode voltage drop, is still enough to bias Q1 into conduction, causing the red LED to dimly light. Removing R5 helps and using Schottky diodes for D1 and D2 eliminates the problem. Another option is to use a P-MOSFET for Q1, such as the BS250.
Hmmm. Depends on what voltage you supply. Even with 5V and 220 ohm current limiting resistors I still get at least 8 mA through all 3 LEDs. The one driven by the transistor is slightly less - 8.15 mA vs 8.76 mA for the others. I doubt some one would see the difference if they were the same LEDs. Since they aren't and different different limiting resistor values would be used, it's complete a non-issue.
I think you've misunderstood. The issue, with the schematic your posted, is not about the LEDs drawing different currents, but with the diode biasing Q1 on, causing the red LED to be on, when it shouldn't be.

The voltage drop across R5 adds to D1's forward voltage, making the situation worse. Removing it helps, but D2 still won't turn off completely. If you don't have a Schottky diodes, adding another diode, in series with Q1's base will also solve the problem.

This sort of thing isn't easy to simulate because real life components often differ from the models. If the D1's diode forward voltage is higher or Q1's VBE lower, then more current will flow through the LED, than SPICE would predict. The temperature will also also make a difference. As Q1 heats up, its VBE will fall, causing it to turn on more, with SPICE won't see, unless you have a program which includes accurate thermal models.

« Last Edit: February 13, 2018, 09:09:57 am by Hero999 »
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #16 on: February 13, 2018, 05:52:57 pm »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light. What part of the sim is inaccurate?
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2812
  • Country: nz
Re: RGB LED circuit
« Reply #17 on: February 13, 2018, 06:36:42 pm »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light. What part of the sim is inaccurate?

Just replace Q1 with a Darlington and everybody will be happy...
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline grifftech

  • Frequent Contributor
  • **
  • Posts: 369
  • Country: us
    • youtube channel
Re: RGB LED circuit
« Reply #18 on: February 14, 2018, 03:39:55 pm »
microcontroler
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #19 on: February 14, 2018, 07:18:14 pm »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light.
It will glow very dimly but won't be noticeble above the other LEDs,
Quote
What part of the sim is inaccurate?
You haven't posted the .asc file.

The chances are my simulation isn't very accurate, because I didn't vary the VBE and the LTSpice doesn't account for the temperature rise of Q1. Did you?

The only way to know how well it'll work, is to actually build it and even then it might not work the same with different components, even with the same part numbers. Isn't easier just to implement the fixes and be sure it'll work !00% of the time?

My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light. What part of the sim is inaccurate?

Just replace Q1 with a Darlington and everybody will be happy...
Yes, that will work too.
 

Offline phil from seattle

  • Super Contributor
  • ***
  • Posts: 1044
  • Country: us
Re: RGB LED circuit
« Reply #20 on: February 14, 2018, 08:04:54 pm »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light.
It will glow very dimly but won't be noticeble above the other LEDs,
Lol. The light from 12 uA will be swamped by moonlight.
And no, I didn't account for temperature but it's just not an issue. 
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19982
  • Country: gb
  • 0999
Re: RGB LED circuit
« Reply #21 on: February 15, 2018, 08:55:10 am »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light.
It will glow very dimly but won't be noticeble above the other LEDs,
Lol. The light from 12 uA will be swamped by moonlight.
But if it's nearly 4mA, then it will be clearly visible!

Quote
And no, I didn't account for temperature but it's just not an issue.
You're wrong about temperature: it is an issue, because it affects device characteristics and different components dissipate amounts of power, causing the temperature between them to vary. The variation between components, is also critical and not taken into account by LTSpice!

I can create plenty of schematics, which work very well in a simulator, but will perform poorly or simply won't work in real life.

Here's another example. It's supposed to give two outputs: one the inverse of the input and one the same as the input, with a gain of 10. LTSpice will happily simulate it, showing a working circuit, but it will either fail to work, or perform really poorly in real life!

https://www.eevblog.com/forum/chat/is-the-electronics-hobby-dead/msg988861/#msg988861
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2812
  • Country: nz
Re: RGB LED circuit
« Reply #22 on: February 15, 2018, 09:54:07 am »
My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light.
It will glow very dimly but won't be noticeble above the other LEDs,
Lol. The light from 12 uA will be swamped by moonlight.
And no, I didn't account for temperature but it's just not an issue. 

Well, I had a few minutes to kill, and spent most if it finding exactly the parts as the original schematic. Reality wins over simulation.

The LED is dimly visible with the over-desk lights on, and clearly visible when the lights in the study nook are off (with ambient lighting from the lounge).

Only when both Green and Blue both lit at the same time (i.e a jumper from +5 to the start of row 38) does the red LED turn off.

(Picture is a bit dull because of the brightness of the Green LED)


Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 
The following users thanked this post: Zero999


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf