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.

switching a block of LEDs with a PIC?

Status
Not open for further replies.

Andy1845c

Active Member
Just looking for some opinions and feed back on my project:)

I have 36 LEDs I need to light with a PIC. I have them wired in as is shown in my drawing.

It will be used in a car, so supply voltage will vary from just under 12v, to almost 15v. I am using 11.5 and 15 as high and low end.

If I use 100:eek:hm: current limiting resistors, I come up with 31mA low end and 66mA high end for current. I will probably go with a little higher resistance to keep from cooking things at 66mA, but for now I am just using this figure.

I need to get my 16F628 to control 8 of these moduals. What is my best option for a switch?

Would I be correct to say that whatever transistor or MOSFET I use will dissapate 3.2 low end to 13.1 watts high end? I'm not sure if I have my math right on that. That seems like alot. :confused:

What decideds if the situation calls for a bipolar transistor or a MOSFET or a darlington?

MOSFETs sound interesting, but I thought I read somplace that it takes 7? or more volts to get them to fully turn on. With I PIC, don't I have 5v at best?

From what I understand, darlingtons only need a very small base current to operate a much larger emitter-collector current. Is this correct?

But I have never used either.

Anyway, just looking for opinions and to understand things a bit more:)

Andy
 

Attachments

  • pictures.jpg
    pictures.jpg
    26.6 KB · Views: 268
Ugggggg.... wrong forum:rolleyes::eek: I'm really on top of it tonight:rolleyes:

Nigel, if I ask really nicely, will you move it for me? Pretty please?:p
 
A couple of ULN2003 Darlington arrays would keep component count to a minimum, and they are cheap as chips.

They act like a digital switch that switches the earth to or from the external circuit. A logic High input will close the circuit to earth, and a Logic Low will open circuit the earth.
**broken link removed**
**broken link removed**
 
I thought about the ULN2003, and actually have a few around, but it can only take a 500mA current and dosn't provide any means to attach a heatsink.

I assume the 500mA is total current and not current per each of the 7 channels?
 
Ordinary 5mm LEDs have a max continuous current of 30mA. They will fry at your much higher current.

But then you have 4 LEDs and a 100 ohm resistor. If the LEDs are white or blue and need 3.5V each then they will barely light because they will need a 16.5V supply for 25mA.
 
MOSFETs sound interesting, but I thought I read somplace that it takes 7? or more volts to get them to fully turn on. With I PIC, don't I have 5v at best?
Use a logic level MOSFET which is designed for 5V signals.
From what I understand, darlingtons only need a very small base current to operate a much larger emitter-collector current. Is this correct?
Yes, for the same collector current, they require apx 10X less base current than a regular bipolar transistor but their saturation voltage is apx 0.7V higher.
I assume the 500mA is total current and not current per each of the 7 channels?
Sort of..... It depends on the ambient temperature, number of active outputs and their current and the duty cycle of the outputs. This info is also in the datasheet; at 85C, if 7 outputs are active, then the max you can draw continuously is around 100ma per output. If all 7 of the outputs are only on 20% of the time then the max per output is increased to 350ma....
https://www.electro-tech-online.com/custompdfs/2007/03/uln2003ai.pdf
 
Last edited:
Wow. Sorry for not reading the datasheet better, but man, that seems like alot for such a tiny IC with no surface area. I think I better find something I can put a heatsink on. The duty cycle won't be 100%, but i'd like to make sure everything stays cool as possible. It will be in the car, so in the summer sun, the thing could be 130 degrees already.

AudioGuru, these are those goofy amber spider style LEDs I posted about a while back. Max current is 70mA, but they don't get much brighter past about 35mA.
Forward voltage is about 2.2v average. I measured a bunch to make sure.
 
Indicators maybe?
 
just use transistors man ;) BC618 is a good one: 800mA. you need no freaking heatsink. and PWM the LEDs! no-one uses them at fully on anywhere.
 
The first thing to remember when using a transistor as a switch, is that when on it has almost no voltage across it. That means almost no power being dissipated by the transistor. When off no current is flowing, so again no power. The chief design consideration for a switching transistor in this scenario should be current, not power.

The second consideration is that if a single (bilpolar junction) transistor is used to provide power to all these LEDs, it will need a lot of base current to saturate. A darlington is your best bet. But don't overlook the possibility of using a number of cheap low current transistors, each powering a single LED string, or some compromise such as a small transistor powering two strings.

In the one-transistor-per-string case each string is drawing about 30mA, and for a transistor beta of 50, that means a base current for each transistor 0.6mA. We should increase this to something like 1mA (to ensure saturation even with the worst transistor batch ever). Ten transistor bases is a total of 10mA, which your PIC output should be able to source. Most common or garden species of small NPN transistor, like a 2N3904 or BC108 would do a fine job.

Here's a picture:
 

Attachments

  • npns_and_leds.png
    npns_and_leds.png
    5.9 KB · Views: 228
Last edited:
Cabwood - thanks for the post. It clears things up a bit for me. I was unsure how to calculate the power dissapation for transistors. I think I am going to try a darlington for starters. I was hoping I could switch all strings with one device to save on components. But your method is an option.

Hero - No, its not really for use while the vehical is moving. More for being stopped along the highway. Here in Minnesota, we have a volunteer program for picking up litter in the highway ditches. I adopted a couple mile section this year and thought i'd use the light when I walk my section if I end up parking on the road. It should be brighter then the 4-ways and won't make it look like I am broke down.
 
just use PDTC123ET NPN transistors. I bought a couple of them as they turned out to be VERY useful indeed. I switch relays LED's (7 segment) and just about everything that needs switching by an AVR. Doesn't heat up, easy to use, integrated resistors (especially meant for switching) etc.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top