Stock Tank Filler

Overview: This is a project to increase the reliability of controlling the flow of water to a stock tank that keeps our horses well watered (there is a “lead a horse to water” joke in here somewhere) using a microcontroller to sense water level and turn the water on/off.  No AC power is available at these stock tanks, so using very low power techniques is required.  The project uses an MSP430 MCU and a DC latching solenoid with a high quality sprinkler valve driven by an H-bridge device.  Power is provided by a single 9v battery. 

Problem: Having horses on the ranch means keeping a steady supply of water for these animals that can swallow a quart per gulp.  Our stock tanks have water piped to them and we have used float valves to regulate the water level, but these float valves wear out often (twice a year), cost ~$30 to replace, and the failure mode results in lots of water in the pasture – good for the grass, but bad for the pocketbook (we don’t have well water).  And water is a precious resource in Texas these days. 

Solution: A few years ago we had irrigation plumbed to our greenhouse and the contractor used a regular sprinkler valve (Irritrol 205s) outfitted with a DC latching solenoid powered by a controller allowing you to set watering cycles as you would expect from a sprinkler controller, but powered from a single 9v battery.  After reliable daily watering on a single 9v battery, it occurred to us that leveraging a similar setup would improve the stock tank problem. 

So it was time to design some electronics to do the job!  Last year we picked up some Launchpad boards from Texas Instruments for $4.30 (MSP430 – four three oh) and enjoyed how simple it was to program, test, and debug with the free Eclipse-based development environment (CCS) supplemented with other great inexpensive tools like the Saleae logic analyzer and a USB oscilloscope.  We hacked together a prototype using a Launchpad and an H-bridge DRV8333 evaluation board working out the basics.  Lot’s wires everywhere as prototypes go! 

Our end goal was to house this controller in the valve box below ground level, so it had to be waterproof.  We had never done a pcb before, but figured this would be the perfect time to learn how to design one, reflow it, and produce a neat, reliable device.  We started down the Eagle tools route, but the commands weren’t intuitive – looked like a big learning curve ahead, yet it seems everyone uses Eagle.  We searched to see if there was an alternative and landed on Diptrace.  Much more intuitive to us and the tools are free, like Eagle, for the hobbyist.  We are open sourcing this project, so hence the design files are Diptrace! 

More on the design:

Hardware Choices: We decided to use the same DC latching solenoid (DIG-S305-DC) and the same valve (Irritrol 205S) that our sprinkler guy used, since he said it was very reliable.  We started searching for an h-bridge and found the TI DRV8833 which has a power supply range of 2.7 V to 10.8 V. The coil impedance of the DC solenoid is 5 ohms and with a 9v battery, we needed the h-bridge to handle 1.8 amps.  The DRV-8833 has two h-bridges each capable of 1.5 RMS amps or 2 amps peak and you can use them in parallel for 3 amps RMS or 4 amps peak so we decided to use them in parallel – could have probably used one channel but we didn’t need the second channel and two channels must be better than one! 

We could have used a basic and less expensive MSP430F2012 for this project, but in case we wanted to add zigbee for remote monitoring/control, we decided to use the MSP430G2553 which has better UART and I2C capability and 16K of flash and 512 bytes of ram.  We had used this part on several other projects as well.  The MCU is programmed using headers that can be attached to the Launchpad – VDD must be driven by the Launchpad when programming so we provided a jumper on the board that must be in the appropriate position.  Kerry Wong provides a nice writeup on using the Launchpad as a programmer here. 

The solenoid specifies a 10 msec minimum pulse to engage/disengage .  During prototyping, we observed a considerable sag in the voltage to the solenoid when the h-brigde was on – the 9 volts would drop to 4 volts – presumably due to the internal resistance of the battery.  So we did a little math on the energy that needed to be dissipated in that 10 msec timeframe, and added a 4700 uF capacitor across the battery and that made things look better, although still sagging to a little over 5 volts.  But the solenoid was happy. 

To provide VDD for the MSP430G2553, we used a TPS76333 – by now you you may be thinking that we are biased towards TI parts, but they provide free samples, fast delivery, and no shipping charges — the path of least resistance! 

Software: To conserve power and simplify the hardware, we used the Very-Low-Power Low-Frequency Oscillator (VLO) for the watchdog timer which is nominally 12 KHz and the default 1MHz DCO when the processor is active.  The VLO can vary from 4 KHz to 20 KHz over the broad temperature range, but we intended for the controller to be in the valve box below ground so we wouldn’t see huge temperature swings and the sampling time of the float switch is by no means critical in this application. 

Packaging

Weatherproof operation is required!  The controller will be located below ground level and will fill up with water in a heavy rain.  We selected a case from Polycase with a cable gland to seal where the wires to the solenoid and the float switch pass through.  Great thing about the Polycase box, is it comes with a dxf template of the dimensions of the circuit board it can accommodate.  We imported this to Diptrace and made some modifications so that it would fit in the 5 cm x 10 cm category for itead studio’s pcb service to reduce pcb costs. 

PCB

As mentioned above, we settled on the Diptrace tools for our schematic capture and board layout.  The tools work well and itead studio’s service is great – for both times we ordered (yes, we missed a few things on the first prototypes), we got back boards in just under three weeks.  They advertise 8 pcs for the colored solder mask boards with 100% e-test and we got 12 boards back on the first run and 11 boards back on the second run.  Very pleased with the quality and service. 

Field Test

The installation required some plumbing This meant some digging and pvc cementing the valve in place.  For the float switch, we fashioned a simple bracket from 1” aluminum stock from the local home improvement store.  After wiring the controller to the solenoid and float switch, the solenoid engaged after the expected delay and shut off when the float switch went open!  However, for the next few mornings, the tank was below the float trigger level meaning something wasn’t working as we thought.  After some pondering, we realized we had no hysteresis in the float switch sensing/triggering control software and theorized it could be that trying to trigger the solenoid on soon after triggering it off, could have put too much demand on the 9v battery and reservoir capacitor.  We added the logic in the software to prevent a retrigger within a period of time and this gave us reliability – no problems since then! 

Next Steps

We don’t know how long the battery will last and we’ll post that when we know as we don’t (yet!)  have a multimeter than can measure in the microamps range (millamp range shows zero).  We also plan to test a tank with a flow meter plumbed inline to collect some statistics on water usage.  There are already Zigbee temperature sensors in use around the ranch, so adding this to the network with information about on/off cycles and usage would be interesting. 

14 Responses to Stock Tank Filler

Have you put any thought into adding a bit of extra circuitry for using a Lead Acid, NiCd, or NiMh battery and a solar trickle charger?  If the solenoid is dragging down the battery to 5V a longer lived source might be a rechargeable 6V lantern battery and a matched solar panel.  Several batteries in this range easily run into the 4-5Ah range. 

The controller lives beneath the ground in a valve box, so solar would need to be separated and obviously above ground.  Size matters (!),  so staying within a small footprint to fit in the valve box precluded larger battery options for us. 

I would ditch the float and add liquid detection to the MCP430 using a couple stainless-steel (bolt) electrodes and squarewave drive, like the LM1830 does. LM1830 (pdf datasheet)
Tank slosh can be a problem, so add a delay time there.  Would like larger pics of PVC stuff. 

Ok, have the units and they are great for my application. ( aquaponics).  What is the chance of a add on module that has a LED to show when to replace the battery? 
Could plug into the test header, and turn on (or off) when the battery voltage drops below a pre determined level. 

A simple voltage divider could be crafted to be sampled by the ADC of the MSP430.  There is already a 2 pin header named SW Led that could be used for a flashing low voltage warning.  It currently is pulsed anytime the solenoid is activated for a visual reference and we also use it with a simple test program to initially test board after assembly.  We simply plug in an LED with a current limit resistor soldered inline for the visual feedback. 

The main reason we didn’t implement a voltage divider is it consumes power unless there is an FET in line to turn it on/off.  Also, we anticipate getting a year or so from the 9v battery, so we opted to just test the battery at some interval. 

We’ll play with some ideas that could be retrofitted and/or might be included in future revisions. 

K2 is there in the event someone wanted to have a switch that turns on VCC to the MSP430 – we decided not to put an external switch on our stock tank filler, so the board ships with the jumper installed. 

EZ_VCC/VCC3.3 is a jumper that provides VCC either from the onboard regulator (normal operating position) or provided from the external programmer for the MSP430.  It is normally connected to the onboard regulator, but when when flashing the MPS430, you must use the supply voltage from the programming source, in our case the launchpad. 

The 9v battery finally stopped triggering the solenoid after 11 months of pretty steady usage by 4-5 thirsty horses.  The “terminal” voltage measured was just a little bit over 6 volts, lots left to power the MSP430, but not the solenoid!  We are working on a visual indicator for battery status…stay tuned.