I am working on a personal project that will involve driving a latching 9V/DC solenoid from an arduino. The circuit I've come up with is dependent on two things, that I haven't quite figured out yet:

1) The arduino needs to provide a DC voltage for a timed interval. This is to power a SPDT relay during whatever time it takes to charge a capacitor.

2) Same as in 1) but the DC voltage needs to be of reverse polarity.

I understand the use of MOSFETs to boost voltage and I know that H-bridges can be used to reverse polarity, but how do I combine these two elements?

I know there are tons of ICs, motor drivers, shields and the like out there that would provide an easy solution; I would however like to keep things as low-level as possible in order to learn something from it.

Thank you.

  • \$\begingroup\$ Excellent, go for it. There's some software you can use to draw schematics and you can put a picture together. Or draw something by hand and post a pic. (there are certain traditions you should follow in drawing schematics.) You might also want to post a link to the relay. Is it a latching relay? \$\endgroup\$ Dec 9, 2014 at 23:40
  • \$\begingroup\$ I don't think it's a latching relay... It's in one position when power is on, and in another when the power is off. \$\endgroup\$
    – vina
    Dec 9, 2014 at 23:58
  • \$\begingroup\$ OK then you should get rid of the word latching. You can edit your question and add, or subtract stuff. If it's not a latching relay, then you just need one switch (fet) for control not four. \$\endgroup\$ Dec 10, 2014 at 0:10
  • \$\begingroup\$ For clarity, the word latching applies to the solenoid, not the relay, and explains the need for reversing the polarity of the voltage. \$\endgroup\$
    – vina
    Dec 10, 2014 at 8:40

2 Answers 2


Just one small clarification before we go any further. MOSFETs, by themselves, cannot boost voltage. However, a higher voltage can be switched on and off through a MOSFET with a lower voltage. For example, your 9V source can be switched with a 5V signal from your Arduino. I suspect that's what you mean by "boosting voltage" using a MOSFET.

It looks very much like you want to construct a classical H-bridge topology. H-bridges allow you to control the direction of current through a load. In your case, the coil of a solenoid. An H-bridge is very simple if you think of the transistors as just four on/off switches that are independently controlled:


simulate this circuit – Schematic created using CircuitLab

When all four switches are open, no current flows and nothing happens. If, say, SW1 and SW4 are simultaneously closed, current will flow from the 9V source, though SW1, through the solenoid (from left to right), through SW4, and into ground. If SW2 and SW3 are simultaneously closed, a similar thing will happen, except the current will flow through the solenoid from right to left. Thus you have polarity control.

Now, let's replace these ambiguous switches with actual MOSFETs. We'll use all N-channel MOSFETs for now:


simulate this circuit

Imagine the gate of each MOSFET controlled by a separate digital line. Most likely GPIOs from your Arduino. Now it's just a matter of writing the code to activate the appropriate pair of transistors at the right time. It would be great if it was really that simple. But, unfortunately, it's not. There's one big gotcha when using transistors this way.

MOSFETs require a certain minimum voltage on the gate in order to activate. That minimum voltage, known as \$V_{gs(th)}\$, is relative to the MOSFET's source pin, not ground. In practice, you'll want a voltage a bit higher than the minimum. But I won't get into that here. The source pins of the low-side MOSFETs (M2 and M4) are grounded, so your Arduino's GPIO outputs will work. But the high-side MOSFETs (M1 and M3) have floating source pins. The direct voltage from an Arduino GPIO pin is not sufficient to activate the MOSFET.

From here, you have two options:

1) Use N-channel FETs for both high-side and low-side as shown in the schematic above. This is the more common method, as N-channel FETs have lower \$R_{ds(on)}\$ than P-channel. However, you will need to implement a bootstrap converter to activate the high-side FETs in order to overcome the problem described in the paragraph above.

2) Use P-channel FETs for the high-side and N-channel FETs for the low-side. Modern manufacturing processes have made P-channel FETs that are near in performance to N-channel. If the current load through the solenoid is not too high, this may be a simpler option as no bootstrap converter is necessary. However, you still can't drive the gates of the P-channel FETs directly from the GPIOs of the Arduino. A small, intermediary N-channel is typically used instead.

There are lots more things to work out before you'll have a functional H-bridge, but hopefully this will get you started. As you hone in on a specific circuit design, feel free to come back with more specific questions.

  • \$\begingroup\$ What about logic-level MOSFET's? Would minimum voltage still be a problem? \$\endgroup\$
    – vina
    Dec 9, 2014 at 23:48
  • \$\begingroup\$ Logic-level FETs are made to have lower Vgs(th) than standard FETs so that they can be activated by logic signals - such as a microcontroller. However, only the datasheet of the MOSFET can tell you if the voltage of your specific logic signal is high enough. \$\endgroup\$
    – Dan Laks
    Dec 9, 2014 at 23:53
  • \$\begingroup\$ Also, I don't intend to put the solenoid as the load in the H-bridge, I want to use a relay that will connect a circuit that will charge up a capacitor when powered. When the relay is no longer powered, it will complete another circuit that will unload the capacitor onto the solenoid. Sorry about "verbal schematics", I will take some time to draw this up tomorrow! \$\endgroup\$
    – vina
    Dec 9, 2014 at 23:54
  • \$\begingroup\$ Regardless, however, you cannot overcome the problem I described with the high-side FETs using logic-level devices no matter how low the Vgs(th) is. \$\endgroup\$
    – Dan Laks
    Dec 9, 2014 at 23:54

An H bridge is a configuration, mostly used with transistors so this is a shorthand for MOSFETs in an H configuration. You want to look for H bridge drivers, there are integrated chips that will take care of driving the transistors for you, you only have to add what the chip needs around it (clearly defined in the datasheet).

Edit: Just noticed you are curious (which is good!), here are some more details: For your information, power converters can be segmented in 4 categories corresponding to the 4 quadrants of the voltage-current plane. You want to use 2 quadrants: positive V positive I, negative V negative I. This can in fact be done with 2 transistors and 2 diodes instead of the full, 4 transistors (+diode), bridge. enter image description here And here is what the H bridge does for each quadrant: enter image description here

So basically, you only need the diodes and the transistors that are closed at any one point. However you still need to drive the transistor properly (see MOSFET driver), and that is particularly tricky for the high side transistor as the gate-source voltage has to be above a certain threshold for it to conduct, and its source's voltage changes over time... This is valid for N channel MOSFET (c.f. N and P channel MOSFET), you can use a P channel MOSFET instead to make the source gate voltage independent on the switching, however this requires voltages referenced to the upper solenoid power rail (not the 5 or 3.3V of your Arduino), and that, your arduino can't give so again that's something a driver would do.

The driver can then be considered as another circuit block that translates the output of your arduino in voltage levels that can "completely" close or open the high side transistor and here you are, building from the ground up.

WARNING: It is not for nothing that drivers are readily available. It is not quite that simple even for a basic 2 quadrant bridge. Do you really think your transistors will switch exactly at the same time? Think again. In order to prevent short circuits because of that, you will need to add tiny time delays to make sure the transition occurs in a safe, short circuit-free configuration.


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.