Back to the original question........
Originally Posted by Andy1845c
I need to switch a 400mA load with a PIC. Would it be better to use a logic level MOSFET or a Darlington? Are there alot of advantages one way or the other or is it more a matter of preferance in this case?
There are a lot of advantages and disadvantages to both.
A logic level MOSFET can cost twice as much.
The MOSFET may require less math.
A transistor will generally be cheaper.
You need to do more math.
For a
logic level MOSFET, I presume that the data sheet already carefully describes the ON resistance and max current
at the proposed gate drive level. (
Don't look at threshold voltage, it tells when the device
begins to turn on, this is
not when it becomes useful.) Although a commercial circuit will need much more analysis, for one-off this might be all you need to know.
For a transistor, you need to drive current into the base. If you want the transistor to have a minimum on-voltage, you need to consider the saturated beta (gain). Darlingtons have an advantage in this area, because their overall gain (beta) is higher, but their best-case on-voltage isn't as good.
Now, you have a PIC and a 400 mA load. If you choose a transistor or darlington it needs to have an absolute max rating of a lot more than 400 mA, because their gain tends to drop off badly after about 1/4 to 1/2 their rating. Then the choice is between a darlington or transistor. In your case, you have 20 mA of drive and a 400 mA load. This calls for a saturated gain of 20. Rule of thumb is to use 10 for a saturated gain on a single transistor. So, unless you choose a super-gain transistor, you don't have enough current out of the PIC to drive it.
Again rule of thumb (you can change this if you truly understand the data sheet) is about 100 for the saturated gain of a darlington (10 * 10). In this case the PIC has plenty of juice. Give the darlington base 4 mA or more and it will well handle 400 mA.
Driving the base of the darlington: Your PIC is probably 4.5V, give or take, when it's high. The darlington base is about two diode drops (1.3V?) above ground. That means you want a resistor that conducts more than 4 mA with 3.2V across it. A common value like 680R seems to be good; it provides enough base drive without overloading the PIC.
Summary:
If you choose a MOSFET with a current rating of 400 mA or more at a gate voltage of 5V (or less), you're done - at maybe 50 cents. Your ON voltage will be defined by the MOSFET ON resistance.
If you choose a darlington (or a pair of 2N2222's) and a 680R resistor, you're done (after doing the calculations above) for about 25 cents. Your ON voltage will be about 1.2 to 1.8 volts with a good design.