1
\$\begingroup\$

Calibrate RGB leds with the correct resistor

Playing around with some microcontrollers and multiplexed leds i noticed that i always need to fix the colors of each led rgb output softwareside... thats a pain...

Microcontroller's pwm output has an output of 255 different values.

By mixing a color with rgb leds you do some math... i like hsl(hsv in mc's) and convert it to rgb values.

So if i want yellow i need theoretically turn on the red and the green at 100%

rgb(255,255,0);

nope... it's not yellow...

  1. here the lighness is not considered...the real rgb values should be less than 255 pwm. all set to 255 should return white.
  2. the blue and the green leds are brighter.

in my code i have something like that

red*1
green*0.2
blue*0.15

i use only 15% of the blue led when mixing the colors.20% of the green one.

The maximum value of pwm used is 38

38 of 255 possible values. A waste!


Those are the resistors i need to properly power the leds.

Red: 5v@2.1v-20mA = 150ohm

Green: 5v@3.2-20mA = 100ohm

Blue: 5v@3.1v-20mA = 100ohm (corrected error 2,1v vs 3.1v)

How can i calibrate the leds hardwareside?

I know i need only 15% of the emitted light comming from the blue led... what resistor should i use?

Is there some sort of calculation that allows me to set the correct resistor based maybe on the wavelength or other carachteristics contained in the datasheet?

Would a Simple LDR help to calibrate those leds?

If i find the correct resistors for a nice hue based on a lightness of 50% what would return rgb(255,255,255) ??? white or not?

What you do to get a nice visual hue on rgb leds?

this for shure would also help to solve some issues on another question i made some time ago

LDR + RGB Led = Color sensor. How to calibrate it?

\$\endgroup\$
  • 1
    \$\begingroup\$ If your LED has a good datasheet it will tell you a typical value for amps vs. light output (which isn't linear). Due to manufacturing tolerances, for accurate output, you still need to calibrate in software though and need good measurement equipmen to do so. \$\endgroup\$ – PlasmaHH Aug 14 '15 at 12:11
  • \$\begingroup\$ 3lco.biz/attachment.php?id_attachment=2 nope \$\endgroup\$ – cocco Aug 14 '15 at 12:34
  • \$\begingroup\$ "good measurement equipment"... like? \$\endgroup\$ – cocco Aug 14 '15 at 12:39
  • \$\begingroup\$ anything that can measure precise calibrated light spectrum power outputs. \$\endgroup\$ – PlasmaHH Aug 14 '15 at 12:43
  • 1
    \$\begingroup\$ You could easily get some small potentiometers, tune them until your light is satisfactory, then measure their values with a multimeter. \$\endgroup\$ – pjc50 Aug 21 '15 at 8:29
1
\$\begingroup\$

To start, Some of your math is a little off.
For the red LED, if you are using a 5v supply and the red LED needs 20ma and has a voltage drop of 2.1v, then you need a limiting resistorstrong text of (5-2.1)/.02 = 145 ohms.
For the green LED, you need (5-3.2)/.02 = 90 ohms.
For the blue LED, you need (5-3.1)/.02 = 95 ohms.

Assuming that these resistors cause equal LED illumination, and that the light intensity varies directly as the current applied to the LED, then you need to reduce the currents to the green and blue LEDs as follows:

For the green LED, the current needed is (20ma x 20% =) 4ma. For the same voltage drop, the new current limiting resistor required is (5-3.2)/.004 = 450 ohms.
For the blue LED, the current needed is (20ma x 15%) =) 3ma. For the same voltage drop, the new current limiting resistor required is (5-3.1)/.003 = 633 ohms.

Obviously, if the assumptions are not accurate, the calculations will also not be accurate. If more accuracy is required, then you will need to use the LED's data sheet.

\$\endgroup\$
  • \$\begingroup\$ You are wrong. The Blue has a voltage drop of 3.1v. Read various rgb led datasheets. "resistors cause equal LED illumination" NO. Also light intensity is NOT linear. You need to create a 255 values map for the intensity as soon as you choosed the proper resistor for the max brightness. The whole question is based on the fact that you don't fully use the PWM range on microcontrollers. I was thinking to use the LDR to measure each color, maybe using a lumen meter, what about the wavelength... said that, reread your answer. I don't downvote, so... nice day. \$\endgroup\$ – cocco Aug 21 '15 at 8:47
  • \$\begingroup\$ I am not wrong because I am using your data. For the blue LED you have the same voltage drop as the red LED. That is your mistake! The reason I am not wrong on the rest is that I clearly conditioned the results on two assumptions. If the assumptions are not valid, then the results are not valid, but the method for obtaining the resistor value is correct. \$\endgroup\$ – Guill Aug 23 '15 at 4:15
  • \$\begingroup\$ oh ... in my question... thats a type error... red has always around 2-2.5 while blue & green have around 3-4. my error sry. i corrected the error \$\endgroup\$ – cocco Aug 23 '15 at 10:57
  • \$\begingroup\$ While this is correct, I would comment that equal power (or current) in the LED's does not always correspond to what is visually perceived as brighter (I think green tends to appear brighter iirc) \$\endgroup\$ – user2813274 Apr 16 '17 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.