As I continue to mess with RGB LEDs, I have written a working, proof-of-concept program on an 08M to generate three, independent synchronous PWM outputs. Although the frequency won't be high enough (LED flicker) on an 08M for my application, it does allow me to test this algorithm. Currently, my program can handle RGB counters, ranging from 2-bits each to 8-bits each. This allows for discrete colors, ranging from 64 (4x4x4 for 2-bit) colors to 16.7 million (256x256x256 for 8-bit) colors. I ultimately plan to program a standard pic (actually, reprogram an extra 08M) when the program is finished for higher PWM frequencies.
I have a couple of questions:
1. I would like to "tighten" up my existing code, hopefully making it run faster on the 08M. After seeing Hippy's magic, I was hoping someone could suggest programming improvements to the following code:
2. Second, does anyone have any successful experience taking a Picaxe program into PicBASIC Pro (editing as necessary) to generate the hex file, and ultimately reprogramming an 08M? Recently, I think there was a thread talking about a DIY programmer (not the Microchip Pickit2), but I can't seem to find it. As I have never programmed a pic before, I am looking for suggestions to do it SIMPLY!
3. Finally, I plan to dedicate this chip to generating the PWM signals and another 08M for control and running my application. As I have not connected two 08Ms together before, I would appreciate suggestions on how to package the data to send to the "slave" PWM generator, as I need to do it quickly (every 100ms-500ms). Initially, I need to send a control signal (number of bits per color counter and uC clock speed) and then ongoing RGB color update information. I think each can be done in a single byte, but do I need to worry about a CRC check to verify successful transmission? I think not since another update comes quickly. Is any form of handshake required or just send the data?
All comments welcome.
Richard
I have a couple of questions:
1. I would like to "tighten" up my existing code, hopefully making it run faster on the 08M. After seeing Hippy's magic, I was hoping someone could suggest programming improvements to the following code:
Code:
Do
counter = counter +1 & mask
if counter = 0 then : PWMgen = red ^ green ^ blue : endif
Rcounter = Rcounter + 1 & mask
if Rcounter = 0 then
if Rduty = mask then
Rcounter = Rcounter + 1
else var = red : endif
endif
gosub update
Gcounter = Gcounter + 1 & mask
if Gcounter = 0 then
if Gduty = mask then
Gcounter = Gcounter + 1
else var = green : endif
endif
gosub update
Bcounter = Bcounter + 1 & mask
if Bcounter = 0 then
if Bduty = mask then
Bcounter = Bcounter + 1
else var = blue : endif
endif
gosub update
pins = PWMgen
loop
update:
PWMgen = PWMgen xor var
var = 0
return
3. Finally, I plan to dedicate this chip to generating the PWM signals and another 08M for control and running my application. As I have not connected two 08Ms together before, I would appreciate suggestions on how to package the data to send to the "slave" PWM generator, as I need to do it quickly (every 100ms-500ms). Initially, I need to send a control signal (number of bits per color counter and uC clock speed) and then ongoing RGB color update information. I think each can be done in a single byte, but do I need to worry about a CRC check to verify successful transmission? I think not since another update comes quickly. Is any form of handshake required or just send the data?
All comments welcome.
Richard
Last edited: