H-Bridge Latching Solenoid Control

A project log for Firefighter Pump Training System

andyknittandyknitt 06/07/2014 at 21:284 Comments

Since the brains of this project is a Raspberry Pi, we want to be able to control the valves from the Pi somehow.  Since the valves are simple on/off valves, using the Pi's GPIO pins is a logical solution.  However, there are a couple problems we need to address.  First, the GPIO pins can only supply 3.3V at a relatively small current, while the DC latching solenoids that control the valves are 9V devices that pull more current than the GPIO pins can source.  Another problem is that the DC latching solenoids require their supply polarity to be reversed to turn the valve off.  

The solution to both of these problems is an H-bridge circuit.  H-bridges are commonly used to drive DC motors in either direction by reversing the polarity of voltage being sent to the motor, and are commonly controlled by microcontroller pins.  In this case we won't be driving a motor, but instead using the H-bridge to reverse the polarity of the voltage being sent to the DC latching solenoid.  A schematic of the circuit I used is shown below.

This can look a little confusing if you've never seen an H-bridge before, so let's step through it.  The two terminals of the solenoid are connected to the S1A and S1B points.  If we apply 3.3V to point H1B, that will turn on NPN transistor Q2 and allow current to flow from point S1A to ground.  At the same time, that 3.3V also turns on NPN transistor Q3, which pulls point H1C low, which in turn turns on PNP transistor Q4.  When Q4 is on it allows current to flow from the 9V supply to point S1B.  So now we have current flowing from the 9V supply, through Q4 to the solenoid coil connected at S1B, through the solenoid coil to point S1A, and from S1A through Q2 to ground.  The current path is complete, and the solenoid will activate, turning the water valve on.  Since this is a latching solenoid, we only need to apply 3.3V to point H1B for about 500ms.  This gives the solenoid enough time to fully activate and latch, and then we can remove power.  

To switch the solenoid in the other direction, we apply pulsed 3.3V to point H1D.  The current path is then from the 9V supply, through Q1, out to the solenoid coil via point S1A, through the coil, into point S1B, and to ground through Q5.  So we now have current flowing from S1A to S1B, which is opposite of when we applied 3.3V to point H1B.  This switches the solenoid in the opposite direction, turning the valve off.  

We can now use two GPIO pins from the Pi connected to points H1B and H1D of the H-bridge circuit to turn a single valve on and off.  

I created a PCB that contains two of these H-bridge circuits along with some analog input circuitry for reading pressure sensors.  This PCB connects via ribbon cable directly to the Pi.  I'll post full schematics and PCB layouts (created in KiCad) eventually.  In the mean time, if you have any suggestions for how to improve this circuit, by all means leave a comment to let me know!


gadmeer wrote 03/21/2021 at 22:16 point


thanks for posting this circuit. I found some articles talking about and does the circurit address also for this?

As I can see D1-D4 look like they address the back EMF problem. Correct?



  Are you sure? yes | no

andyknitt wrote 03/22/2021 at 02:02 point

Yes, the diodes are for back EMF from the solenoids.  The base resistors can be sized to limit the current flowing through the transistors to whatever value you'd like.  

  Are you sure? yes | no

gadmeer wrote 04/10/2021 at 08:29 point

Thanks Andyknitt! :)

  Are you sure? yes | no

Mario Praga wrote 07/10/2014 at 19:44 point
Hi, I have found your project and I like it . I wonder how many pulsed can drive the 9V battery, also if can be used with a 1.7A bistable latched solenoid.

  Are you sure? yes | no