3
\$\begingroup\$

Sorry if this is too basic but I don't understand this issue.

Right now, using an MCU, I change the RGB colours of an LED strip with 3 PWM signals. All colours works great . The thing is, when I am trying to set the intensity of the light, I don't know how to do it.

So if, for example, I have RGB(15,170,230), then I want to slowly reduce the intensity of the light, keeping the same colour, how would I change the RGB to get that?

\$\endgroup\$
  • 1
    \$\begingroup\$ What does the data sheet for the LED(s) tell you about this? \$\endgroup\$ – Andy aka Mar 30 '15 at 8:31
  • \$\begingroup\$ nothing, its a led strip i bought from Aliexpress they dont provide data sheet but its a regular led strip with 4 lines, one 12v and the others are RGB lines. \$\endgroup\$ – Curnelious Mar 30 '15 at 8:33
  • \$\begingroup\$ Lowering the duty-cycle of the PWM doesn't work? \$\endgroup\$ – Paul Mar 30 '15 at 8:34
  • 1
    \$\begingroup\$ I never buy anything like this without a data sheet. It's a golden rule. \$\endgroup\$ – Andy aka Mar 30 '15 at 8:34
  • \$\begingroup\$ You could check if there is any serialnumber/id/type/build/manufacturer details on it, check if they have a datasheet, but I think it should be quite a basic thing then. Think, how do you lower the intensity of a normal led with PMW? And then try if it works in this occasion... Also, are you sure this isn't a duplicate question? electronics.stackexchange.com/questions/50417/… \$\endgroup\$ – Paul Mar 30 '15 at 8:36
6
\$\begingroup\$

Start by scaling the R,G and B by the intensity value, for your example at 50% intensity you would set 15*0.5, 170*0.5, 230*0.5 (7, 85, 115).

The LEDs might have different non-linear responses, so you might need to tweak the scaling for perceived colour

In particular, at very low levels, you will suffer from rounding error. There is no easy way around this except by increasing the colour resolution (e.g. to 0-1000 instead of 0-250) or selecting devices with a more appropriate dynamic range for the application (brighter or dimmer LEDs).

Another alternative if you are using multiple devices is to switch a subset of the devices on to give different intensity levels, for example if you have 6 RGB LEDs you could switch 3 to (1,10,10) and 3 to (0,10,10) to add resolution, effectively (0.5, 10, 10) overall.

\$\endgroup\$
  • \$\begingroup\$ its not really working ,for some colours if your value becomes 0 for the red before the others, than it changes the original colour . \$\endgroup\$ – Curnelious Mar 30 '15 at 10:10
  • 1
    \$\begingroup\$ Updated response, but unfortunately there isn't an easy way around that, you are limited by the resolution of the LEDs. Matching a colour using RGB LEDs will always have a subjective element to it, so you might be able to find a solution that 'looks good enough'. How you do that depends on the application (scientific measurement needs a different approach to architectural lighting, for example) \$\endgroup\$ – rolinger Mar 30 '15 at 12:59
  • \$\begingroup\$ If it's PWM, the LED response shouldn't matter, only the eye's response, which is much more linear. You're still limited by the time resolution of the PWM, 256 x brightness isn't a big change to the human eye. \$\endgroup\$ – tomnexus Mar 30 '15 at 17:49
  • 1
    \$\begingroup\$ When I said 'resolution of the LEDs', I meant the 'resolution of the thing that controls the current through the LEDs', not the devices themselves. Nothing in the original question suggested that the PWM resolution was 256 steps, I just used that as an illustration of increasing resolution. Sorry for any confusion. \$\endgroup\$ – rolinger Mar 31 '15 at 9:07
  • \$\begingroup\$ @rolinger How did this work out? In your case: (1) I'd establish hardware + software CURRENT drive proportional to PWM output value. (2) I'd establish max current allowed per colour and (3) brightness of each at that current. (4) Then I'd establish brightness per PWM step. | This allows desired brightness per PWM step to be used to select an RGB mix. You coild scale in software so all colours use value say 0-100 for 0-100% brightness, or 0-100 for absolute intensities (setting most sensitive colour to 100 at mx brightness so it did not get overdriven OR use data "on the fly". | eg SAY \$\endgroup\$ – Russell McMahon Jul 24 '17 at 8:27
2
\$\begingroup\$

In your case:
(1) I'd establish hardware + software CURRENT drive proportional to PWM output value. Current and not voltage control is essential as lumens:mA is ROUGHLY constant but lumens:volts is very non linear. Very.

(2) I'd establish max current allowed per colour and

(3) brightness of each at that current.

Note that the measure is liable to be lumen/mA. As lumen are an eye response based unit, even if LEDs had equal light_mW/mA the lumen values per mA would differ. Also - when mixing coulours, even when the sun of (Red)lumen + green_lumen + blue_lumen) is constant as magnitudes change, you may well find that the perceived brightness varies. However, when two LEDs are observed one at a time, a difference in luminous output of nearly 2:1 is needed before a brightness change can be discerned by most people. Side by side maybe 1.5:1. Wall washing adjacent - maybe 1.2:1.

(4) Then I'd establish brightness per PWM step.

This allows desired brightness per PWM step to be used to select an RGB mix.
You could

  • scale in software so all colours use value say 0-100 for 0-100% brightness, or

  • 0-100 for absolute intensities (setting most sensitive colour to 100 at mx brightness so it did not get overdriven OR

  • use data "on the fly".

eg SAY
Red = max brightness 200 units at 25.0 mA
Green = max brightness 120 units at 20.0 mA
Blue = max brightness 80 units at 20.0 mA

So Red = 8 brightnesses per mA, 25 mA max So Green = 6 brightnesses per mA, 20 mA max So Blue = 4 brightnesses per mA, 20 mA max

There are various ways of controlling this.
If you ALWAYS want top be able to use equal RGB then blue (being less max bright) red sets the limit at 80bu, 20 mA.
So Green max = 80bu/6 ma/bu= 13.333 mA max
Red max = 80bu/8 = 10 mA Blue = 80bu/4 = 20 mA (as above).

You can use these scaling values on the fly OR if say PWM max = 250 = 25 mA then you could use brightnesses 0-100 per colour so that: Red 100 = 10 mA -> Scaling factor = 1 Green 100 = 13.333 mA -> scale values UP by 1.33
Blue 100 = 20 mA -> scale values up by 2.0

So a value of say RGB 50 50 50 produces "white" light with equal RGB brightness.
Actual PWM values are 50 67 100.
Actual mA are 5 6.7 10.

So also 25 25 25 brightnesses yields white at half the above overall brightnesses and currents.

Changing to 50 20 80 or to 50 80 20 produces a new colour and APPROXIMATELY unchanged brightness IF independent lumen values are added. What the eye-brain system sees may differ.


How did your original experimenting work out?
I'm about to try 'playing' with some LED strips that I acquired.

\$\endgroup\$
1
\$\begingroup\$

Just do a linear interpolation. Say, over 100 time steps, start with the original color and then decrease each component by 1% each time step. You need to preserve the ratio between the components to preserve the overall color. As long as you scale all of the elements by the same amount, the color will remain the same.

\$\endgroup\$
  • 2
    \$\begingroup\$ Actually, linear interpolation is not the way to go. Reducing brightness linearly produces an apparent brightness which doesn't change much until it drops sharply to nothing. Logarithmic interpolation is the key. This is why dBs (decibels, not data bases) were invented. \$\endgroup\$ – WhatRoughBeast Mar 30 '15 at 21:17

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.