At 10:14 PM +0100 1/30/03, Wouter van Ooijen wrote: > > My need is to drive an RGB LED which is more or less like driving 3 >> discreet LEDs. Since I want to be able to generate an arbitrary >> color and brightness, and still have lots of PIC left to do other >> things, using a part with 3 hardware PWM outputs seemed like a >> natural. > >Are you sure you won't have enough CPU left after bit-banging 3 PWMs for >LED driving? If that is realy the case why not use a dedicated small PIC >(12F629) to do the job? > >Wouter van Ooijen yeah, further down I mention that as a possibility... napkin calculation regarding time needed for bit banging...but correct me if I am thinking about this the wrong way...I am still learning... To ensure no flicker problems lets say the basic cycle is 100hz. Then if I use 8 bits of resolution for brightness I have to check the duty cycle (256*100) = 25600 times per second. At 4 Mhz I get 1000000 instructions per second. So if the PWM calculation is in an event loop, I get 1000000/25600 or about 39 instructions per loop. I'd rather use 10 bits of brightness resolution. (This *can* be seen at low levels of brightness. I want to be able to ramp up the LED without "zipper noise" or obvious "steps". I might be able to use some kind of nonlinear transfer function so there is more resolution at low light than bright...). So for 10 bit resolution 10^6/(2^10*100) = 9 instructions per loop A 20 Mhz crystal will allow about 45 instructions per loop. Or 195 instructions at 8 bit resolution. Given all the other stuff I expect to be doing I don't think that is enough cycles to do it all on one PIC...frankly I'd like the "cpu" to be entirely unburdened from PWM generation. Phil -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body