LED Question - I must be missing somethong really simple

Hi,

I am trying to drive two sets LED's using an Arduino.

The LED's run at 12v, so I naturally thought a little bit of code to strobe the LED's alternately, and a few TIP31C (NPN) Transistors would do the job nicely.

Tests using this setup worked great, so the project was built.

But, When it came to fitting the lights to be used to the controller, I found an issue...

The LED's im using are built with a white and an amber LED on each, both 12v.
They have a common ground, and a separate 12V feed for the white and amber LED. So, of course, won't work with the NPN Transistors in the circuit.

Can I just swap them for PNP Transistors and it'll work, or am I missing something else?

Thank you

Well, kind of. NPN transistors work when you pull the base up relative to the emitter by providing base current through a resistor. The PNP transistors will switch the high side, and work when you pull the base down relative to the emitter - the problem in this case is you are switching 12 volts, so you will need to have a NPN transistor on the low side being driven by the Arduino that is used to sink the base current of the switching PNP transistor on the high side - basically, what you need is something like Fig 3 in that image. If you do a Google search on "high side switch", you will find lots of options, but the bottom line is it takes two transistors of some form to switch the high side with a low level logic signal.

benc1981:
The LED's run at 12v

Sounds like you're missing a few other key pieces of information. How about a link to what these LEDs are?

benc1981:
Tests using this setup worked great, so the project was built.

How did you test them?

benc1981:
They have a common ground

That's known as common cathode.

benc1981:
So, of course, won't work with the NPN Transistors in the circuit.

Of course? why doesn't an NPN high-side switch work?

(You may need to move the LED's current limiting resistor to the collector of your NPN.)

You can use NPN as a high side switch, but you have to pull the base up to the collector which in this case is 12v. you could reference the Arduino against the +12v and pull the ground side of the Arduino down 5v, but that would be a pain. If he was switching 5v then you could work the problem with the NPN on the high side and drive the base up to 5v, but the 12v is a no-no on a Arduino pin.

The LED's are 12V Lights off of a tractor.
They're the side/driving lights and turn signals.

They're being re-purposed into a white/amber flash unit for warning.

But, as with most automotive lights, they have a single ground, or common cathode.

I tested the unit with 12V LED's that didn't have a common common, I had wired them into a Common Anode, so used the NPN on the ground side for switching, which worked very well.

I understand I need something like this:

My question is, Would the BD442 be a suitable PNP for this application?
It's switching 14.8v max, at around 300mA

I had been using the TIP31C as the NPN.

Draw a schematic and post a photo of it.

You description is hard to follow.
If you are trying to say NPN transitors won't work because two different colored lights are mounted in one assembly that has TWO +12V terminals ( one for each color) but only ONE common GND, then the PNP high side transistor idea may not work using 0 V to turn on and 5V to turn off. You will need to verify that the PNP transistors turn ON AND OFF.
Sparkfun logic level mosfets with a TC4427 mosfet driver chip would work if the PNP transistors don't do the job.

That 5k doesn't look right - or is the PNP meant to be a darlington?

We don't know what the current draw is yet, I'd say go for a p-MOSFET with an on-resistance
of 50 milliohms or less, then several amps can be switched easily. The BD442 is a simple PNP
power transistor needing Ib = Ic/20 or so and Ic might be a lot.

Runaway Pancake's circuit looks good.
If building a lot of these and making a PCB, then could consider a small resistor-equipped surface mount chip (very small, only 1 part needed).
I doubt that LED current would be a problem (for 1 light colour) because the lights will have built-in resistors.

dlloyd:
Runaway Pancake's circuit looks good. If building a lot of these and making a PCB, then could consider a small resistor-equipped surface mount chip (very small, only 1 part needed).

I doubt that LED current is even a consideration because the lights will have built-in resistors.

They may even have a built in switching regulator in them - look at the LED tail lights on cars these days - when they are on, turn your eyes so they scan across the lights and you will notice they are being strobed to maximize the apparent brightness of them.

They may even have a built in switching regulator in them - look at the LED tail lights on cars these days - when they are on, turn your eyes so they scan across the lights and you will notice they are being strobed to maximize the apparent brightness of them.

Ahh, possible ... I was thinking of just the generic trailer/truck LED lights. Hmm, if its one of these simpler ones, could pulse the common ground (PWM) +NPN to control brightness. Or even just PWM the amber and white control signals independently.

PWM Runaway_Pancake's circuit. It resolves the voltage difference between the arduino output and the voltage needed to drive the transistors.

MarkT:
That 5k doesn't look right - or is the PNP meant to be a darlington?

Darlington? No way.
The 5k determines PNP base current. The 10k pulls up the PNP base, through the 5k, when the NPN is off (not conducting.)
If more base current is required then reducing base resistance ("the 5k") would allow for that, the NPN will oblige.

5k limits the base current when on to 2.4mA, which won't saturate the PNP
transistor at all.

or is the PNP meant to be a darlington?

A darlington by definition is two transistors of the same type (NPN/PNP) and has both collectors tied together. The two resistors wouldn't be there and the emitter of the driver would be connected to the base of the output transistor.

the OP is using a BD442 PNP so he would need a 417 ohm base resistor to get 4A of current with an hFE of 140.

MarkT:
a) 5k limits the base current when on to 2.4mA,
b) which won't saturate the PNP
transistor at all.

a) Correct
b) "Won't"? That depends on the collector current (NOT stated) needed - see Reply #12, IB : IC

b) "Won't"? That depends on the collector current (NOT stated) needed - see Reply #12, IB : IC

I looked for the load current and couldn't find it in the OP's posts.

My preference for picking a base resistor like that is to take the load current expected (worst case), use the worst case Hfe of the transistor to figure how much current I need to drive it into saturation then double that base current (assuming you stay clear of max. base current or max drive from the Arduino or whatever you are driving it with) and use that value to calculate the base resistor. I may move either way, but that is a good starting point - you want to make sure you drive the transistor into saturation in a switching application like this - if it starts getting into the linear region, you get poor drive as well as heating in the transistor.

My preference for picking a base resistor like that is to take the load current expected (worst case), use the worst case Hfe of the transistor to figure how much current I need to drive it into saturation then double that base current (assuming you stay clear of max. base current or max drive from the Arduino or whatever you are driving it with) and use that value to calculate the base resistor. I may move either way, but that is a good starting point - you want to make sure you drive the transistor into saturation in a switching application like this - if it starts getting into the linear region, you get poor drive as well as heating in the transisto

Isn't it hard to do that when you don't know the load current ?

raschemmel:
Isn't it hard to do that when you don't know the load current ?

Yes - my point in my post was to define the process I use. And you are correct - the first part of the whole thing (which seems completely foreign these days) is to develop a set of requirements that defines what basic parts (and their specs) you are going to be using and what you are trying to control and what those specs are. My post was an attempt to give people unfamiliar with this sort of thing a place to start in their calculation of what values to use for their circuit. As to whether 5k is correct in this case, we don't know because we don't know the transistors OR the load involved.