Small Problem / Explanation Request

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
Okay i'm reasonably new to building my own circuits so I'll try to be as detailed as possible with what I am attempting to do..


I have a micro controller that has a PWM function. It is programmed to output a variable PWM signal from 0 to 100% duty cycle. The basic layout is shown here on figure "A"




All LED's share a common cathode (-) and the cathodes are attached to R5 which is a varying PWM signal.

The LEDs annodes are connected to R2 and R3. These outputs are switched high (+) by the micro controller in sequence, ie the first LED on R2 goes high and the LED fades in from zero to 100% then back out. R2 goes low and r3 goes high then the second LED fades in then back out.

This works as expected however; fade is only one part of my overall need.


Figure "B" shows another mode of operation:



The LEDs that I am turning on/off need more than the 5v+ that my micro controller can supply. (they are wired for 12v operation already and that can not change). Likewise there is an un-determined number of LEDs that may be connected to any one output. Thus I solved the problem of giving them a full 12 volts by incorporating a NPN type transistor on the outputs of the micro controller. When R2 goes high the transistor connects the LED(s) to ground.

This by itself also works as expected, no issues here.


When I attempt to combine the two methods is where I get into trouble. I can manually set the PWM (- output) to 100% duty cycle (or whatever brightness I want) and in theory simply switch on the LED channel as desired. Giving the LED its (+) feed, this again right off the PIC will only give me 5 volts or so to work with.

Thus I am looking at this solution:


All LED's would share a common cathode (-) which is the PWM set at 100% duty cycle R3.

Using a PNP type transistor connected to the output ports (r1, r2, r3 etc).
I should be able to supply the LEDs with their positive power triggered by the output at R2 going low (-).


I will need to re-work the programming on the chip to account for the outputs going low instead of high but that isn't a big deal at all.

My question is this:
1) Am I going about this the right way with a PNP transistor?
2) Do I need any diodes in the mix here to protect the micro controller mostly.
3) Does anyone know of a way to accomplish this for several output channels (R1,R2,R3,R4 etc.) without using a separate transistor per output? It's not a big deal if it has to be that way but I need the channels diverse.

Thanks in advance!


*EDIT* looks like I drew my PNP transistor wrong, as the arrow should be the other direction... does this mean i'll need to swap the C and B as well on the transistor?
 

Attachments

Last edited:

wayneh

Joined Sep 9, 2010
17,496
I lost you when you switched to using a PNP instead of the NPN you had working. For each channel, I'd have all the +12v loads connected on the high side and a signal coming from your controller to each NPN base pin. Controller ground is shared with 12v ground (beware potential ground currents), so a high pulse of 5v turns on the transistor and the load.
 

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
I lost you when you switched to using a PNP instead of the NPN you had working. For each channel, I'd have all the +12v loads connected on the high side and a signal coming from your controller to each NPN base pin. Controller ground is shared with 12v ground (beware potential ground currents), so a high pulse of 5v turns on the transistor and the load.

if you'll note, figure b - The NPN example had the anodes connected to +12v and the cathode was switched to ground (triggered by the pins going high)

in figure A with the PWM output is ground, and all the grounds need to be common. The +12v feed needs to come from somewhere so I thought it was necessary to switch to a PNP transistor.

Since I need to switch (+) voltage instead of (-) voltage with the transistor,
is a PNP is needed or am I mis-informed? I assumed the base which is a (-) when R1-3 are low would trigger the PNP transistor. Then if the collector was connected to +12v dc it would then supply the LEDs with the +12v to their respective anodes out of the emitter.

The systems separately work fine, when I try to combine them i'm having trouble figuring out where and which transistor to use to switch +12v to them instead of the +5v that i'll get out of my PIC.

FWIW I wasn't incorporating a transistor and +12v in the PWM example drawing because I haven't gotten that far yet, it was operating on +5 volts with dim LEDs.
 

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
I think the arrangement you seek is this:


I have that arrangement in my figure B drawing. Which works fine when the LED's have the CATHODE switched to ground and a common +12v anode.

I need them to all have a common cathode that is grounded via a PWM ground output. Then I need the ability to switch their anodes to +12v dc.

Thus I have +12v running through the collector out to the emitter, and the base needs to be able to accept a ground. The above diagram if connected to ground would just ground both the cathode and anode of the led in question when using a NPN transistor.


Figure "C"


Again: R5 is a common ground to the LED(s) and R2 can be + or - either way but it can only output +5v which is not enough for my purposes.

I need to incorporate a transistor to switch +12v to the anode side of the LED. Thus this is the reason im asking if a PNP transistor is proper or if I am just confused.

perhaps I am completely missing the obvious here, I Just don't see how using a NPN in this situation connected to ground would do anything except throw ground to both the cathode and anode of the LED.

figC.jpg
 

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
If I understand correctly, I think this is what you are looking for.
Okay now if I understand your diagram correctly you're using two transistors to basically switch the polarity right?

The v2 would be my low voltage source which when the base goes high it passes a ground to the second transistor upon receiving said ground it switches the higher voltage source v1 to the led anode.

The cathodes are still connected to the ground output at v1.

If v1 was to output two grounds. Ie one to the cathodes and one where the first transistor is could the first transistor be eliminated from the circuit?
 

wayneh

Joined Sep 9, 2010
17,496
If v1 was to output two grounds. Ie one to the cathodes and one where the first transistor is could the first transistor be eliminated from the circuit?
If everything to the left of R1 was gone, and a wire from battery ground was touched to R1, the LEDs would light. Does that answer your question?

Actually, any voltage more than about 1V less than the battery voltage will begin to turn on the transistor. For instance instead of a wire to ground touched to R1, you could put a 1.5V cell, its "+" to your +12V and its "-" to R1. This should also light the LEDs but perhaps not as fully.
 

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
If I understand correctly, I think this is what you are looking for.

Okay guys, I think I've figured out the terminology for what I am trying to do. I need to preform High Side switching where the load being switched is at a higher voltage than the voltage supplied to the micro controller. Which appears to be exactly what ronv has given me. I kept asking if there was a way to eliminate the NPN transistor from the circuit because I will need to do this for at least 4 different outputs which will require 4 NPN & 4 PNP transistors. as well as multiple resistors per setup.

I would rather keep the overall number of components that will be required in the finished module as low as possible, for simplicity as well as cost purposes.

Does anyone here know of another way to pull off high side switching? OR would it be possible to apply rony's diagram to my PWM ground output to switch its polarity so that all anodes can be common? and I can go back to using NPN's to switch grounds to the individual LEDs to turn them on/off?
 

wayneh

Joined Sep 9, 2010
17,496
Your last suggestion may be the ticket. Get a single big P-channel MOSFET to send 12V forward every time the PWM signal goes to ground.

I think we've all been confused trying to understand your setup. I know I have been. Your PWM signal, is it open collector, pulsing between ground and "float"? It does not (now) pulse between ground and +12V? I think that's not a normal implementation, and the cause of confusion.

Your control lines do not control the PWM signal, but rather whether that signal is to be applied to the LED in question?
 

MMcLaren

Joined Feb 14, 2010
861
If you'd like to keep all of the switching on the low side (common anode instead of common cathode) then may I suggest using something like a TPIC6C595 8-bit serial-to-parallel sinking driver IC (90 ma outputs)? This would give you the ability to "steer" the PWM output onto one (or any) of eight channels using just two I/O pins plus the PWM pin, along with a small interrupt 'helper' routine. One caveat with this method is that your duty cycle would be inverted since you'd be driving the active low <output enable> pin on the driver IC with an active high PWM output.

You did say you can change from a common cathode to a common anode configuration, correct?

Good luck with your project.

Cheerful regards, Mike
 
Last edited:

MMcLaren

Joined Feb 14, 2010
861
Okay guys, I think I've figured out the terminology for what I am trying to do. I need to preform High Side switching where the load being switched is at a higher voltage than the voltage supplied to the micro controller. Which appears to be exactly what ronv has given me. I kept asking if there was a way to eliminate the NPN transistor from the circuit because I will need to do this for at least 4 different outputs which will require 4 NPN & 4 PNP transistors. as well as multiple resistors per setup.

I would rather keep the overall number of components that will be required in the finished module as low as possible, for simplicity as well as cost purposes.

Does anyone here know of another way to pull off high side switching? OR would it be possible to apply rony's diagram to my PWM ground output to switch its polarity so that all anodes can be common? and I can go back to using NPN's to switch grounds to the individual LEDs to turn them on/off?
I had to re-read this thread a couple times. Tell me if this is what you're looking for, please?

You have to use an NPN+PNP or an NFET+PFET combination to switch the high side voltage since it's higher than your 5v output pin. That said, just use your PWM signal to drive a single NPN+PNP driver which would "source" all of the LED channel anodes. Then use a single NPN sinking driver per channel (on the cathodes). The caveat is that you would have to invert the PWM duty cycle value in your code (not a big deal).

Regards...
 
Last edited:

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
I had to re-read this thread a couple times. Tell me if this is what you're looking for, please?

You have to use an NPN+PNP or an NFET+PFET combination to switch the high side voltage since it's higher than your 5v output pin. That said, just use your PWM signal to drive a single NPN+PNP driver which would "source" all of the LED channel anodes. Then use a single NPN sinking driver per channel (on the cathodes). The caveat is that you would have to invert the PWM duty cycle value in your code (not a big deal).

Regards...


Thank you, that sounds like that will eliminate the double transistors per led and make the design simpler. Sorry it's taken me a while to explain what I'm trying to accomplish. And to the other poster yes I need to be able to enable individual LEDs all high voltage from the pic. All connected to the pwm output.
 

MMcLaren

Joined Feb 14, 2010
861
I mistakenly said you'd have to invert your duty cycle value. That's not the case since the input to the NPN/PNP pair is active high just like your PWM signal.

Good luck on your project.

Regards, Mike
 

Thread Starter

whoolieshop

Joined Jun 11, 2012
12
May I ask how many LED channels you want to drive?
Ideally 6 channels with multiple led strips per channel all pre wired for 12 volt operation. I have a module that does this already but it has some major drawbacks. The company that produces them for me doesent care to address the drawbacks. So my only option is to produce them in house.


Most of the time it will be one strip of 12 pre wired led strips per channel but it could be as many as 6 depending on the number of colors someone wanted to throw at it.


This module controls the led strips turning them on/off solid, runs several strobe patterns and now I'm developing a fade between channels.

The old module has a wireless remote which I do not intend on adding to this module as the remotes randomly lose their programming and the batteries are always dying.

The old module is also in a water resistant case, it HAS to be water proof. Currently each module has to have the case opened up and sealed before I can send it out. This works until a remote goes dead then the case has to be opened up to re program. This compromises the waterproofing that was done and makes them impossible to warranty.

The new modules won't require any opening up so they can be potted in epoxy to waterproof them.

The old modules also have some plugs that are less than desirable They have to be the cheapest six conductor plugs on the planet.

These have to be bulletproof in the end but right now getting the basic functions and pic code is the current stage.
 
Top