0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

The circuit is taken from the schematic of a SONOFF of the ITEAD house.

If a gate of a MOSFET behaves like an open circuit, why are resistors needed?

Applying 3.3V from GPIO12 directly to the gate of the MOSFET should work correctly and barely circulate current through the gate of the MOSFET.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ What happens if the GPIO isnt connected to anything? What will be the voltage level at the gate of the mosfet? If the GPIO comes from a microcontroller, there will be times when it acts like an open circuit (i.e. is basically not connected to anything) \$\endgroup\$
    – BeB00
    Jan 3, 2021 at 10:12
  • 1
    \$\begingroup\$ I think by "door" you mean "gate"? \$\endgroup\$
    – Wesley Lee
    Jan 3, 2021 at 10:23
  • \$\begingroup\$ Sorry for my English, I meant gate \$\endgroup\$
    – Mario
    Jan 3, 2021 at 10:40
  • \$\begingroup\$ BEB00 >> What happens if the GPIO isnt connected to anything? GPIO belongs to an ESP8266, if I connect the gpio directly to the gate of the mosfet, with zero volts in gpio the relay does not activate but with 3.3 if it does, thanks \$\endgroup\$
    – Mario
    Jan 3, 2021 at 10:46
  • 2
    \$\begingroup\$ The 1k resistor is completely unnecessary for a MOSFET. Somebody took the circuit for a BJT and simply changed it to a MOSFET without bothering to update the rest of the circuit. \$\endgroup\$ Jan 3, 2021 at 10:49

2 Answers 2

2
\$\begingroup\$

R2 is necessary to make sure that the mosfet M1 is in cutoff even if nothing is driving the GPIO12 line. This is important during power-up, for example, at which time the MCU in this system may not be driving GPIO12. If this resistor were absent, the mosfet might turn on during startup and engage the relay erroneously.

R1 is not necessary because M1 is a FET. Were M1 a BJT and not a MOSFET, then this resistor would limit the current into the base. With a BJT, this would be necessary since the base-emitter junction of a BJT basically looks like a diode to the circuit which drives it. R1 is not necessary with a FET but does have the effect of increasing the turn-on/off time of the FET due to the increased RC delay imposed by the 1kOhm resistor and the capacitance of the FET's base input. Of course, this additional RC delay has no effect on the relay since the time for the relay to open and close is so much longer, but it would be more significant if the MOSFET were driving other electronics, rather than a relay.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you very much for this excellent answer \$\endgroup\$
    – Mario
    Jan 3, 2021 at 13:03
  • \$\begingroup\$ Could you give a small example of how R2 can prevent an activation during power-up? \$\endgroup\$
    – Mario
    Jan 3, 2021 at 13:19
  • 2
    \$\begingroup\$ Technically it is often good practice to include R1, since it limits the current flow into the mosfet gate. This can be important because too much current flowing can cause EMI, and also damage the GPIO (although it probably wouldn't in this case) \$\endgroup\$
    – BeB00
    Jan 3, 2021 at 19:50
  • \$\begingroup\$ @BeB00 indeed. Also because the gate can be quite capacative, there can be stability issues when driving it driectly from a CMOS output which tries to go from 0 to 3.3V in a very short time. Without the resistor the instantaneous current can be surprisingly large. R1 limits it to 3.3mA which will never be a problem. \$\endgroup\$
    – danmcb
    Mar 31, 2021 at 15:16
  • \$\begingroup\$ It is a voltage divider. the goal of those resistor is to establish the voltage at the gate which will be a ratio of the resistors \$\endgroup\$
    – Jose Areas
    Apr 1, 2021 at 2:42
0
\$\begingroup\$

These resistors work as a voltage divider. The voltage applied to the MOSFET will be a ratio according to the following formula:

Vgate = VGPIO12 * (R2/(R1+R2))

When the voltage is 3.3V that would mean 3 V will arrive at the MOSFET.

They are not pull-up/pull-down resistors.

\$\endgroup\$
12
  • 1
    \$\begingroup\$ R2 also functions as a pull-down resistor, however, and it's quite essential that it do so. \$\endgroup\$
    – Hearth
    Mar 31, 2021 at 15:30
  • \$\begingroup\$ The MOSFET gate will still get .909 of whatever floating voltage will be. Although It may be enough to not activate the MOSFET, it cannot be consider a pull-down. Because adjusting that resistor will affect the circuit in a different ways other than just adjusting a pull-down. \$\endgroup\$
    – Jose Areas
    Mar 31, 2021 at 16:39
  • \$\begingroup\$ But the floating voltage will also get discharged to ground through the combination of R1 and R2. It is a pull-down resistor in addition to its other functions. \$\endgroup\$
    – Hearth
    Apr 1, 2021 at 0:31
  • \$\begingroup\$ So, you are saying it is a 11K pull down, once both resistors are in series? So, you are saying that those 2 resistors can be replaced by a 11K resistor? I will have to disagree with you. The fact that a resistor is connected to ground does not make it a pull down. If that is the case, all R2 in a voltage divider are also pull down. Which is inaccurate once there are different formulas to model each of them. A pull down resistor will drive the signal by its own. In the case here what is driven the signal at the gate is the voltage left after applying the voltage divider formula. \$\endgroup\$
    – Jose Areas
    Apr 6, 2021 at 4:39
  • \$\begingroup\$ I'm not saying that you can replace them with a single resistor. It's a voltage divider, after all, and those require two resistors. I am saying that one of the functions of the resistor here, regardless of whether it was designed that way or not, is to pull the gate to ground when the gate drive signal goes high-impedance. I get the impression you don't fully understand what the function of a pull-down resistor is, or how floating gates behave, given your words above. Don't blindly apply formulas, try to understand the physics and you'll see. \$\endgroup\$
    – Hearth
    Apr 6, 2021 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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