I am trying to understand how to use an NPN transistor as a switch with my Arduino Uno R3. In looking at the data sheet for a transistor, it gives an Ic figure and an Ib figure (ratings) and if I do Ic/Ib i get 40. In a graph on the data sheet it says Ic/Ib=250 and this confuses me. Also it gives a current gain hFE of 1000! Is Ic/Ib not the current gain. I would like if possible for someone to explain so that I do not blow up my Arduino. I may be 60+ but I am excited at the possibilities of the Arduino and keen to get going with it.
Figures 10 and 11 are all you should be using when driving the part as a switch (saturation) as opposed to using it as an amplifier.
If you need 1 amp of current, you drive it with 1/250=4ma of base current which will result in a Vce of about 0.75 volts. Since the output voltage of an AVR processor is usually around 4.5 volts, the base resistor should be (4.5-0.7)/.004=950 ohms. A 1K is close enough for me.
SierraGolfMike:
I am trying to understand how to use an NPN transistor as a switch with my Arduino Uno R3. In looking at the data sheet for a transistor, it gives an Ic figure and an Ib figure (ratings) and if I do Ic/Ib i get 40. In a graph on the data sheet it says Ic/Ib=250 and this confuses me. Also it gives a current gain hFE of 1000! Is Ic/Ib not the current gain.
I think the initial numbers you are referring to are Maximum Ratings above which the part may be damaged.
Figure 9 "DC Current Gain" shows that the Hfe parameter depends on collector current, this is a high figure since it is a Darlington (very roughly the Hfe of the two transistors is multiplied together).
Figure 11 graphs are showing the saturation voltages across Collector Current (@ Ic/Ib =250).
Very roughly; this Ic/Ib figure looks low compared to 'Hfe=1000' because we are talking here of using the device as a switch, we want to turn the transistor 'hard on' to make the Vce(sat) as low as we can.
Hfe is commonly used as the 'gain' of a transistor, but in reality it is a bit more complicated than that.
Ah... looks like avr_fred has given you the info you need to make practical use of this.
avr_fred:
Figures 10 and 11 are all you should be using when driving the part as a switch (saturation) as opposed to using it as an amplifier.
If you need 1 amp of current, you drive it with 1/250=4ma of base current which will result in a Vce of about 0.75 volts. Since the output voltage of an AVR processor is usually around 4.5 volts, the base resistor should be (4.5-0.7)/.004=950 ohms. A 1K is close enough for me.
Thanks for that, a couple of things to clarify though:
For the NPN version, am I correct in saying that Vce would be just over 1V (figure 10 LHS)?
Is it not 5V if a pin is HIGH on Arduino?
Also, I assume it should have been (4.5-0.75)/0.005 ?
So if I was drawing 4A from a 12V supply, Ib would be 4/250 giving 16mA. Ice looks like it will be 1V (figure 10)
If I used 5V on the base, the base resistor would be (5-1)/0.016 giving 250 ohms using 4.5V it would be 218.75 ohms which isn't too far out.
If I used a 250 ohm resistor the base current could be 14mA, will that affect the current flowing from collector to emitter, i.e. my supply current?
Since it is a darlington, the Vbe is higher than 0.7 volts. Vbe must be at least 1.4 volts, datasheet shows it can be as high as 3V at 3 amps Ic. Unless you're pushing high load currents, using the 1.4 volt value yields: (4.5-1.4)/.004=825 ohms so 820R would be the closest 5% value.
Depending upon your load and your switching rate, you could try lowering the base resistor to see if Vce drops. At some point, the voltage will go no lower and that's as good as it gets which also means the power dissipated by the device is as low as you can make it as well. This would lessen or could possible eliminate the need for heat sinking.
All things considered, a using an Darlington transistor for switching is so 1960's. You'd be far better served with a modern day logic level N channel MOSFET. Orders of magnitude lower losses overall and easier to drive.
Then, moving on to your response:
So if I was drawing 4A from a 12V supply, Ib would be 4/250 giving 16mA. Ice looks like it will be 1V (figure 10)
No, you're not reading the graph correctly. Correct on the 16ma of base drive but follow the 4.0A curve down the Y direction until it intersects X at the 4ma base current point. That shows that Vce will be 1.3 volts. Figure 11 shows the same thing from the Ic perspective, the result is approximately the same.
Based on what I've stated above, Rbase should be closer to: (4.5-3)/.016 = ~100 ohms. This is pushing the limits of what I'd suck out of an AVR output pin.
At this point, see my note above about using a MOSFET. You'd be dumping ~5 watts (1.3 Vce * 4 amps) into the transistor so it is going to need a big heat sink and the voltage as seen by your load is going to be about 2 volts below supply. That's not a good situation.
Upon some review, I'm now confused. The data shown in Figure 11, Vce at 4 amps and Ic/Ib=250, does not agree with the ON characteristics in the body of the datasheet. I read Fig 11 as 1.25V but if you extrapolate the ON data, Vce is 3.0 volts.
Since it is a darlington, the Vbe is higher than 0.7 volts. Vbe must be at least 1.4 volts, datasheet shows it can be as high as 3V at 3 amps Ic. Unless you're pushing high load currents, using the 1.4 volt value yields: (4.5-1.4)/.004=825 ohms so 820R would be the closest 5% value.
Depending upon your load and your switching rate, you could try lowering the base resistor to see if Vce drops. At some point, the voltage will go no lower and that's as good as it gets which also means the power dissipated by the device is as low as you can make it as well. This would lessen or could possible eliminate the need for heat sinking.
All things considered, a using an Darlington transistor for switching is so 1960's. You'd be far better served with a modern day logic level N channel MOSFET. Orders of magnitude lower losses overall and easier to drive.
Then, moving on to your response:
No, you're not reading the graph correctly. Correct on the 16ma of base drive but follow the 4.0A curve down the Y direction until it intersects X at the 4ma base current point. That shows that Vce will be 1.3 volts. Figure 11 shows the same thing from the Ic perspective, the result is approximately the same.
Based on what I've stated above, Rbase should be closer to: (4.5-3)/.016 = ~100 ohms. This is pushing the limits of what I'd suck out of an AVR output pin.
At this point, see my note above about using a MOSFET. You'd be dumping ~5 watts (1.3 Vce * 4 amps) into the transistor so it is going to need a big heat sink and the voltage as seen by your load is going to be about 2 volts below supply. That's not a good situation.
In "Rbase should be closer to: (4.5-3)/.016 = ~100 ohms." where is the 3 coming from?
Never dealt with or looked at MOSFETs before, if it's a better option I am willing to try it but will need to learn how to use one!
avr_fred:
Upon some review, I'm now confused. The data shown in Figure 11, Vce at 4 amps and Ic/Ib=250, does not agree with the ON characteristics in the body of the datasheet. I read Fig 11 as 1.25V but if you extrapolate the ON data, Vce is 3.0 volts.
I see what you mean, in the table it says:
Collector−Emitter Saturation Voltage Symbol Min Max
(IC = 3.0 Adc, IB = 12 mAdc) VCE(sat) - 2.0 Vdc
(IC = 5.0 Adc, IB = 20 mAdc) - 4.0
In "Rbase should be closer to: (4.5-3)/.016 = ~100 ohms." where is the 3 coming from?
I transposed numbers. I meant to use 2.5 volts which is what is stated in the ON data at 3 amps Ic.
"Base-Emitter On voltage (Ic = 3.0 amps, Vce = 3V) | 2.5 vdc |"
That seemed rather high to me so I did some quick tests with several new TIP122's on hand.
16ma doesn't reach full saturation, takes closer to 20ma and Vbe was 1.8V at 4A Vce. Given the possibility for high dissipation, more base current isn't a bad thing unless you're trying switch at high speeds. So, for that exact situation, I'd use (4.5-1.8 )/.02=135 so 120R or 150R isn't unreasonable. I use 4.5 volts output voltage as worst case, that is the spec at 20ma and 25 deg C.
If you need/want help in selecting a specific device, at a minimum, we'd need to know what you want to control (LED, Motor, etc), the supply voltage and load (4 amps?).
avr_fred:
If you need/want help in selecting a specific device, at a minimum, we'd need to know what you want to control (LED, Motor, etc), the supply voltage and load (4 amps?).
I have just got my Arduino starter kit and was looking at using bigger LEDs than the ones on the kit but they require more current, one of the 10W arrays takes 1050mA, I was looking at using a 12V supply. I was hoping to find a general solution that would take unto 4 of these arrays. Turns out that I have a MOSFET in my starter kit an IRF520 although it says it is a Power Transistor! (Is that what power transistors are?). The data sheet can be found here: http://www.redrok.com/MOSFET_IRF520N_100V_9.7A_200mO_Vth4.0_TO-220.pdf
Looks like it can handle the voltage and current but not sure how to determine resistor sizes for gate etc. Any help would be much appreciated.
SierraGolfMike:
Turns out that I have a MOSFET in my starter kit an IRF520
Ok, MOSFETs are good, but they are not magic.
The important things in the MOSFET's datasheet are:
ID Continuous Drain Current (and note the VGS that it is specified at).
VDSS Drain-Source breakdown voltage.
RDS(on) tells you the resistance when the device is turned on (again, note the VGS and current that this happens at).
that will indicate if the part is worth looking at for an application
This datasheet is pretty good, just looking at RDS(on) we can see it will have a resistance of 0.2 ohm when the gate is driven at 10V and it is sinking 5.7 Amps.
The next thing to look at is how much voltage you have to put on the gate to turn it on.
There is a really misleading parameter: VGS(th) = 2.0 to 4.0 V for this part.
Practically, this information is not useful when you are wanting to use if for turning stuff on and off; it is the threshold voltage where the device only starts to turn on.
Those previous specifications have mentioned 10V for VGS to turn the part fully ON.
There is a graph: "Fig 3. Typical Transfer Characteristics" ...
...this shows that, for example, 4.5V on the gate will allow about 1 Amp through the device.
To use it for 5 Amps, it looks like it needs around 5.5V and so on.
This does mean that you could use this directly from a 5V output pin to drive, maybe, 1 Amp - but to drive higher currents you have to supply more than 5v.
So you end up with a circuit like this for example:
Diagram:
Many thanks for taking the time to explain a MOSFET. I think I understand everything reasonably well. Electronics has never been my strong point so I am not fully understanding the diagram. I get using a transistor and R3 to limit the current on the base but why the 5V Supply and R1? Also how does the operation of the transistor allow the MOSFET to operate. Apologies if I appear a bit thick but I am obviously missing something!
SierraGolfMike:
I get using a transistor and R3 to limit the current on the base but why the 5V Supply and R1?
Good question...
This is just one way to solve the problem of supplying greater than 5V to the gate of a MOSFET (so it is turned hard ON to drive a heavy current load).
The MOSFET is turned on by R1 (so VGS = 12V).
The transistor Q1 is to turn it off. Supply a voltage on the base, Q1 conducts, pulls down the MOSFET gate.
The additional +5V and R2 is a bit of a 'trick'...
When an Arduino is turned on or is RESET (like when you download new code), the outputs all get reset and turned back into high-impedance inputs. There is no drive to R3 so Q1 turns off and you get a bit of a surprise when your MOSFET turns ON all of a sudden.
R2 pulls up the pin so Q1 stays ON and the MOSFET OFF until the Arduino is up and running.
The circuit overall still has the possible disadvantage that if you left on the 12V power and turned off the 5V power, the MOSFET would turn on (thru R1).
SierraGolfMike:
Almost got it! Just one question though, will the 5V not keep Q1 on permanently?
No, because the Arduino pin can be driven LOW so it pulls down the bottom of the 10k (R2) and provides no voltage into R3
OK two questions, how do you determine the resistor sizes?
*Reminds me of Monty Python: * "Our chief weapon is Surprise. Surprise and Fear... our two weapons are Fear and Surprise, ... and ruthless efficiency..." Amongst my answers are such diverse elements as:
Resistor sizes...
Starting from the MOSFET: The input to a MOSFET needs very little current (the limiting factor is actually input capacitance, but that's going a bit far for now), and could probably be turned on with 500k ohm - but you usually try and avoid high resistances because the circuit is then more susceptible to interference. So I went for 'about 1mA' and 10k is a common 'round number'.
The transistor Q1 has to sink that 1mA thru R1 to turn off the MOSFET, so a base current of 1mA will easily do that. with about 5v a 1k resistor will provide a little under 1mA base current.
The transistor must also be turned on by the combination of R2 and R3 from 5V (while the pin is an input), but R2 doesn't want to be too small because the pin has to pull it down. The value is not critical; 1k seems a bit small, could easily have been 4k7, I just made it 10k. (current into Q1 base is then around 0.4mA).
Often you end up just picking a common value and in any one circuit it makes sense to (within reason) use as few different values as possible. (to save on manufacturing and stocking costs for example)
Thanks Tony, much appreciated. I now have enough information to start playing with circuits requiring more voltage and current than the Arduino can give. Looking forward to trying a few things.
Best Regards
Steve
Thanks for reminding me of the Monty Python sketch!
It is not my intent to hijack Tony's tutorial on driving mosfets with high voltage gate requirements but I'd really like to point out it's all an unnecessary excerise when using the appropriate device with an Arduino.
As mentioned in my earlier post, using a logic level mosfet is a simple solution for driving higher currents and voltages especially when you can do low side switching (controlling the connection to the zero voltage point in the circuit).
Consider the simplicity of this circuit:
The gate series resistor is selected to limit the maximum output current from the Arduino pin. The 10k resistor is there to insure the mosfet stays off in case the output pin becomes high impedance, as is the situation at power up where all pins are initialized as high impedance inputs.
avr_fred:
It is not my intent to hijack Tony's tutorial on driving mosfets with high voltage gate requirements but I'd really like to point out it's all an unnecessary excerise when using the appropriate device with an Arduino.
No problem.
I just wanted to make it clear that you have to be very aware of VGS requirements, especially since SierraGolfMike said: "Turns out that I have a MOSFET in my starter kit an IRF520"
which might be a problem if you wanted to sink more than an amp or 2.
There has been great debate as to the need for the 150R gate resistor.
I'll bet. Only looked at the first 3 pages, not a mention of Miller or gate charge.
I'd agree with 150R for most stuff, fast enough, alleviates ringing if the track's long etc. etc.
Do you have any 'go-to' MOSFETS you would recommend for Arduino users of your circuit (switching several amps) ?