How to simulate different lighting with RGB LEDs

CudaBlu

New Member
I have searched the forum and have not found the answer (at least one that is obvious to me, not saying it isn't here) that I need to the following task.

I have an inexpensive RGB LED strip (5m) such as this that I would like to use to simulate different lighting conditions such as outlined here. This site gives the RGB values for each lighting scenario in a few charts on the web page. Such as: Candle light as: R=255, G=147, B=141.

I have breadboarded and tested the circuit I need to control the LEDs and have written some very simple programs to control the LEDs via pwmout/pwmduty. But I am at a loss as to what values I would use in the pwm... commands to produce the RGB values as outlined in the charts.

Can someone tell me if the pwm setting can be the same as the lighting RGB values or would there be a formula that would need to be applied?

Thanks for the help.
 

nick12ab

Senior Member
Use a period value of 63 in the pwmout commands and the valid range of duty cycle values will then be 0-255. Then try using those R/G/B values for the pwmduty values for each colour of LED.
 

CudaBlu

New Member
Thank you nick12ab, I will give that a try!

At the risk of showing my true ignorance, in case I haven't already, out of 256 different possibilities to set period to how do you come up with 63?
 

nick12ab

Senior Member
At the risk of showing my true ignorance, in case I haven't already, out of 256 different possibilities to set period to how do you come up with 63?
For pwmout, the acceptable range of values for period is 0-255 and for duty is 0-1023 (so duty has 4 times the range of period) and the acceptable range of values for duty decreases as period is decreased so to get a range for duty of 0-255, period needs to be set to 63.
 

CudaBlu

New Member
I was just reading up on this in the manual (2), I should have waited til after I did the reading then I probably wouldn't have displayed my ignorance. But in all honesty I still don't think I would have gotten it. I just noticed there is a wizard for this in the program editor software, I will check that out next.

Thanks again for getting me steered in the right direction.
 

nick12ab

Senior Member
I was just reading up on this in the manual (2), I should have waited til after I did the reading then I probably wouldn't have displayed my ignorance. But in all honesty I still don't think I would have gotten it. I just noticed there is a wizard for this in the program editor software, I will check that out next.
The wizard calculates the PWM values according to a frequency and duty cycle percentage that you specify.

Unless you are going to be filming the LEDs, the frequency is unimportant (as long as it isn't too excessively high which would reduce the efficiency of any driving transistors) so you kight as well choose 63 for the period to simplify the duty cycle value.
 
Top