EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: Falcon69 on March 26, 2016, 03:28:40 am

Title: Online calculator for resistor values of RGB to obtain a certain color?
Post by: Falcon69 on March 26, 2016, 03:28:40 am
Anyone have a link to an online calculator that would show the resistor values needed for each color of an RGB to obtain a certain color output of said RGB?  Certainly it can be calculated using Excel or something.  I know a PWM is the way to go, but I don't want to implement a micro-controller for something that will never change colors. I just want to set it and be done with it.

There must be something ouot there, put in Forward voltage of each LED, the Voltage in, etc. Then you can calculate the resistors needs to get the color.

What if I took the resistor value needed to obtain 20mA through each LED, then based on that, and 0-255 and using the hexidecimal to get the color I want, I can calculate the percentage of resistance needed for each color?
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: sleemanj on March 26, 2016, 04:15:02 am
Ignoring that different LEDs will have different characteristics meaning you probably have to tweak things for your specific leds anyway to get a good balance of colours (with regard to intensity of each die), changing the current through an LED will change it's colour slightly also.

For that reason, PWM is the better idea, maintain the same instantaneous current so the colour remains the same, and adjust the PWM duty cycle of that current to adjust the amount of that colour in the overall combination.

With that said, here you go, a spreadsheet I just made which just calculates resistances for 0 to 20mA through each for 255 steps...

https://docs.google.com/spreadsheets/d/1Z_2JToEy1v5mtXm4NCGtIV0VkrqYtnPCRqtROACH2fE/edit?usp=sharing
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: Falcon69 on March 26, 2016, 05:10:07 am
sleemanj

I owe you a beer if I ever get the cash to visit New Zealand. You are awesome. exactly what I was looking for.

And yes, I understand PWM is the way to go, but that adds more components and for something I just want to set and leave, just changing resistors I think will work.  I will be using 0603 RGB Leds. They are small, about the size of two 0603 leds side by side.

I'm sure I will need to tweak these values for brightness and everything else, but this gives me a GREAT starting point.

Thank You sir.

This spreadsheet should be something that should be 'stickied'   :-+
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: Kilrah on March 26, 2016, 06:19:58 am
Can't see how this could be of much use since it doesn't account for the different current-to-light output characteristic of each LED, some will need 2mA to produce X lumens, some 20mA. That would need calibration for whatever LEDs you're going to use. Don't be surprised if it's completely off.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: Falcon69 on March 26, 2016, 06:23:17 am
oh, I know, but it gives me a good starting point, and yes, I know what you mean.

To get the Red and Green LED (of the LEDs I have) to appear to be the same brightness, I had to run the Red with the 100ohm resistor, and the green with a 4k ohm resistor (when normally it would be about 160 for 20mA).

I'll need to tweak it alot, but it is a good starting point.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: rdl on March 26, 2016, 11:28:01 am
Hehe, this is so true. I have some old Panasonic 7-segment displays that are still pretty dim at 15 mA and some new blue ones that are almost too bright to look at with only 5 mA.


20mA max current is for ancient inefficient LEDs. Modern efficient LEDs, if used as indicators, will be too bright even at 5mA.
Many LEDs used in mobile electronics are driven at under 1mA.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: XOIIO on March 26, 2016, 11:39:46 am
For something that you will just leave, you can get an attiny85 for extremely cheap, it can do the PWM just fine, and you can program it using the arduino IDE and an arduino, I'm not 100% sure but I seem to recall programming them with a pro mini, could give it a try actually.

They make for great little drop ins for things you don't want to spend too much on, though a pro mini itself is pretty darn cheap on ebay, the attiny will be a bit more compact.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: tooki on March 26, 2016, 01:44:06 pm
And don't forget that our eyes do not have a linear response to brightness, so you need gamma correction to shift more of the brightness levels to the lower range of the brightness scale.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: dentaku on March 26, 2016, 07:16:22 pm
It seems to me that the best way is just to use three pots so you can adjust it to what you think looks right then measure the value of each pot and find the nearest resistor value to those pots and use those in your final circuit.
Title: Re: Online calculator for resistor values of RGB to obtain a certain color?
Post by: Dubbie on March 31, 2016, 06:17:14 pm
That's really the only way that is going to work. A few percent error can be perceived as a very different colour at some parts of the color gamut.


Sent from my phone using Tapatalk