N-CH and P-CH Complementary MOSFET switch

Thread Starter

bobinbd

Joined May 28, 2016
23
I am not really sure how to describe the issue. Attached is my circuit diagram. Essentially, I have two MOSFET's, one P channel and one N channel that are switched by the output of NAND gate. The N channel mosfet is turned on with +5V logic 1 gate voltage and the P channel is turned on with a logic 0.
Both mosfets are connected to a three wire, common cathode Red/Green LED. With a logic 1, the Green LED is on (powered through the N channel mosfet) and with a logic 0 the P channel mosfet switches on and the N channel mosfet switches off.

This seems to work, but both mosfets are configured as high side and I can see where the N channel mosfet shouldn't work very well because Vgs won't be appropriate. The currents are very small (Maybe 15ma for the N channel Mosfet). On the breadboard this seems to work. But I think maybe I am just lucky!
I think the N channel mosfet should be configured low side to the LED load, except I can't see how I might configure one Mosfet high side and one low side while still powering the three wire common cathode LED.

I do have both common cathode and common anode LED's, as well as a two wire Red/Green LEDs that requires the current flow to be reversed for one or the other colour to work.

So I am game to any configuration that will switch a single LED from Green to Red based on a changing logic signal. It seems like a very simple thing!

And I am very curious to know if there is a way to connect a common cathode/anode LED to two different MOSFETs in both a high side and low side configuration. I don't think it can be done. But I also don't think I know enough to know that.
 

Attachments

Thread Starter

bobinbd

Joined May 28, 2016
23
Maybe you're thinking about something like this?

Gotta duck out now. Thunderstorms threaten my connection.:(
The difficulty is, the Red/Green LED is one led with a common cathode. the Green is powered by one Mosfet and the Red by the other. But they share the common Cathode!
 

ronv

Joined Nov 12, 2008
3,770
I am not really sure how to describe the issue. Attached is my circuit diagram. Essentially, I have two MOSFET's, one P channel and one N channel that are switched by the output of NAND gate. The N channel mosfet is turned on with +5V logic 1 gate voltage and the P channel is turned on with a logic 0.
Both mosfets are connected to a three wire, common cathode Red/Green LED. With a logic 1, the Green LED is on (powered through the N channel mosfet) and with a logic 0 the P channel mosfet switches on and the N channel mosfet switches off.

This seems to work, but both mosfets are configured as high side and I can see where the N channel mosfet shouldn't work very well because Vgs won't be appropriate. The currents are very small (Maybe 15ma for the N channel Mosfet). On the breadboard this seems to work. But I think maybe I am just lucky!
I think the N channel mosfet should be configured low side to the LED load, except I can't see how I might configure one Mosfet high side and one low side while still powering the three wire common cathode LED.

I do have both common cathode and common anode LED's, as well as a two wire Red/Green LEDs that requires the current flow to be reversed for one or the other colour to work.

So I am game to any configuration that will switch a single LED from Green to Red based on a changing logic signal. It seems like a very simple thing!

And I am very curious to know if there is a way to connect a common cathode/anode LED to two different MOSFETs in both a high side and low side configuration. I don't think it can be done. But I also don't think I know enough to know that.
You could always use a BJT transistor in place of the 2N7002 then you would only loose .7 volts or so instead of the 2 volts with the FET.
 

#12

Joined Nov 30, 2010
18,224
The difficulty is, the Red/Green LED is one led with a common cathode.
That does seem to explain the strange configuration.:(
You could do what I call a double invert.
Yousa no like the original? Add a transistor or two. It was only done that way to keep it cheap.
Doesn't that happen kinda often in your area? ;)
So what do you do, disconnect everything?
Florida: Lightening Capital of America:(
My UPS battery peed so I just shut off the computer until I expect the lights won't flicker any time soon.:D
 

Attachments

Thread Starter

bobinbd

Joined May 28, 2016
23

I think that might be the answer! I am going to breadboard this but it probably makes more sense to use a transistor for one logic signal and then the mosfet to respond with the other signal.

I have a configuration using two transistors (not mosfets but otherwise the same) an NPN and PNP and this works, but since they both share the base, I think it is possible that some of the current bleeds from the PNP transistor to the NPN when it is conducting but I don't see any way at all for that sort of thing to happen here.

And I would suggest that if I were to use my common anode LED's, then I would use a PNP transistor (2N3906) and then an N-channel Mosfet with the LED connected to Vdd rather than ground. In case I run out of the others.

This looks awesome! Elegant and simple.

And one day I will figure out how to use LTSpice (just downloaded it yesterday).
 

#12

Joined Nov 30, 2010
18,224
ronv showed a definite improvement in how to do this. The double invert method is the ultimate in voltage delivery, but requires a lot more parts (not elegant).
since they both share the base, I think it is possible that some of the current bleeds from the PNP transistor to the NPN
The reverse breakdown voltage of a transistor P-N junction is usually more than 5 volts. There is no leakage in such a low voltage circuit, but it would not work correctly with, for instance, a 10 volt power supply.
 

ronv

Joined Nov 12, 2008
3,770
I think that might be the answer! I am going to breadboard this but it probably makes more sense to use a transistor for one logic signal and then the mosfet to respond with the other signal.

I have a configuration using two transistors (not mosfets but otherwise the same) an NPN and PNP and this works, but since they both share the base, I think it is possible that some of the current bleeds from the PNP transistor to the NPN when it is conducting but I don't see any way at all for that sort of thing to happen here.

And I would suggest that if I were to use my common anode LED's, then I would use a PNP transistor (2N3906) and then an N-channel Mosfet with the LED connected to Vdd rather than ground. In case I run out of the others.

This looks awesome! Elegant and simple.

And one day I will figure out how to use LTSpice (just downloaded it yesterday).
If you were to use a pnp in place of the other fet you need to add some base resistance or it will kind of short out your logic gate without it.
 

Thread Starter

bobinbd

Joined May 28, 2016
23
If you were to use a pnp in place of the other fet you need to add some base resistance or it will kind of short out your logic gate without it.
I did breadboard your circuit and it worked perfectly, as far as I can tell! (I added a 22k resistor on the base of the transistor, but the gate of the mosfet was tied directly to the logic gate output).

Attached is a piece of my original (and I have 5 or 6 of these in operation) that used an NPN transistor and a PNP transistor. My concern was when the base voltage was a logic LOW or 0 or 0Volts, when the 2N3906 was turned on the current flowing through the base could actually leak into the 2N3904 and then turn this transistor on (as well as sink to the logic gate of the CD4011 I am using.

I didn't know how to avoid this leakage current flowing back to the other transistor. I thought complementary MOSFETs would work, but your idea of one transistor and one MOSFET solves that issue and also the issue of having an N channel mosfet as a high side switch that would cause it's own issues.

As an extra, I also breadboarded the setup using a PNP Transistor (2N3906) and an N Channel Mosfet (2N7000) with a common Anode LED (so the Mosfet was a low side switch) and that worked just as well.

So many thanks from me for your help.
 

Attachments

ronv

Joined Nov 12, 2008
3,770
I did breadboard your circuit and it worked perfectly, as far as I can tell! (I added a 22k resistor on the base of the transistor, but the gate of the mosfet was tied directly to the logic gate output).

Attached is a piece of my original (and I have 5 or 6 of these in operation) that used an NPN transistor and a PNP transistor. My concern was when the base voltage was a logic LOW or 0 or 0Volts, when the 2N3906 was turned on the current flowing through the base could actually leak into the 2N3904 and then turn this transistor on (as well as sink to the logic gate of the CD4011 I am using.

I didn't know how to avoid this leakage current flowing back to the other transistor. I thought complementary MOSFETs would work, but your idea of one transistor and one MOSFET solves that issue and also the issue of having an N channel mosfet as a high side switch that would cause it's own issues.

As an extra, I also breadboarded the setup using a PNP Transistor (2N3906) and an N Channel Mosfet (2N7000) with a common Anode LED (so the Mosfet was a low side switch) and that worked just as well.

So many thanks from me for your help.
I can see how that would happen if the logic gate was not connected. But with the logic gate the voltages on the gate side of the resistors should be 0 or 5 volts depending on the logic state.
 

Thread Starter

bobinbd

Joined May 28, 2016
23
I can see how that would happen if the logic gate was not connected. But with the logic gate the voltages on the gate side of the resistors should be 0 or 5 volts depending on the logic state.
To conclude, I have a link to a short video I have creating showing the circuit in action on the model train layout.
The red/green led is still attached to the circuit board under the layout and will eventually be moved to a display panel where the red/green light will show the tunnel as being clear or occupied.

https://www.dropbox.com/s/63gkleywnpg5nnz/TunnelLights.mp4?dl=0

As another note, I have just discovered that a P-CH MOSFET can be used very well as reverse voltage protection without suffering the .7v drop/loss with a diode or .4v drop with a Schottky diode.
 
Top