Close

H-Bridge Latching Solenoid Control

A project log for Firefighter Pump Training System

andyknittandyknitt 06/07/2014 at 21:281 Comment

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!

Discussions

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