PDA

View Full Version : RGB LED driver, Any comments?



paxmowa
- 17th November 2005, 16:25
Hi there,

I'm thinking of building a RGB LED driver for 8 LEDs. I want to use a PIC16F777 for this task as it has a very convenient 3 hardware PWM channels.

I've made a little schematic, but have some questions.
http://users.telenet.be/maxpowa/schema_RGBleds_small.jpg
larger image:
http://users.telenet.be/maxpowa/schema_RGBleds.jpg

I wonder, are the transistors I've choosen OK for the task at hand? Should I use MOSFETs instead, if so, which mosfets are my best choice?

I would power the circuit with an MC33269T-3.3 LOW drop 3.3Volt regulator. Is this OK or are there better options to power the circuit?

Anything missing or other comments?

Thanks in advance,
Steve.

keithdoxey
- 17th November 2005, 17:49
Shouldnt the placement of the transistors be transposed.

PORT D
PNP collector to +5V feeding emitter to common Anode
Take the base to 0V via resistor to turn on an LED

PWM Outputs
NPN emitter to ground, Collector to R,G,B common cathodes
Take the base to +5V via resistor to turn on a colour.

You might also like to take a look at the RGB LED Controller Project http://www.rgbled.org

I am just waiting for the bits for my kit to arrive :)

Just my thoughts.

Regards

paxmowa
- 17th November 2005, 18:19
Dude! You're so right.

Lack of sleep makes pax go crazy.

Thanks a bunch, i'll rework it after some sleep... or coffee...

Steve

keithdoxey
- 17th November 2005, 19:49
Dude! You're so right.
Steve

Apart from when I am wrong!!!


PORT D
PNP collector to +5V feeding emitter to common Anode
Take the base to 0V via resistor to turn on an LED

Should read

PORT D
PNP *EMITTER* to +5V feeding *COLLECTOR* to common Anode
Take the base to 0V via resistor to turn on an LED


That'll teach me to reply in a hurry before dashing out to collect the kids from school :(
DOH !!!!

paxmowa
- 18th November 2005, 16:04
Thanks for the efford Keith.

After a bit of sleep and with a cleared head I made up this:

Updated:
http://users.telenet.be/maxpowa/schema_RGBleds_v3.jpg

Swapped PNP and NPN transistors around, replaced BC547 by BD139.

It aint finished yet i guess.

I checked the specs for the RGB leds and green and blue chips are rated 3.5 to 3.8 volts, red chip is GaAlAs rated at 1.85 to 2.2 volts. The 3.3 volts from the voltage regulator is to high for the red chip and to low for the blue and green. Will prolly go to 5V supply and put resistors in series with each chip.

Anyways, thanks again for the help so far,
Steve

UPDATE:
This is the third version, added resistors in series with each led chip, this should be almost complete i think. Now only add the PIC16F777 and power supply.

paxmowa
- 18th November 2005, 19:13
hmmm, I figure there's also the voltage drop over the transistors. about 0.6 volt each.

So the resistors for blue and green should be 10 ohm and for the red should be something like 82 ohm.

Getting there... slowly, but getting there none the less.

Steven

charudatt
- 22nd November 2005, 05:23
Hello PAX / Other,

I am trying a very similar project in which I send a byte (actually 3 bytes for R-G-B) information for each of the color LED via the RS232 Port to form a Colour Combination.

I am plannig to go about using 3 12F629 for each of the LED's. I am having some problem of communicating the PIC's with the RS232.

Can anyone share some code samples for the RGB LED out here ?

regards

peu
- 21st January 2006, 23:26
Im using a single 12F683 (or 12F675) for controlling the RGB channels and I still have space for an extra potentiometer (for sweep speed) and 2 buttons.

http://peu.net/temp/rgbschem.gif

For PWMing I use PWM instead HPWM, of course if you have 3 HPWM is a little easier, but not much...

you share a common ground and use a 7805 regulator for the pic, then you can power the regulator and the leds with any value from 5-24V (+ after the resistors)

I drive luxeon leds without problem

Have fun

ERIK
- 24th January 2006, 13:27
Hey Peu, I'm working on pretty much the same thing with a 12F675 PWMing to 3 Mosfets. Everything is working well except I'm finding when I PWM from GP2 and GP4 the MOSFETs don't really pulse they pretty much just stay on, or switch off when the cycle gets low enough. I'm not sure why, I've poked the ANSEL and CMCON, but it seems maybe the output voltage on those pins is a little different or something. Anyone have any ideas what might be going on? I see you are driving your green channel with GP2, does that work fine for you?

peu
- 24th January 2006, 14:43
Hey Peu, I'm working on pretty much the same thing with a 12F675 PWMing to 3 Mosfets. Everything is working well except I'm finding when I PWM from GP2 and GP4 the MOSFETs don't really pulse they pretty much just stay on, or switch off when the cycle gets low enough. I'm not sure why, I've poked the ANSEL and CMCON, but it seems maybe the output voltage on those pins is a little different or something. Anyone have any ideas what might be going on? I see you are driving your green channel with GP2, does that work fine for you?

I used this header in a previous version that used gpio.0 as an adc input and 1,2 and 4 as the pwm channels

@ device pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
@ device INTRC_OSC_NOCLKOUT
DEFINE OSC 4

trisio =%00000001
ansel =%00000001 'analog off except gpio.0
cmcon0 =%00000111 'Comparators Off
pasos con 16
ciclos con 10
conta var byte
puerto var byte


and this is the routine I use for the led brightness increase:

for conta=0 to 255 step pasos 'Rise routine
pwm puerto, conta, ciclos ; puerto is the port to be used
next conta
high puerto ; after it reached the top brightness, set port high
return


you can use the same routine for decreasing, just change the for next and put a LOW after the loop instead of the high.

hope it helps


Pablo

KD6OJI
- 9th September 2006, 03:48
Try using a 1K pull down from the gate to ground on your MOSFET's. I have found that sometimes they get a little flaky with PWM and the 1K seems to make a huge difference.

ERIK
- 10th September 2006, 06:13
Ya did put some 1K's on and found the same thing, that it all worked perfectly. I should've come back to this post with that. Strange that I haven't seen any mention of doing that anywhere else.

paxmowa
- 7th October 2006, 18:06
I don't know for sure,

since i changed my computer I should digg out the old schematics somewhere. But I'm pretty sure that there where pulldown resistors in my design. It's never a good thing to leave the pics pin floating in mid air, which will always cause weird results.

This being said, does anyone think it's feasable to design a RGB christmas light with 50 channels from one PIC controller, prefferably 16C class? I don't think it can be done. Last year with the 8 channel set-up, it was already clear that the switching between the colours was getting a bit iffy to say the least, colours bleeded a bit from one transistion to another when working with 2 or more colours at the same time. I would use decimal counters to go down the row of leds, but I don't think it could be switched fast enough to at least have a flicker-free view.

It was programmed like this:

set pwm for red - green - blue
turn on all used channels
wait a few msec
turn off all channels
set pwm for red - green - blue
turn on all used channels
wait a few msec
turn off all channels
etc...

When I wanted one out of two leds to be red and the other ones blue, I ended up with a light shade of blue and a shade of pink, which made me think the PWM channels didn't ramp down fast enough or something.

Steve

eduman
- 27th March 2007, 15:20
I am a new user.Where is the asm or hex code for this cicuit.
Thank you very much.

skimask
- 27th March 2007, 15:24
I am a new user.Where is the asm or hex code for this cicuit.
Thank you very much.

You haven't written it yet!

eduman
- 27th March 2007, 15:35
Sorry,
I don't understand.

skimask
- 27th March 2007, 15:41
Sorry,
I don't understand.

People spend a lot of time learning, building, writing, testing, researching, and repeating that same process until they get the result they are looking for.

I (as well as many others) would be more than happy to write the code to fit your application, design a circuit, build a board, and I'll even hand deliver it to your house/business/whatever...for the right price!!!
Or maybe you could just learn it yourself...

Post your idea for a circuit, and some code to go along with it. We can help you iron out problems.
There's a lot of people around here that would be more than willing to help you out.
But, as for me (and most others), I'm not going to do it for nothing.
One hand washes the other...
You wash my back, I'll wash yours...
Do unto others...
blah blah blah
Get the picture now?

eduman
- 27th March 2007, 15:50
Thank you for your information.

T.Jackson
- 29th March 2007, 14:31
People spend a lot of time learning, building, writing, testing, researching, and repeating that same process until they get the result they are looking for.

I (as well as many others) would be more than happy to write the code to fit your application, design a circuit, build a board, and I'll even hand deliver it to your house/business/whatever...for the right price!!!
Or maybe you could just learn it yourself...

Post your idea for a circuit, and some code to go along with it. We can help you iron out problems.
There's a lot of people around here that would be more than willing to help you out.
But, as for me (and most others), I'm not going to do it for nothing.
One hand washes the other...
You wash my back, I'll wash yours...
Do unto others...
blah blah blah
Get the picture now?

You're here to make money? With that in mind a long with your rather rude attitude, I think you're in the wrong place. Not saying that it's not possible to pick up a job or two around here, but with that sort of attitude I wouldn't hold my breath.

skimask
- 29th March 2007, 14:56
You're here to make money? With that in mind a long with your rather rude attitude, I think you're in the wrong place. Not saying that it's not possible to pick up a job or two around here, but with that sort of attitude I wouldn't hold my breath.

Man, you miss the point completely and entirely...way over your head...

I'm glad you got a good, expensive education. I'm glad that somebody will pay you for your hard learned skills. I hope somebody will recognize you for your many years of effort. I hope those same people recognize you for your years of experience so far. I wish you luck in future electronic adventures. May the demons of evil get confused on their way to your doorstep. I bow to your overwhelming skill and intuition.

If I may quote a little something I found here on the site:
Date of Birth: February 8, 1977
Age: 30
Biography: Fulltime student - Bachelor of Applied Science in IT
Location: Australia
Interests: Cars, Computers, Electronics
Occupation: Currently not employed

I like that last line the best!

T.Jackson
- 29th March 2007, 16:06
Man, you miss the point completely and entirely...way over your head...

I'm glad you got a good, expensive education. I'm glad that somebody will pay you for your hard learned skills. I hope somebody will recognize you for your many years of effort. I hope those same people recognize you for your years of experience so far. I wish you luck in future electronic adventures. May the demons of evil get confused on their way to your doorstep. I bow to your overwhelming skill and intuition.

If I may quote a little something I found here on the site:
Date of Birth: February 8, 1977
Age: 30
Biography: Fulltime student - Bachelor of Applied Science in IT
Location: Australia
Interests: Cars, Computers, Electronics
Occupation: Currently not employed

I like that last line the best!

You're throwing stones at someone who's struggling to do a degree? Few years ago I drove around in a Twin Turbo charged black Nissan 300ZX and I always had a wallet with "something in it" Now the tables have turned, I now live in a remote location with next to nothing. I'm a struggling full time student.

In my better years I have contributed a wealth of knowledge to the Silicon Chip magazine and hardly got paid anything. I currently have a software archive of 17 submissions on Planet Source Code. One of which is in the hall of fame section. I did not get paid a penny for them. Knowledge received / knowledge given is what it's all about. Sadly you seem to have no concept of it. "My overwhelming skill and intuition hasn't come easy I can assure you"

skimask
- 29th March 2007, 16:20
Twin Turbo charged black Nissan 300ZX ----> Wish I could find one of those, I'd even settle for a 280ZX

In my better years -----> All 30-some of them right? I'm 37, and I've said it before, I'll say it again, I know I don't know squat about nothing and probably never will

I currently have a software archive of 17 submissions on Planet Source Code. One of which is in the hall of fame section -----> Does somebody hear a personal horn tooting around here somewhere?

I did not get paid a penny for them -----> Ya think anybody around here does? Well, maybe a select few of the elite...

Knowledge received / knowledge given -----> My point exactly, ya shmo! 'cept that a good portion of these fools/newb's don't want to do ANY of the leg work themselves...they want stuff handed to them on a platinum plate, a one-way transaction all the way, no thought of meeting halfway. Screw that. I've got better things to do.

you seem to have no concept of it -----> you still don't get it...'cause whether you realize it or not, I'm laughing... :)

T.Jackson
- 29th March 2007, 16:41
Lay off the drugs.

skimask
- 29th March 2007, 16:56
Lay off the drugs.

Oh...good comeback there Corky. You come up with that yourself?

lester
- 31st March 2007, 08:57
Hey SkiMask, if you can change a busted cam belt and swap a few valves, i have a Twin Turbo charged Metallic Black Nissan 300ZX sitting here with your name on it.

If you can't or you can't afford to ship it to your location, I'd be happy for you to adopt it - like an adopted pet in an abandoned animal sanctury.

skimask
- 31st March 2007, 09:19
Hey SkiMask, if you can change a busted cam belt and swap a few valves, i have a Twin Turbo charged Metallic Black Nissan 300ZX sitting here with your name on it.

Ouch! Ya have to hate it when that happens!
Much as I'd LOOOOOOOVE to fly over and get my hands dirty, I'd have a helluva time trying to drive it back :D

Wait a minute...I thought Nissan has always used timing chains instead of belts. I've got a '98 200SX/SE, took it to the shop to buy an oil seal for the crank, asked about getting a new timing belt. They said they'd do it for $5 in labor and do it in 10 minutes. That's when I figured out my engine used chains instead of belts :) The mechanic said Nissan's have always used chains (then again, he was a bit doofy looking), probably didn't know what he was talking about...

T.Jackson
- 31st March 2007, 15:48
What a ride! That thing fitted me like hand-to-glove. Doubt too many people would really say much otherwise though. Shame about my current car, he's not all there, just have to ignore it I guess.

cjurczak
- 2nd April 2007, 19:27
Seems everyone is using MOSFETs to switch their RGB leds, any reason not to use a darlington pair?

skimask
- 2nd April 2007, 20:47
Seems everyone is using MOSFETs to switch their RGB leds, any reason not to use a darlington pair?

MOSFETs don't have a secondary breakdown when they overheat, so less chance of burning up. Mainly, no base resistor needed, lower drain-source resistance, practically zero gate current required (gate cap's make it draw a bit of current at high freq's, not much though.

The list goes on...

T.Jackson
- 3rd April 2007, 05:31
MOSFETS are a voltage controlled current source as apposed to BJT's which are a current controlled voltage source. FETs in general have a relatively higher impedance than their BJT counterparts.

I think there's a lot of personal preference between the two. I will make a bold statement and say that "BJTs make better audio amplifiers" In many cases, either of the two can be made to work.

ScaleRobotics
- 25th July 2011, 00:07
This is a pretty old thread. But thought I would add a link to a constant current driver circuit for 1 watt LED's. There are a couple other products around, but this is pretty low part count, and allows from 1 to multiple LED's, so its pretty versatile. It also accepts 7 to 30 volts. They also happen to use a PIC.

Project site: http://picprojects.org.uk/projects/hbld/index.htm

Calculator tool for ZXLD1350 chip: http://www.diodes.com/_files/calculators/zxld1350calcv2.xls (http://www.diodes.com/_files/calculators/zxld1350calcv2.xls)

5794

5793

Docedison
- 7th March 2012, 22:52
No, however they will require more heat sinking than a Mosfet of equivalent current capacity. Since it is a switch (PWM) the LOW RDSon of most all power mosfets < .1 Ohm Vs a VCEsat of > 1Volt makes it a kinda No Brainer unless all you have are some tip121's? I don't remember which... But @5V gate voltage an IRF 540 is hard to beat for a GP Power Mosfet.
Doc