Use a 2N 3904 Transistor to switch 12v with MCU?

MisterBill2

Joined Jan 23, 2018
18,508
Thanks for all the thoughts. As many posted, you may be right, I think I have the 2N2222 reversed, so will give that a look. Thanks for that catch. Also will confirm my resistors are all connected for the 860 ohms (330, 330, 200) - I’m pretty sure I tested that series for overall resistance when building tho.

For reference, the ESP NodeMCU can put out 3.3v at around 12mA.

Will assess when home in a bit, and digest all the feedback more carefully, thanks.
To work as a switch, for the 2N2222, the collector goes to the more positive part of the circuit, which in this case is the negative side of the fan motors, since the positive side of the motors connects to +12 volts, and then the emitter connects to the zero volt side of the 12 volt supply. And the base positive bias to switch on is applied to the base, with the return of that bias tied to the emitter, at the common zero volts line.
 

Audioguru again

Joined Oct 21, 2019
6,692
One fan uses 88mA then two fans use 176mA. You want the transistor to be a saturated switch so hFE is not used, the datasheet shows that for saturation the base current must be 1/10th the collector current. You need a base current of 17.6mA that the MCU cannot do. Try it. The MCU output might be 2.8V at 17.6mA then the series base resistor is (2.8V - 0.7V)/17.6mA=120 ohms.
 

MisterBill2

Joined Jan 23, 2018
18,508
One fan uses 88mA then two fans use 176mA. You want the transistor to be a saturated switch so hFE is not used, the datasheet shows that for saturation the base current must be 1/10th the collector current. You need a base current of 17.6mA that the MCU cannot do. Try it. The MCU output might be 2.8V at 17.6mA then the series base resistor is (2.8V - 0.7V)/17.6mA=120 ohms.
Or use a transistor with more gain.
 

Audioguru again

Joined Oct 21, 2019
6,692
Or use a transistor with more gain.
Gain (beta or hFE) is used when a transistor is a linear amplifier that is never saturated, it always has a considerable Vce.
Little American 2Nxxxx transistors are saturated very well when the base current is 1/10th the collector current regardless of the gain. Little European BCxxx transistors are poorly saturated when their base current is 1/20th the collector current.

You mean use a Darlington or two compounded transistors and sufferer some voltage drop? Then you get lots of current gain.
 

MisterBill2

Joined Jan 23, 2018
18,508
I mean that using an MPSA13 transistor worked very well for driving a relay from a CMOS gate. Even at 3.3 volts it will go into saturation and that is what is needed for this application. It is switching, not regulating.
 

BobaMosfet

Joined Jul 1, 2009
2,113
This explanation is very confused. First, Vbe does not subtract from the collector voltage . Next, and more important, the transistor is being used as a switch and so it needs to be fully saturated in order to not have excessive power dissipated as heat. In this aplication the transistor is being used as a switch, not as a linear amplifier.
@MisterBill2 - Every time you open your mouth here, I'm wondering if you're on the same thread. What you're saying is absolutely a crock compared to the circuit and information I've provided to the TP. The math is inarguable. The 2N2222 _is_ being used in the linear region, not as a saturated switch. If you're confused, it's because you're not understanding what's being written.
 
Last edited:

BobaMosfet

Joined Jul 1, 2009
2,113
Why do you assume you get 3mA from GPIO pin? Many MCUs can sink, but not source, that amount of current.
@shjacks - I'm not assuming- That 860-Ohm resistor prevents the GPIO pin from outputting more than 3.06mA. If you read the thread from the beginning you'd see the math I showed the TP about how to get to that value.

and 3.06mA is 0.00306 amps. All MCUs in the world can source 3.06 thousandths of an Amp.

Per the datasheet on the TP's NodeMCU:

1583251045029.png
 

Attachments

Last edited:

Audioguru again

Joined Oct 21, 2019
6,692
I mean that using an MPSA13 transistor worked very well for driving a relay from a CMOS gate. Even at 3.3 volts it will go into saturation and that is what is needed for this application. It is switching, not regulating.
The maximum saturation voltage of an MPSA13 Darlington is 1.5V (!) when its current is only 100mA. Here, its current will be 240mA when the fans turn in then 160mA continuously.
 

ElectricSpidey

Joined Dec 2, 2017
2,779
There is no point in using a Darlington in this circuit, if you want to lose that kind of voltage you might as well run a 222 in linear mode.

The ESP can provide enough current to get a 222 into soft saturation @ 160mA, VCE probably below .7 maybe between .5 and .6.

Hard saturation is not necessary here, the transistor will still be within its wattage rating, and the voltage drop is acceptable.
 

ebeowulf17

Joined Aug 12, 2014
3,307
If you read the thread from the beginning
Hehe, that's a pipe dream!

I often get frustrated in these forums by the hordes of people who either respond to the first post without reading subsequent discussion, or respond to the most recent post, without reading the setup that led to it. Without context of the running thread, useful judgment is impossible, yet people chime in based on a single post all the time.

As you can tell by my mini-rant, this is one of my pet peeves. I try to either stay out of a thread or fully engage in it, paying attention to context as it evolves, but not everyone works the same way. I try to just ignore it - I shouldn't expect to dictate to others how they can participate here, but I'll admit it occasionally gets me riled up when people are especially ridiculous and counterproductive.

This thread is a prime example. You've clearly articulated, several times over, that your proposed circuit is deliberately designed to operate in linear region, yet several people are acting like this is an accident or miscalculation. If people disagree with your choice, they should address that more directly... but it's obvious that they're just not paying attention before commenting.
 

MisterBill2

Joined Jan 23, 2018
18,508
It is still not clear why anybody would ever choose to operate a transistor in the linear mode when a switching function is desired. An explanation of why one would avoid running a switching transistor in the switching mode, saturated, would be interesting and educational. I look forward to reading it.

And the TS has already told us that the goal is to run the fans at the highest voltage possible within their ratings. I had neglected to consider the darlington drop in Vce, sorry about that. So another type in the saturated mode is a better choice. The reason for suggesting the MPSA13 was the very low base drive requirement.
 

ebeowulf17

Joined Aug 12, 2014
3,307
It is still not clear why anybody would ever choose to operate a transistor in the linear mode when a switching function is desired. An explanation of why one would avoid running a switching transistor in the switching mode, saturated, would be interesting and educational. I look forward to reading it.

And the TS has already told us that the goal is to run the fans at the highest voltage possible within their ratings. I had neglected to consider the darlington drop in Vce, sorry about that. So another type in the saturated mode is a better choice. The reason for suggesting the MPSA13 was the very low base drive requirement.
*** EDIT: Please disregard my original message below. I misunderstood the proposed circuit's design intent.

My understanding was that they're trying to limit the starting and/or inrush current, but set the limit high enough that it doesn't really affect the run current. I may have misunderstood that, so I'll be interested to hear what @BobaMosfet says.
 
Last edited:

BobaMosfet

Joined Jul 1, 2009
2,113
It is still not clear why anybody would ever choose to operate a transistor in the linear mode when a switching function is desired. An explanation of why one would avoid running a switching transistor in the switching mode, saturated, would be interesting and educational. I look forward to reading it.

And the TS has already told us that the goal is to run the fans at the highest voltage possible within their ratings. I had neglected to consider the darlington drop in Vce, sorry about that. So another type in the saturated mode is a better choice. The reason for suggesting the MPSA13 was the very low base drive requirement.
From the first post, the TP was simply trying to get the circuit to work period, nothing about inrush current was discussed at that point.

The BJT doesn't limit the voltage (except for BE junction). it only controls current- it's a current device. As for why operate it in linear .v. saturation- In this specific example you can operate in either- it isn't going to use more current through the CE junction, just because more current is available. The CE junction will only see what the load demands. If operated in saturation, the transistor will operate cooler. My primary reason for operating in the linear region was to reduce the amount of current being drawn from the GPIO pin, as the upper-end was unknown when I created the circuit.

As a matter of good practice, one should strive always to utilize as little current from any CPU/MCU pin- only use what is absolutely necessary- because this allows you to use more pins- the processor/micro can only use so much current throughout its entire structure simultaneously. Preserving current means more current available to any pin that needs it and the CPU/MCU runs cooler overall.
 

ebeowulf17

Joined Aug 12, 2014
3,307
From the first post, the TP was simply trying to get the circuit to work period, nothing about inrush current was discussed at that point.

The BJT doesn't limit the voltage (except for BE junction). it only controls current- it's a current device. As for why operate it in linear .v. saturation- In this specific example you can operate in either- it isn't going to use more current through the CE junction, just because more current is available. The CE junction will only see what the load demands. If operated in saturation, the transistor will operate cooler. My primary reason for operating in the linear region was to reduce the amount of current being drawn from the GPIO pin, as the upper-end was unknown when I created the circuit.

As a matter of good practice, one should strive always to utilize as little current from any CPU/MCU pin- only use what is absolutely necessary- because this allows you to use more pins- the processor/micro can only use so much current throughout its entire structure simultaneously. Preserving current means more current available to any pin that needs it and the CPU/MCU runs cooler overall.
My apologies - I misunderstood your intent, and I think my comment above was counterproductive. Glad you came in to set the record straight. Cheers!
 

MisterBill2

Joined Jan 23, 2018
18,508
How much inrush current will a an BLDC motor drive fan that draws 180 mA stalled have? Not very much, I predict, probably about 180 mA. And given that the fans will not be starting very often, how big a deal will that actually be? These are not big fans with powerful motors.
 

ebeowulf17

Joined Aug 12, 2014
3,307
How much inrush current will a an BLDC motor drive fan that draws 180 mA stalled have? Not very much, I predict, probably about 180 mA. And given that the fans will not be starting very often, how big a deal will that actually be? These are not big fans with powerful motors.
Sorry, the inrush current comment was just my own misunderstanding, not Boba's description (which he already clarified several posts above this one.)
 
Top