13
\$\begingroup\$

I'm trying to control a 12V DC solenoid valve through a MOSFET (BS170), which receives its control signal (5V) from an Arduino microcontroller. This is the basic schematic: enter image description here

When I test the MOSFET, putting a LED with a 1.5k ohm resistor as Load (see picture), it works fine and I can control the 12V current with the 5V signal, without problem.

But then I connect my solenoid valve instead of the LED. It works for a few seconds, then it stops working and the MOSFET ends up permanently conducting current, regardless the state of the 5V control pin.

The MOSFET is permanently damaged, because when I connect the LED again, it doesn't work anymore.

Too much current? But when I add a resistor before the valve, it doesn't operate anymore... Maybe I need a heavier MOSFET/transistor?

\$\endgroup\$
5
  • 2
    \$\begingroup\$ how much current does your solenoid draw? You need to pick an appropriate size MOSFET and we can't possibly answer that question w/o knowing the current requirements. \$\endgroup\$
    – Jason S
    Mar 31, 2012 at 19:06
  • 2
    \$\begingroup\$ Can you link the datasheet of the solenoid? Or at least connect it with an ammeter to 12V and tell us the current it draws? \$\endgroup\$
    – markrages
    Mar 31, 2012 at 19:06
  • \$\begingroup\$ Does the MOSFET get hot ? \$\endgroup\$ Mar 31, 2012 at 20:42
  • \$\begingroup\$ markrages: ebay.com/itm/290655223999 Rocketmagnet: Yes, it does. \$\endgroup\$
    – Dyte
    Mar 31, 2012 at 22:36
  • \$\begingroup\$ Poor driving voltage. Use a universal bipolar NPN transistor to get your control voltage to 12V, then drive a P-channel MOSFET with that (because the polarity will be changed by the extra transistor). Use a current-limiting resistor for the base and a pull-up resistor for the collector as usual. Also connect a filtering cap between D and S of the MOSFET because a diode itself may not be fast enough to intercept the spike from the coil. If the inductance is huge, you may want to create a fade-out with an integrating RC element in the input. \$\endgroup\$
    – Zdenek
    Nov 10, 2017 at 19:52

1 Answer 1

23
\$\begingroup\$

Read my blog entry "Byte and Switch" -- it covers this exact scenario.

The short answer is that you need a freewheeling diode to conduct the current when the MOSFET turns off; the solenoid has inductance that stores energy in the magnetic field, and when you turn the MOSFET off the inductance will generate however much voltage is necessary to continue flow of that current. The resulting voltage pulse will cause breakdown in the MOSFET which causes the damage you are seeing.

You should also add a couple of resistors, one from microcontroller output to ground, to make sure it's off when your microcontroller is in reset, and the other from the microcontroller to the MOSFET gate, to add some resistive isolation between your power switch and your microcontroller.

enter image description here


edit: I just noticed you're using a BS170 MOSFET. Have you looked at the datasheet? This is a poor choice for a MOSFET used as a power switch from a microcontroller.

First of all, the MOSFET is specified at 10V Vgs. You're supplying it from a 5V microcontroller. You need to make sure you use MOSFETs that are "logic level" and have on-resistance specified at 4.5V or 3.3V Vgs. (I suggest you not use ultra-low voltage MOSFETs as there's a possibility of it turning on weakly when you think it is off.)

More importantly, it's a small TO-92 MOSFET specified at 5 ohms max Rdson at 10V Vgs. This MOSFET is fine for very small loads like LEDs drawing a few milliamps. But solenoids generally draw tens or hundreds of milliamps, and you need to calculate I2R loss in your MOSFET for the current load it draws, and make sure that it doesn't cause your transistor to overheat. Look at the thermal resistance R theta J-A on the datasheet and you can estimate how much temperature rise there is in the part.

Use a MOSFET in the 20V-60V range that has a lower on-resistance -- as I said in my comment, we need to know how much current your solenoid draws if we're going to help you.

\$\endgroup\$
11
  • 2
    \$\begingroup\$ A catch diode is absolutely needed here, but that's not the cause of "fails after a few seconds" type of failure. \$\endgroup\$
    – markrages
    Mar 31, 2012 at 19:08
  • \$\begingroup\$ Thanks for your quick answer! Silly of me that I didn't specify the valve. This is the one: ebay.com/itm/290655223999 It has some data, including the current: 500 mA. So I'm using the wrong mosfet? Btw, where do you see that it's rated for 10V Vgs? On the datasheet I see "+-20" in the VGss row. \$\endgroup\$
    – Dyte
    Mar 31, 2012 at 22:30
  • 1
    \$\begingroup\$ I just changed "rated for" to "specified at". You can use up to +/-20V gate-to-source voltage w/o damage, but if you want the MOSFET to have a guaranteed drain-source resistance, you need to provide 10V gate-to-source, at which point the on-resistance is at most 5 ohms, typically 1.2 ohms, at 200mA load (see Rds(ON) on page 2). At 5V gate-source, it is going to be a higher resistance, so you're talking a watt or two of power dissipation of I2R... all you know is it's probably several times higher than 1.2 * (0.5A)^2 = 0.3W... until the device overheats and fails. \$\endgroup\$
    – Jason S
    Mar 31, 2012 at 23:03
  • \$\begingroup\$ I would add a zener diode to protect MOSFET's gate-source. Would it be an over-kill? \$\endgroup\$ Apr 1, 2012 at 8:07
  • 1
    \$\begingroup\$ @abdullah: Not overkill, rarely needed though unless there's a risk of noise causing gate/source voltage to exceed safe levels. \$\endgroup\$
    – Jason S
    Apr 1, 2012 at 13:44

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