2n3904 DC current gain confusion

dl324

Joined Mar 30, 2015
9,083
Some beta data for 2N3904.

upload_2017-12-29_18-51-34.png

Beta for a typical transistor in the 1-10mA range is a minimum of 70-100, with a maximum of 300.

If you had a transistor that gave a beta of 100 at 4mA, the base current would be 40uA; so collector current would be 3.96mA. A 1% error. Is that close enough?
 

WBahn

Joined Mar 31, 2012
24,848
Hello all. I am trying to setup a constant current source using a 2n3904 and a Motorolla LM358N. I want to ensure 4mA collector current regardless of my load. Here is a screen shot of the circuit, an explanation of my rationale, and the problem I am having.


My Rationale
Using the datasheet, to the best of my ability, it looks like my DC current gain would be 70. By that logic my base current, 3.68V/23k = 160µA, multiplied by 70 should give me a collector current of 11.7mA (NOTE: The LM356N does not go rail-to-rail so the output is 3.68V). When the voltage across my sense resistor exceeds 4V, 4mA total current, the LM356N will output low unbiasing the 2n3904. I know I may have to implement some hysteresis into this circuit.

My Problems

1. I am pretty sure I'm interrupting the datasheet incorrectly. Could someone explain this section to me?
How I see it if I'm fully on, what would my collector current be? Well in this case it would be 5v/1k which is 5mA.
With that information I assumed I would reference the 3rd entry for the behavior I could expect. Also, Vce is listed as 1V here.
How does this factor in?


2. As it stands right now, I get 2.8mA of total current through my sense resistor. What exactly am I screwing up here?

3. Lastly, I've heard it is poor practice to use an op-amp as a comparator without some sort of hysteresis. How can I implement this here?

Thank you all so much for any input. Hopefully, I was clear in my explanation.
You are doing several things incorrectly.

First -- and possibly foremost -- you are operating on the basis that the DC current gain shown in the data sheet is a hard, fixed, reliable value. It isn't. In fact, look at the top of the column you are getting that value of 70 from and you will see that it says "min". That means that, under the conditions stated -- namely a collector current of 1 mA and a Vce of 1 V, that the DC current gain will not be less than 70. If you look more closely at the datasheet you will likely find that further conditions are stated for all of the measurements such as a specific temperature (that might be given in "Note 2" or maybe elsewhere). To see how rough this spec is, look a the next line for a collector current of 10 mA and you will see that while the minimum current gain is 100, the typical current gain is three times that. What it will be for a specific transistor will be all over the map and even transistors from the same lot can vary quite a bit. So you never rely on the current gain of your transistor being a specific value -- the most you do it rely on it being at least some value.

Second, you are misapplying Ohm's Law. Even assuming you were correct and that the output of the opamp was 3.68 V, that is the voltage, relative to the 0 V reference point, of the left end of the base resistor. Ohm's Law relates the value of a resistor to the voltage ACROSS that resistor and the current THROUGH that resistor. So you need to subtract the voltage at the base of the transistor from the 3.68 V (again, assuming that this is the actual voltage) to get the voltage ACROSS the base transistor.

Third, assuming you managed to get 3.94 V at the emitter, the voltage at the collector would need to be at least about 4.2 V to keep it from saturating, which means the most you could get across the load resistor would be about 0.8 V and so the largest value it could be would be about 200 Ω. You don't mention what the range of load resistances are that you want to maintain 4 mA through, so I'll pick 1 kΩ as the max.

It pretty much goes downhill from there. Where did you get this circuit from, any way? The circuit itself is reasonable, but it's pretty evident that you did not design it because you seem to have any idea of how it works to achieve the goal you stated.

So let's look at a more reasonable way to analyze this circuit.

The voltage at the non-inverting input of the opamp is set by the leftmost voltage divider, which appears to use a 220 Ω and an 820 Ω resistor (it's a bit fuzzy, so I'm guessing a bit). So that voltage would be 3.94 V. Assuming that this is even within the input common-mode voltage range of that opamp (and I'm far from certain it is if the saturation output voltage is as far from the rail as you say it is) then the opamp will try to adjust it's output voltage so that the inverting input is also at 3.94 V (or very close to it). That voltage, in turn, is the voltage at the top of the 1 kΩ current sense resistor, so if the circuit is working that voltage will be 3.94 V and 3.94 mA of current will be flowing through it (the voltage ACROSS this resistor is 3.94 V because the voltage at the other end of the resistor is 0 V). However, since the current in the resistor is coming out of the emitter of the transistor, the base voltage must be about 0.6 V to 0.7 V more than this, or about 4.5 V to 4.6 V. But you've already indicated that the opamp can't output this much voltage.

So let's see if we can patch it. With the 1 kΩ load resistor I chose, the voltage at the collector would be 1 V. Let's set a minimum collector-emitter voltage of 0.5 V to keep the transistor out of hard saturation, which gives us a target for the emitter voltage of about 0.5 V, meaning that the current sense resistor would need to be less than 125 Ω. Let's make it 100 Ω for convenience. That means that the emitter voltage will be about 400 mV and the base voltage will be about 1 V. We don't need the base resistor, but if we do keep it, then we want to allow for a lower current gain since we don't always have Vce of at least 1 V. So let's use a gain of 50, meaning that the base current could be as high as 80 μA. Let's call it 100 μA to give us some margin. If the max opamp output is the 3.68 V you say, then the voltage across the base resistor can't get above about 2.68 V. Let's call it 2.5 V for some more margin. That means that the base resistor can be more than 2.5 V / 100 μA, or 25 kΩ. So 22 kΩ should work fine.

All that is left is to pick our voltage divider resistors to get 0.4 V at the non-inverting input. That means we want the ratio to be 11.5. So let's see what might expect using 12.0 kΩ and 1.0 kΩ. That would give a reference voltage of 385 mV, which would result in an emitter current of 3.85 mA. But if we changed the sense resistor to 910 Ω, that would increase to 4.23 mA. Taking into account a base current of somewhere around 1%, that means the current in the load resistor would be about 4.2 mA. If that isn't close enough, then you probably need to include a potentiometer to calibrate the circuit and you may need to use a better reference than just the 5 V supply voltage.
 

Thread Starter

odm4286

Joined Sep 20, 2009
241
Some beta data for 2N3904.

View attachment 142714

Beta for a typical transistor in the 1-10mA range is a minimum of 70-100, with a maximum of 300.

If you had a transistor that gave a beta of 100 at 4mA, the base current would be 40uA; so collector current would be 3.96mA. A 1% error. Is that close enough?
That will be fine for what I am doing. Do you have any links to a decent tutorial to help me understand DC current gain? The math seems incredibly straight forward, beta = Ic/Ib, but the application is tricky for me. Do I determine the base current only after I have determined the collector current?

Aside from experimentation, how can I calculate my base emitter current to ultimately get a rough idea of my collector current?
 

Audioguru

Joined Dec 20, 2007
11,251
The base current cannot be easily calculated in your new circuit without a series base resistor. If you use a transistor with high hFE then the base current is very low. I think you are using a general purpose 2N3904 that does not have a very high hFE, it is from 80 to 250 or typically 230.

With your ref at +2.5V then the sense resistor will also have about 2.5V across it which creates an emitter current in the transistor of about 2.5V/619 ohms= 4.04mA. The base current will typically be 4.04mA/230= 17.7uA and the collector current will typically be 4.02mA. The base voltage will be about +3.2V.
 

Attachments

Thread Starter

odm4286

Joined Sep 20, 2009
241
You are doing several things incorrectly.


It pretty much goes downhill from there. Where did you get this circuit from, any way? The circuit itself is reasonable, but it's pretty evident that you did not design it because you seem to have any idea of how it works to achieve the goal you stated.
Thanks for the reply, I did design it and I am learning. I've always stayed away from the analog side of things and favored microprocessors, PIC especially. I wanted to start to learn.
 

WBahn

Joined Mar 31, 2012
24,848
@ odm4286:

1) What is the range of load resistances that you want this circuit to maintain 4 mA in?

2) What is the accuracy that you need for this 4 mA?

3) What is the tolerance of your supply voltage?
 

Thread Starter

odm4286

Joined Sep 20, 2009
241
The base current cannot be easily calculated in your new circuit without a series base resistor. If you use a transistor with high hFE then the base current is very low. I think you are using a general purpose 2N3904 that does not have a very high hFE, it is from 80 to 250 or typically 230.

With your ref at +2.5V then the sense resistor will also have about 2.5V across it which creates an emitter current in the transistor of about 2.5V/619 ohms= 4.04mA. The base current will typically be 4.04mA/230= 17.7uA and the collector current will typically be 4.02mA. The base voltage will be about +3.2V.
It seems that these calculations rely heavily on "assumption" due to the nature of the 2N3904. For example, given the table on the 2N3904 datasheet, am I wrong for expecting a beta anywhere from 100 to 300? I understand my Vce is not 1V in this case.

https://www.onsemi.com/pub/Collateral/2N3903-D.PDF Page 2
 

dl324

Joined Mar 30, 2015
9,083
I did design it and I am learning.
You need to read the datasheet and operate the opamp within it's specified parameters.

Maximum input voltage is Vcc-1.7V, so you need to design your voltage divider to stay below that voltage. Maximum output voltage is VCC-1.7V, so you need to make Rsense small. The smaller you make it, the more headroom you leave for your load.

If you don't do this, you're going to saturate the transistor and beta will drop to some low value (10 is what we use to be conservative). Once the transistor saturates, further increases in base current will not result in the collector current increasing.
 

Audioguru

Joined Dec 20, 2007
11,251
You do not know the beta of the transistor and you do not need to know the base current. The collector current is almost the same as the emitter current.

The opamp causes the emitter voltage to be the same as the reference voltage and the collector current is almost the same as the emitter current.
 

dl324

Joined Mar 30, 2015
9,083
am I wrong for expecting a beta anywhere from 100 to 300?
At Ic=10mA, Vce=1.0V, and temperature=25C.

You're guaranteed 100, not 300. To get 300, you need to cherry pick your transistor.

The DC gain graph I posted above shows how beta changes with collector current and temperature, but it doesn't indicate how it varies with Vce.

If you examine the graph, you'll see that at a current of 10mA, the normalized beta is 100. At 1mA, it's 0.7. That's how they came up with 70 in the data below:
upload_2017-12-29_19-23-46.png
 
Last edited:

WBahn

Joined Mar 31, 2012
24,848
It seems that these calculations rely heavily on "assumption" due to the nature of the 2N3904. For example, given the table on the 2N3904 datasheet, am I wrong for expecting a beta anywhere from 100 to 300? I understand my Vce is not 1V in this case.

https://www.onsemi.com/pub/Collateral/2N3903-D.PDF Page 2
A good way to think of the datasheet values for hFE is to use them to determine how much base current your circuit needs to be able to supply, at a minimum, so that you don't starve the transistor's base current needs.

Do NOT use it to determine what the base current is for a particular collector current or the other way around. You simply don't know what the gain actually is under any specific situation for that approach to give you any kind of reliable outcome.

You want to design your circuit so that the beta can vary over at least an order of magnitude, say from 40 to 400 for a 2n3904, and your circuit will behave acceptably anywhere within that range.
 

Thread Starter

odm4286

Joined Sep 20, 2009
241
@ odm4286:

1) What is the range of load resistances that you want this circuit to maintain 4 mA in?

2) What is the accuracy that you need for this 4 mA?

3) What is the tolerance of your supply voltage?
1. Anywhere from 0 to 500ohms

2. Within 1% would be nice, not too concerned with this at the moment.

3. At the moment I'm using 1 percent resistors and a regulated supply, so I don't see the reference voltage varying much.

Lastly, this is just an experiment to help me learn. I've used a current source with µCs a few times before and I wanted to see if I could make my own this time. At some point i'd like to implement a selector switch that switches Rsense to different values for different collector currents.

I just want to be clear on one thing, I still don't quite understand the concept of DC current gain fully but it seems Ie ≈ Ic in this circuit. Correct?

 
Last edited:

WBahn

Joined Mar 31, 2012
24,848
1. Anywhere from 0 to 500ohms
So part of your design is going to have to allow the collector voltage to go down as far as 3 V. If you want to keep the transistor well out of saturation, the keeping Vce above 1 V is a good idea, since you had data sheet values for minimum hFE at that collector-emitter voltage.

2. Within 1% would be nice, not too concerned with this at the moment.

3. At the moment I'm using 1 percent resistors and a regulated supply, so I don't see the reference voltage varying much.
Not gonna happen with 1% tolerance components. A good rule of thumb is that your component tolerances need to be about an order of magnitude better than your target, so you would need 0.1% tolerance components. But if you were shooting for that level you probably need to start doing a proper propagation of errors.

Plus, to get that level of accuracy, you are going to want to sense the current in the load resistor (or something that is truly in series with it). The base current in the BJT is going to be a good fraction of 1% plus it will vary as the gain varies. Using a FET transistor will eliminate the base current consideration, but there are ways to do it with BJTs, too.

Also, even with a nice, regulated supply, it is unlikely regulated to within 1%. That really is pretty tight.

Since this is a learning experience, I'd shoot for 5%. That is probably doable fairly easily with this circuit and 1% tolerance components.

I just want to be clear on one thing, I still don't quite understand the concept of DC current gain fully but it seems Ie ≈ Ic in this circuit. Correct?
There really isn't that much to understand.

KCL requires that Ie = Ic + Ib

By definition, Ic = β·Ib

Thus

Ie = Ic + Ic/β

Ie = Ic · (1 + 1/β) = Ic · (β + 1)/β

Ic = β/(β + 1) · Ie

For a typical small-signal transistor in the active region, β is somewhere between about 50 and 500, with either 100 or 200 the "typical" values used to basic design purposes. To

Again by definition, α = β/(β + 1), so

Ic = α·Ie

But there is nothing that says that β is a constant. For simple circuits operating in the active region, we treat it like it is and, for well-designed circuits, this is good enough even if β actually varies over a pretty wide range. So α is generally somewhere between 98% and 99.8% with either 99% or 99.5% being the "typical" values.

The boundary between the active region and the saturation region is not well-defined. It is a continuous change in behavior and so we have to defined the transition point arbitrarily. For historical reasons that date back decades, device manufacturers typically measure the "saturated" parameters at the point where the DC current gain has dropped to β = 10 or α = 90%. Many people have taken this to mean that the gain is still 10 in saturation. This is not the case. The gain will continue to drop as the device becomes more and more saturated and will eventually reach the point where the base current is larger than the collector current. In the extreme case in which the collector is open-circuit, the base current and emitter current are the same and α = β = 0.
 

Thread Starter

odm4286

Joined Sep 20, 2009
241
So part of your design is going to have to allow the collector voltage to go down as far as 3 V. If you want to keep the transistor well out of saturation, the keeping Vce above 1 V is a good idea, since you had data sheet values for minimum hFE at that collector-emitter voltage.
Thanks a lot for the detailed reply. This will be my last post in this thread but I just want to check in with you one last time to make sure I've wrapped my head around this finally. Here is a table of the predicted values for Ib. Using the values I found on this datasheet : https://www.sparkfun.com/datasheets/Components/2N3904.pdf

I think I understand now. Beta is not a definite parameter, especially in the way that I am using this transistor. The best you can do is calculate a "window" for Ib and design accordingly.

 

WBahn

Joined Mar 31, 2012
24,848
I think I understand now. Beta is not a definite parameter, especially in the way that I am using this transistor. The best you can do is calculate a "window" for Ib and design accordingly.
You've got it. There are exceptions to every rule, but that rule will serve you well for most purposes.
 

dl324

Joined Mar 30, 2015
9,083
I think I understand now.
Close, but not quite.

While it's true that Ic = βIb, you're setting Ie and Ie = (β+1)Ib.

So for Ie = 4mA, Ib = 4mA/(80+1) = 49.4μA;

How did you arrive at a minimum β of 80? From the graph, I'd take it to be closer to 95.

At any rate, knowing the base and emitter currents, you can calculate the percentage error in Ic:
Ib/Ie*100. For Ie = 4mA, that gives 49.4uA/4mA*100 = 1.2% (using your numbers) or 1.0% using mine.

EDIT: Add error calculations:
upload_2017-12-30_11-48-24.png
 
Last edited:

Thread Starter

odm4286

Joined Sep 20, 2009
241
Close, but not quite.

While it's true that Ic = βIb, you're setting Ie and Ie = (β+1)Ib.

So for Ie = 4mA, Ib = 4mA/(80+1) = 49.4μA;

How did you arrive at a minimum β of 80? From the graph, I'd take it to be closer to 95.

At any rate, knowing the base and emitter currents, you can calculate the percentage error in Ic:
Ib/Ie*100. For Ie = 4mA, that gives 49.4uA/4mA*100 = 1.2% (using your numbers) or 1.0% using mine.

EDIT: Add error calculations:
View attachment 142743
Here is the latest. Thank you all for the help.

 

dl324

Joined Mar 30, 2015
9,083
Here is the latest.
When you get down to the 10's of mV range on the input, you need to consider the input offset voltage spec. Don't know if you're using LM358 or LM358A. For the former, Vos is 7mV max, 2mV typical. 7mV would give you an additional error of approximately 15%.

EDIT: For the lowest Vref.
 
Last edited:
Top