Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

27 channel PWM with a 16F88

Status
Not open for further replies.

geko

Active Member
Here's a video of a little project I've been tinkering with.

9 RGB LEDs, 27 x 6 bit PWM channels on an 8Mhz PIC 16F88.

The LEDs are driven in 3 groups of 3. The outputs are multiplexed as well as PWM'd to get the 27 channels through 9 sink outputs and 3 source drivers.

YouTube - Rainbow 9
 
Nice project. I like how you mounted the piranha led's, in case you have a dud, it's an easy replace. Need to get some of those piranha's.
 
Very nice geko, but what's the deal with Youtube clips and techno? That clip almost requires a disco song. I demand Dancing Queen!
 
Thanks geko, you just made my day.
What's this for anyways?
 
Nice project. I like how you mounted the piranha led's, in case you have a dud, it's an easy replace. Need to get some of those piranha's.
Actually the sockets are mainly so I can recycle the LEDs into the next project.

Oddly enough the only dud Piranah LEDs I've had came from a reputable UK distributor; all the cheap ones I've bought off eBay from HK & China have never let me down.:confused:
 
Thanks geko, you just made my day.
What's this for anyways?

I was asked to do it with the requirment that it has 9 RGB LEDs and runs on a 16F628.

Initially I thought it was complicated to achieve and pointless and wasn't that keen to take it on but now I've had it running in the workshop it's quite mesmerising - the video clip doesn't do it justice.

It might yet end up a project on the website.
 
This is excellent nicely done.Good work.

Did you extend your vertical counter Pete?

No I haven't used vertical counters on this, it doesn't lend itself to them because it needs 27 PWM channels, and even though it's split into 3 groups that's still 9 bits so it's not byte friendly.

I just used this basic method below. Because the PWM is only 6 bits (0-63) pwm.count is initalised to 256-63 at the start of each period, and is incremented. There's a little bit more code that's not shown to pull it altogether but this is the core of the PWM generation.

Code:
              movfw       pwm.count
              addwf       pwm.led1,W
              rrf         portb.copy,F
 
              ; ..... repeat for leds 2 thru 7 
 
              movfw       pwm.count
              addwf       pwm.led8,W
              rrf         portb.copy,W
              movwf       PORTB
 
              ; deal with that pesky 9th LED on port A
              ; porta is also controlling the common anode source transistors
              movfw       pwm.count
              addwf       pwm.led9,W
              skpnc
              bsf         porta.copy, led9
              movfw       porta.copy
              movwf       PORTA

This method is also a bit more handy for experimenting with different PWM resolutions too, just change the pwm.count intialisation value.
 
Last edited:
Hi Pete thats a nice method.I like your CARRY transferring method. Let me compact it more sir :D.

I more prefer your way is because you are turning off the LEDs until matches the duty & sets the particular bit.This is smoother when animating LEDs.
 
Last edited:
Hey geko, what's the partnumber on those LED's and where did you buy them from?
 
Here's a video of a little project I've been tinkering with.

9 RGB LEDs, 27 x 6 bit PWM channels on an 8Mhz PIC 16F88.

The LEDs are driven in 3 groups of 3. The outputs are multiplexed as well as PWM'd to get the 27 channels through 9 sink outputs and 3 source drivers.

YouTube - Rainbow 9
Hi Pete,

Is the schematic for this 9-channel RGB controller somewhere on your web site Sir?

Regards, Mike
 
Pete,

In my previous post I forgot to say that I think your demo' and prototype PCB looks extremely nice.

Thanks for posting the schematic. So, you're using direct drive from I/O for cathodes and source driver transistors on the common anodes as I suspected.

Did you limit software PWM duty cycle to 64 steps (6 bits) because of ISR driver "overhead" and to produce a decent refresh rate?

Regards, Mike
 
Hi Jason,

I just stumbled onto it yesterday too.

Pete did an extremely nice job on this project but I would like to update it with a BAM (bit angle modulation) driver of my own design which should allow for 8 or 9 bit resolution (256 or 512 steps, respectively) at extremely high refresh rates on the order of several hundred Hertz.

More later. Regards, Mike
 
Last edited:
would be nice if i had some code to examine heh... when ready im sure it will be posted here. This is awesome tho really! Great job to the both of you. Its like thanking the guy who invented the wheel then the guy who smoothed it out heh
 
Pete,

Did you limit software PWM duty cycle to 64 steps (6 bits) because of ISR driver "overhead" and to produce a decent refresh rate?

Regards, Mike

I think that was why I did it that way yes.

The whole thing was done as a bit of an experiment after I was asked if it could be done - they wanted 9 RGB channels and so the challange was there and I just had a play to see what I could do. The PCB had the option for an external crystal but I think I had no crystal to hand so it started with the internal 8Mhz RC.

I can't really remember too much about it, I hacked it together over a couple of evenings and haven't been back to it since. It uses sine wave data in a look up table (calculated in Excel) to generate the duty cycles.

Depending on the 'angle' between the RG & B offsets into the table and the channel index seperation you can tune the spread of colour across all the channels (full colour spectrum or narrow colour 'window' ) and also the rate it changes through the spectrum.

The source code is a bit rough and ready and was never really finished but here it is anyway:)

Attachement doesn't seem to want to open so here's a link direct to my website.
**broken link removed**
 

Attachments

  • rainbow9..zip
    42.4 KB · Views: 274
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top