Hippogriff
Member
Hi all,
I've hit a hurdle with my RGB LED experiments. I have a PIC 16F684 controlling 3 RGB LED strips... so that's 9 output pins I'm using. Everything is absolutely fine when I'm setting individual pins off and on, I can get reds, greens, blues, yellows, purples, cyans and whites on each individual RGB LED strip - it all looks very nice indeed.
The issues come when I start to do software PWM on each of the pins. If I'm doing the same colours as above, i.e. ones that are - effectively - set at either 255 or 0 PWM levels, then everything is fine. The problem is when I set them to something a bit more interesting, like "Dark Orange" RGB = 255,140,0 or "Deep Pink" RGB = 255,20,147 - then I get flickering.
I think my PWM routine, setting 9 IO lines, might be too resource intensive to stop the flickering going on, because - if I reduce the routine so that it only does a single set of RGB then I can set "Dark Orange" or "Deep Pink" and the single RGB LED strip does not flicker.
If I do two RGB LED strips, then I see some flicker and, when doing all three, back to full-on flickering.
I was wondering how I might get around this and, so far, the only thing I've thought of is to change direction a bit and use three PIC 12F683s in concert, each one controlling a single RGB LED strip - which I know, from experience, can do the job perfectly well. Is that a mad idea or should I be able to finesse the current 'solution' so that I can set three RGB LED strips from a single PIC without experiencing flickering?
My simple software PWM routine (JAL) for 9 pins...
I've hit a hurdle with my RGB LED experiments. I have a PIC 16F684 controlling 3 RGB LED strips... so that's 9 output pins I'm using. Everything is absolutely fine when I'm setting individual pins off and on, I can get reds, greens, blues, yellows, purples, cyans and whites on each individual RGB LED strip - it all looks very nice indeed.
The issues come when I start to do software PWM on each of the pins. If I'm doing the same colours as above, i.e. ones that are - effectively - set at either 255 or 0 PWM levels, then everything is fine. The problem is when I set them to something a bit more interesting, like "Dark Orange" RGB = 255,140,0 or "Deep Pink" RGB = 255,20,147 - then I get flickering.
I think my PWM routine, setting 9 IO lines, might be too resource intensive to stop the flickering going on, because - if I reduce the routine so that it only does a single set of RGB then I can set "Dark Orange" or "Deep Pink" and the single RGB LED strip does not flicker.
If I do two RGB LED strips, then I see some flicker and, when doing all three, back to full-on flickering.
I was wondering how I might get around this and, so far, the only thing I've thought of is to change direction a bit and use three PIC 12F683s in concert, each one controlling a single RGB LED strip - which I know, from experience, can do the job perfectly well. Is that a mad idea or should I be able to finesse the current 'solution' so that I can set three RGB LED strips from a single PIC without experiencing flickering?
My simple software PWM routine (JAL) for 9 pins...
Code:
procedure OutRGB3 ( byte in pRTop,
byte in pGTop,
byte in pBTop,
byte in pRMid,
byte in pGMid,
byte in pBMid,
byte in pRBot,
byte in pGBot,
byte in pBBot
) is
var byte BrightnessTest
for 255 using BrightnessTest loop
if (BrightnessTest >= pRTop) then RTop = off else RTop = on end if
if (BrightnessTest >= pGTop) then GTop = off else GTop = on end if
if (BrightnessTest >= pBTop) then BTop = off else BTop = on end if
if (BrightnessTest >= pRMid) then RMid = off else RMid = on end if
if (BrightnessTest >= pGMid) then GMid = off else GMid = on end if
if (BrightnessTest >= pBMid) then BMid = off else BMid = on end if
if (BrightnessTest >= pRBot) then RBot = off else RBot = on end if
if (BrightnessTest >= pGBot) then GBot = off else GBot = on end if
if (BrightnessTest >= pBBot) then BBot = off else BBot = on end if
end loop
end procedure