I redid the plumbing, adding a separate pressure pump on the surface. Now, the wells always pump into the storage tank, and the pressure pump takes water out of the sotrage tank and pumps it into the pressure tank. But the pressure pump is an additional high current load, and prior to adding that I've drawn too much current and tripped the main breakers on the house. At the same time as redoing the plumbing, I decided to put in a controller that would only run one of the three pumps at a time. In this way I would be reducing the peak current requirement, since before two pumps could run simultaneously (and could potentially be starting simultaneously, but since they were on separate pressure switches that was unlikely).
I put four level switches in the storage tank. The top one isn't actually used (it's output is displayed, but is otherwise ignored). It tells me that the tank has more water in it than I'll put in there from the wells. I get some water from a spring part of the time, so this is a normal condition. There's an overflow on the tank to dump the excess water. If that was not the case, that sensor could trigger an alarm. As it is, it could potentially be used to help decide when to run some type of irrigation system, when to change the water in a hot tub, when to pour water into the wells to try to recharge the ground water, or something along those lines. The next two switches are used to decide to start adding water to the tank, and when to stop. The bottom switch is just a little above the pipe that draws water out of the tank - it is used to prevent the pressure pump from being run dry.
There are three relays to control the pumps. There's a current transformer on each going back to the controller, directly into the ADC inputs on the PIC (RMS calculations are done in software), to monitor how much current the pumps are drawing. Too little current would indicate that the pump is dry, or turned off if the current is really small. Too much current indicates that it's stalled. Too little or too much current for the pressure pump are both alarm conditions. These are alarm conditions for the well pumps as well, unless the current is really small. That is a normal condition, as they have their own boxes that won't let them run when the wells don't have enough water in them. The alarms cause the controller to not attempt to run the associated pump again until the error has been reset.
Finally, there's a pressure sensor (on the pressurized side of the system of course). This just puts out 1-5V corresponding to pressure from 0-100psi, and goes straight into an ADC input on the PIC. It's used to decide when to turn the pressure pump on and off. If the pressure goes over a fixed threshold this is also an alarm that causes all of the pumps to shut off until manually reset. If this happens it probably means that the valves are not in the right state for the mode the controller is in; there are also mechanical pressure relief valves at the outputs of the pumps where they can not be cut off by a valve, to make sure the whole thing won't explode.
It also uses the absense of current to the selected well pump as a cue to switch to the other well, since that means the selected one isn't running (which means it's dry, manually turned off, or broken). It starts with a minimum time between switches of five seconds. Each time it switches pumps at the minimum time, it increases the minimum by fifteen seconds, until it reaches the normal switching time of fifteen minutes. Each time it switches at more than the current minimum, it subtracts fifteen seconds from the minimum until it's back down to five seconds. This is to keep it from wearing out the relays or anything in the well pump boxes when neither well pump is producing water.
The trip points for alarms from the current sensors are all hard coded in the firmware, so I'd probably have to change those if I ever switched to a different size pump. The pressure set points are soft configurable. I did the plumbing so that I can change to having the wells pump directly into the pressure tank, rather than the storage tank, by changing some valves. This way the storage tank could be taken out of service for maintenance without cutting off my water. The controller can be switched to a mode where it uses pressure rather than level switches to control the well pumps, and leaves the pressure pump off, to support this configuration.
There's a driver on the board intended to control an LED type backlight on the LCD. The firmware never turns this on because the LCD panel I ended up with doesn't have one. If it did, I would have turned it on whenever one of the two user control buttons was pressed, and off maybe 30 seconds after the last button push.
allanh@kallisti.com