I just started the next one I always wanted to do.
An RGB LED color changing using a VR.
PIC is 12F675
Code is already running. I have implemented soft PWM using the method John taught me during the computer table light.
So fay I can control the brightness for all or one color. Mixing is next. My approach is simple. But before that I like to figure out something.
Below is the part I like to know
I am reading the ADC and using it to update the Duty.
I get 64Hz flicker free brightness control.
Q is in here "Freq = Freq_temp/10"
You see the divider "10". If I go to ">100" brightness does not go to max and if low (<4) I get jumping in brightness around some ADC positions . I scoped the output and "10" seems a fine value as I can go from 0 PWM to MAX. How I got it doing trial and programing and checking......
I figures since "Freq" is like 0-255 and the ADC is more. I tried to scale it down thinking that an "int" is like 655535. So I tried divide by 257 to scale it down and brightness was way low.
I am thinking it should be 1023/255 = ~4 . Cause 4 is also working ( I just tried it ).
But wait 4 is also not as good as 10 at high brightness. "10" seems better ( gives smooth brightness change when pot is changed all the way .
So what value is "Freq" ?
Better yet if ADC is 5V max, what is ADC value, is it 1023 or something else ?
{ed}
"20" seems better at low brightness than "10"
Like to figure out the max value in which "Freq" is at max ADC
An RGB LED color changing using a VR.
PIC is 12F675
Code is already running. I have implemented soft PWM using the method John taught me during the computer table light.
So fay I can control the brightness for all or one color. Mixing is next. My approach is simple. But before that I like to figure out something.
Below is the part I like to know
C:
unsigned int Freq_temp;
unsigned char GPIOimg, Freq;
Freq_temp = ADC_Read(0);
Freq = Freq_temp/10;
PWMduty = Freq;
I get 64Hz flicker free brightness control.
Q is in here "Freq = Freq_temp/10"
You see the divider "10". If I go to ">100" brightness does not go to max and if low (<4) I get jumping in brightness around some ADC positions . I scoped the output and "10" seems a fine value as I can go from 0 PWM to MAX. How I got it doing trial and programing and checking......
I figures since "Freq" is like 0-255 and the ADC is more. I tried to scale it down thinking that an "int" is like 655535. So I tried divide by 257 to scale it down and brightness was way low.
I am thinking it should be 1023/255 = ~4 . Cause 4 is also working ( I just tried it ).
But wait 4 is also not as good as 10 at high brightness. "10" seems better ( gives smooth brightness change when pot is changed all the way .
So what value is "Freq" ?
Better yet if ADC is 5V max, what is ADC value, is it 1023 or something else ?
{ed}
"20" seems better at low brightness than "10"
Like to figure out the max value in which "Freq" is at max ADC
Last edited: