25
\$\begingroup\$

I'm trying to use an Arduino to enable/disable a 12V solenoid. I used an H-bridge and got that working fine. Then, I decided to simplify things and get a single mosfet instead of a multi-channel H-bridge and have gotten myself very confused. I'm trying to understand the proper way to use a P-channel (or N-channel) mosfet in this setting, and came across this sample circuit on google:

sample circuit

Why is there another transistor involved (the 2N3904), and why is there a diode across the load?

I understand that a P-channel is activated when \$V_{gate}\$ is brought high (above \$V_{source}\$ + \$V_{drain}\$), hence the pull-up, but why the extra transistor? Shouldn't the MCU (in this case the PIC) be doing the same thing?

Also - in the scenario when all I'm doing is turning a load on or off (like my solenoid), is there a reason to use an N-channel vs a P-channel?

\$\endgroup\$
  • \$\begingroup\$ I'm new to this - what is the software you are using to generate these pictures? \$\endgroup\$ – Andrew Mao Nov 10 '14 at 21:44
  • \$\begingroup\$ was just googling mosfets \$\endgroup\$ – kolosy Nov 10 '14 at 22:45
  • \$\begingroup\$ Software used is most probably Proteus. \$\endgroup\$ – Rrz0 Mar 15 '18 at 17:19
29
\$\begingroup\$

Compare the actions of a P and N channel MOSFET in your circuit.

(I've left the junction transistor in to aid comparison.)

enter image description here

The PIC output does not like being connected to 12V so the transistor acts as a buffer or level switch. Any output from the PIC greater than 0.6V (ish) will turn the transistor ON.

P CHANNEL MOSFET. (Load connected between Drain and Ground)

When the PIC output is LOW, the transistor is OFF and the gate of the P MOSFET is HIGH (12V). This means the P MOSFET is OFF.

When the output of the PIC is HIGH, the transistor is turned ON and pulls the gate of the MOSFET LOW. This turns the MOSFET ON and current will flow through the load.

N CHANNEL MOSFET. (Load connected between Drain and +12V)

When the PIC output is LOW, the transistor is OFF and the gate of the P MOSFET is HIGH (12V). This means the N MOSFET is ON and current will flow through the load.

When the output of the PIC is HIGH, the transistor is turned ON and pulls the gate of the MOSFET LOW. This turns the MOSFET OFF.

The 'improved' MOSFET circuit.

We could eliminate the transistor by using a digital N MOSFET type - it only needs the 0-5V signal from the PIC output to operate and isolates the PIC output pin from the 12V supply.

enter image description here

When the PIC output is HIGH the MOSFET is turned ON, when it is LOW the MOSFET is turned OFF. This is exactly the same as the original P MOSFET circuit. The series resistor has been made smaller to aid the turn ON, turn OFF times by charging or discharging the gate capacitance more quickly.

The choice of device is basically down to your design needs although in this case the digital type N MOSFET wins hands down in terms of simplicity.

\$\endgroup\$
  • \$\begingroup\$ In the 'improved' circuit, shouldn't there be a resistor between the gate and the ground to make sure the FET goes low again after the microcontroller brings the voltage back to 0? \$\endgroup\$ – captcha Sep 2 '14 at 22:49
  • 1
    \$\begingroup\$ @captcha The output pin of the pic effectively grounds the gate through the 100R resistor and turns the MOSFET off. Adding an extra resistor would have no effect. \$\endgroup\$ – JIm Dearden Sep 3 '14 at 9:53
  • \$\begingroup\$ Wow, this is great news as I have always been including this resistor with my mcu designs. When space is at a premium every bit helps. Thanks! \$\endgroup\$ – captcha Sep 3 '14 at 22:08
  • \$\begingroup\$ P channel fets have higher ON resistance due to the lower hole mobility \$\endgroup\$ – Autistic Mar 19 '15 at 2:35
  • 1
    \$\begingroup\$ @diegoreymendez No. The gate-source is effectively a 'capacitor' so a small series resistor (in this case 100 Ohm) limits the initial charging/discharging current from/to the pic output. It also prevents any possible oscillation due to inductance in pcb track/connecting wire. Ignoring the I/O resistance (which would increase the resistor value) the peak current is a simple Ohm's law calculation. 5/100 = 50mA. After 5 time constants this is virtually zero. If the input capacitance is 2000pF, time constant = (CR) = 0.2uS. Like most design calculations its a simplification and a compromise. \$\endgroup\$ – JIm Dearden May 7 '17 at 10:44
5
\$\begingroup\$

The bipolar transistor is present as a driver for the MOSFET. Although to DC, MOSFETS have a very high resistance and so look like open circuits, they actually capacitive. In order to turn on, charge has to be transferred into them, and doing that fast requires current driving.

The BJT (and the overall circuit design) also brings in the following advantage: a small and predictable turn on voltage. You can substitute different BJT's in there, and the behavior will be similar.

One more advantage of the extra transistor is that the extra transistor stage has voltage gain, which helps create a sharper transition from off to on, from the perspective of the input looking in.

To use a small, positive signal to turn on the circuit, an NPN transistor has to be used. But the output of this is inverted, with a high-side load, and so a P-channel MOSFET is used. This has another nice feature, which is that the load is controlled from the positive side, and so remains grounded when the transistor is shut off.

The schematic symbol for the MOSFET looks like a depletion device (since the channel is drawn solid, rather than as three sections). This is probably just a mistake. The circuit looks like a run-of-the mill enhancement mode setup.

The P-channel MOSFET activates when the gate is brought low. It is drawn "upside down". Think of it as analogous to a PNP BJT.

The "flywheel" diode completes the circuit for the inductive load when the transistor/switch opens. An inductor tries to keep the same current flowing in the same direction. Normally, that current flows through the transistor loop. When that is abruptly cut off, it flows through the diode loop, such that its direction through the load is the same, and that means flowing the opposite way through the diode. For this continuation of current to happen, the inductor has to generate "back EMF": a voltage whose direction is opposite to the one that was previously applied to it.

\$\endgroup\$
2
\$\begingroup\$

You should add a 4k7 from gate to ground to avoid your FET to be conducting when your io-pin is high-impedant or not connected. In this case a simple charge from your hand can activate the mosfet and there is a chance that it continous to drive your circuit even when there is no power on the gate pin.

\$\endgroup\$
  • 2
    \$\begingroup\$ When you say "you", whom are you referring to: Kolosy (O.P.) or Jim? Notice that the schematic in the O.P. has a P-channel MOSFET (an opposed to N-channel) and a 10k pull-up at the gate. That pull-up does exactly what you are describing. \$\endgroup\$ – Nick Alexeev Sep 2 '14 at 21:27
2
\$\begingroup\$
  1. Why is there another transistor involved (the 2N3904)? - so that the gate driver doesn't see less than 10k impedance (resistance). The 10k resistor and BJT are actually optional, but elegant if added. Edit: Whoops, it is essential for the PWM to work properly. it inverts a digital signal, which is required for a PNP to work the way you want it to. you can still omit the BJT if you can invert the control signal prior to output.

  2. And why is there a diode across the load? - because inductive loads (solenoids, motors, etc.) cause currents to flow in the other direction once turned off. As you're using PWM to control something, it basically rapidly switched on and off. You turn on the motor, the rotor starts to spin, you turn it off, the rotor still spins and then acts as a generator causing current to flow in the other direction. This reverse polarity can damage components, but is instantly negated once the diode is added.

\$\endgroup\$
1
\$\begingroup\$

This goes directly to the theory of MOSFETs. The diagram shows a DEPLETION MOSFET which works with Shockley equation:ID=IDSS(1-VGS/VP)^2. It is obvious that the micro controller works with 5 volts output and if you use it directly as a gate voltage, you can not obtain the maximum current from the power source (12 volts above ). The second transistor works as a buffer and also isolator for this purpose. And about the diode: this diode is almost always used for loads that contain coils ( as a motor or a relay). The purpose is suppression of the backward current made by the coil as an inductor. This backward current can damage your MOSFET.

Let me explain the diode part: let's assume we have a switch connected to a resistor and then an inductor.( SW-R-L->Ground). the problem arises when the switch opened very fast which means sudden zero current in the circuit but we know that inductors don't let sudden zero current (VL=L di/dt). This means that the inductor searches for a short way to empty it's current and the only way is making a "spark" between heads of the switch . We can see this phenomenon by connecting a DC power to a small DC motor. We can see although the motor is not working with a high voltage, but by touching its wires with the power cord, "very obvious sparks" are seen.By replacing the switch with a transistor , the same scenario happens and these continuous sparks lead to the damage to the transistor.

\$\endgroup\$
  • \$\begingroup\$ Inductors do not make a "backward current". Quite the opposite: they try to keep the same current flowing in the same direction. \$\endgroup\$ – Kaz Sep 10 '13 at 21:44
  • 1
    \$\begingroup\$ The depletion symbol is almost certainly just a symbol choice error. The circuit is not biased for depletion mode operation. \$\endgroup\$ – Kaz Sep 10 '13 at 21:47
  • \$\begingroup\$ can you elaborate on the "the second transistor works as a buffer and also isolator?" more specifically - why can't i just use that transistor as my "switch", why do a i need a sequence of two of them? \$\endgroup\$ – kolosy Sep 10 '13 at 21:51
  • \$\begingroup\$ -1: I don't think I've ever seen an answer that was so detailed, yet wrong on nearly every important detail. \$\endgroup\$ – Dave Tweed Sep 10 '13 at 21:55
  • 1
    \$\begingroup\$ @Kaz: Let's assume you want to use only one transistor ( which means must be N-Mosfet). Let's make a real world example with IRFxxx N-Channel Enhancement.I use this example as such Mosfets can bring up to 15 Amperes for the load. let's pickup one with VGS-Threshold = 4 volts and ID(on)= 14A at 10 volts.by ID=k(VGS-VGSth)^2 ,If you want to drive it at 5 volts from the micro you will have only ID=1.2 A current but by using the second transistor, you are driving at 0-12 volt with full scale range of current. \$\endgroup\$ – Aug Sep 10 '13 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.