Go Down

Topic: Resistor values for P-Channel MOSFET + NPN Transistor Switch (Read 717 times) previous topic - next topic

jaron

Goal: Possibility to programmatically switch 3.3V peripherals (sensors, RF module) on an 3.3V Arduino on and off.
Question: What are the correct values for R1 and R2?





I've tried to figure out the values for R1 and R2 for a while now but couldn't find an example nor an understandable explanation on how to calculate their values. I'd really appreciate if someone could point me to a possible solution.

Thanks!


[Edit]


This is revision 1 of the schematic that I've modified according to the inputs given so far:
  • In the original schematics the emitter of the transistor was connected to VCC instead of GND.
  • This revision uses an NDP6020P logic level MOSFET instead of an FQP47P06.
  • There is now a 10kΩ pull-down resistor at the Arduino pin D4.
  • R1 is now 260kΩ and R2 33kΩ, which must be verified.

The circuit is part of a battery powered IOT application where a minimal power consumption and voltage drop are crucial. After some research I came to the above solution to switch all unused components off while an Atmega328P is in deep sleep.
The LED is just an example of a consumer, in reality this would be at least an HC-12 433 MHz HF module and one or more sensors which together will probably use 1 A max.
[End Edit]

raschemmel

change R1 to 1k.

Quote
I've tried to figure out the values for R1 and R2 for a while now but couldn't find an example nor an understandable explanation on how to calculate their values. I'd really appreciate if someone could point me to a possible solution.
Whatever you are trying to do it is not going to work with that circuit.
List the reason for each of the components in your circuit:

1 - 2n2222 (purpose)
2 - P-channel mosfet (purpose)
3.- led (purpose)
4- module (post vendor link and correct name for module) (purpose should be self explanatory)
5- battery (purpose self explanatory)

here's an example of how to use an npn transistor to switch a p-channel mosfet
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

6v6gt

The FQP47P06 is not even a logic level mosfet and is certainly not suitable for 3.3 volts. The RDS(on) is quoted only for -10 volts in the data sheet.

ReverseEMF

There are numerous errors in your schematic.  Try this, instead:


NOTE: Updated schematic to indicate ground attachment to supply [previously, "ground" was ambiguous].

And, that FQP47P06, has a "Gate Threshold Voltage" that will not be, consistently, low enough for it to work in this application.  I mean, since, technically, the VGS(th) can be as low as -2V, and because, in this case, you're only driving a measly LED at around 6mA, if this is a one-off, you might be able to cherry-pick a winner, but I wouldn't hold yer breath ;)

But, on to the rest of your question: How to figure out the resistors values.  I see you connected to D4, which is NOT a PWM enabled output, so that makes this trivial:

Since a MOSFET is [statically speaking] a Voltage Driven device, you can get away with a wide range of values for R2.  So, lets pick a value that will not contribute much to power supply demand [in case the Pro Mini is also being powered by a battery], like 33k. 

The PN2222 is a Current Driven device.  Thus, it's a matter of the ratio of input current, to output current.  A bipolar transistor has a parameter called hFE, which is a number that indicates the maximum expected current gain.  The hFE for a PN2222 is around 35 for the small current will be dealing with, here.

Rule of thumb, to turn a BiPolar transistor on, in a way that insures it's "really on" [i.e. is in the "saturation region"], use a current gain of "10", and since the gain, on this transistor, goes all the way up to 35, there's enough "head room" to achieve this. 

Thus, a 33k resistor on the collector, will allow a current of around 0.1mA, when the transistor is all the way on, so to satisfy the stipulation of a current gain of 10, use the following math:

IB = IC/10 = 100µA/10 = 10µA
R1 = (Voutput - VBE)/IB = (3.3V-0.7V)/10µA = 260k

BUT, if conserving energy for a battery is not an issue, then a little more drive current might be wise -- especially if that MOSFET has a lot of Gate Capacitance to deal with [a whole other subject, that is more apropos for such things as PWM].  So, lets choose, for R2, a value of 3.3k, so we have 1mA of pull up current [e.g. turn-off current].  Combining the two formulas:

R1 = (Voutput - VBE) * 10/IC = (3.3V-0.7V)*10/1mA = 26k

"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

jaron

Thanks @all, you are quick! Would a NDP6020P work for my application? The data sheets are difficult for me to interpret.

@ReverseEMF thanks, your schematic looks so much cleaner. I can't spot the differences right away and need some time to analyze it.

6v6gt

The NDP6020P seems  a much better choice.
This one also looks quite good: Si7615ADN, but the package is not very breadboard friendly. What is the maximum current you anticipate switching with this device ?


raschemmel

Quote
your schematic looks so much cleaner. I can't spot the differences right away and need some time to analyze it.
What are you talking about ?

The difference is like night and day.

They couldn't be more different if you tried.

Start by looking at where the emitter of the NPN is connected.

Is there a difference between Vcc and GND ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

jaron

@raschemmel post #1. The circuit is part of an IOT application where the power consumption is crucial. After some research I came to the above solution to switch all unused components off while the Atmega328P is in deep sleep (1 + 2). The LED was meant as an example of a consumer, in reality this would be at least an HC-12 433 MHz HF module and one or more sensors which together will probably use 1 A max (3).
I'm not a pro and every constructive input is welcome.

@ReverseEMF thanks for the addition. It'll take me some time to process your information as I'm obviously not a pro.

@6v6gt thanks, I've ordered some NDP6020P.

ReverseEMF

@raschemmel post #1. The circuit is part of an IOT application where the power consumption is crucial. After some research I came to the above solution to switch all unused components off while the Atmega328P is in deep sleep (1 + 2). The LED was meant as an example of a consumer, in reality this would be at least an HC-12 433 MHz HF module and one or more sensors which together will probably use 1 A max (3).
WhooHoo!  1 Amp (max 3)!  Much different than the 6, or so, mA implied by your LED and 220Ω resistor!!

OK, that means a more hefty MOSFET, and possible concerns regarding switching time.  Though a NDP6020P is plenty hefty -- in fact, might be overkill.  Like, we might be waltzing into the concerns about that Gate Capacitance, I mentioned before.  And, low power consumption concerns to boot!  OK, a little more complicated of a design, perhaps [or, still simple -- depends on the need for speed].  Also, just checking...what's with the P-Channel MOSFET, anyway?  Why did you feel that was necessary?  I mean, couldn't we just use an N-channel MOSFET and dispense with the PN2222?
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

jaron

@ReverseEMF it would be 1 A max. I've chosen the above solution because I assumed that it uses the least power and has the least voltage drop which is important as I use a single LiFe battery. But of course I could be wrong.

larryd



The above is a catastrophe waiting to happen.

NOOBs are often told to connect grounds so circuits can have common reference point for current flow.

At a minimum, the schematic should come with a warning.




Better still, use one of the circuits below:






No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

ReverseEMF



The above is a catastrophe waiting to happen.
In what way is this a "catastrophe waiting to happen"?
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

jaron



This is revision 1 of the schematic that I've modified according to the inputs given so far:
  • The emitter of the transistor is now connected to GND instead of VCC.
  • An NDP6020P logic level MOSFET is used instead of an FQP47P06.
  • There is now a 10kΩ pull-down resistor at the Arduino pin D4.
  • R1 is now 260kΩ and R2 33kΩ, which must be verified.

* In a real application the LED would be for example replaced by an HF module and a temperature sensor.
** The design of the circuit is debatable but low power consumption and minimal voltage drop are crucial.

raschemmel

R1 is excessively high for a simple 5V logic driven 2n2222 . In that configuration you typically see values
 between 1k and 5k. The only reason to use 260k is to limit the base current and thus the collector current.
I can't see any reason to do that. How did choose 260k ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

ReverseEMF

R1 is excessively high for a simple 5V logic driven 2n2222 . In that configuration you typically see values
 between 1k and 5k. The only reason to use 260k is to limit the base current and thus the collector current.
I can't see any reason to do that. How did choose 260k ?
260k for the "avoiding long term battery drain in a NON-PWM application" case.
26k for the "not using a battery, or PWM", case
And, didn't I explain how I chose 260k?
And, "catastrophe"? Isn't that rather dramatic?
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

Go Up