Water pump controller idea...

Grogster

Senior Member
Hi.

I need to sense when a water pump is pumping at regular intervals.
The pump is self-contained, and although you can set the pump pressure switch to what you want, there is no access to the switch itself.

Therefore, I was planning to simply pass the phase wire(complete with insulation for safety) through a toroid core a few times, and put quite a few turns on the other side of the toroid using thin enameled copper wire, which would then be connected to a half-wave rectifier and decoupling cap. The idea being that when the pump starts up, a voltage will be induced in the enameled wire by the current being drawn through the 230v phase on the other side of the toroid core, producing a voltage that the Picaxe can then detect - it would not need to be that much voltage - a few volts would probably be enough for the Picaxe to detect it. There might be more required then that(an amplifying transistor arrangement perhaps) if there is not enough induced voltage from this idea, but that is the general concept.

A timer routine can be setup to time how long the motor is on for, but the next bit is the tricky part:

- Detect whenever the motor is routinely switching on and off, and when there is a pattern, switch off the juice to the motor stopping it until manually reset.

The problem with that, is that the duty-cycle for ON-OFF pump condition can be anything - 5 minutes or 50 seconds - you name it.

I know how to deal with the first event, but not sure how to approach having the PIC detect a pattern of regular on/off cycles.

This is all being done, as there is a master water tank of some 20,000 liters, and a buffer "Pressure tank" which is kept at a water pressure of about 8lbs/sq. inch. The pump sucks water from the main tank, and pushes it into the pressure tank until the pressure in the pressure-tank is 8lbs or so, at which point, the pump switches off until the pressure in the pressure tank drops, and when that happens, the pump switches on again, and builds up the pressure again, before switching off.

Depending on how quickly the water is being taken from the pressure tank, the pump can be switching on and off quite a bit, or hardly at all - it all depends on water demand.

REMEMBER - You cannot access the pressure switch - it is built into the pump assembly's water output valve.

Any ideas on how to detect a regular on/off pattern?
 

BeanieBots

Moderator
Your torroid current sense is fine. I use it to confirm that heaters are really heating and not just on with a burned out element and/or safety bi-metallic contact tripped. A few extra turn will even give enough to drive an LED direct.
Use two diodes in series back-to-back with a another two to keep the average DC at zero or the torroid will degrade over time.

Pattern matching is an age-old challenge. Especially with limited resources.
For something like this, I would feed the on-off times into an array. Then compare that array to some "known" pattern and assign a value to "how close it matches". You need to decide the deffinition of a match. It could be based on sequence, time or both. Then shift the array along by one and do it again. This requires a lot of memory and will need I2C RAM for anything but the simplest of patterns.

If you don't know the pattern, then the only method I know of is "neural nets". I've had a few failed attempts at doing that with PICAXE (needs floating co-processor) but there is plenty of stuff on the net to run on a PC. Maybe you could "characterise" using that and then hard code the PICAXE?
 

KMoffett

Senior Member
Grogster,

Attached is the detector portion of a circuit I made to automatically turn on my shop's dust collector when I turned on the table saw. It worked on any current draw above 1/2 amp.

Ken
 

Attachments

boriz

Senior Member
You want to override the pump’s automatic control and turn it off IF it has switched on/off more than a certain number of times in the last X minutes?

Try something like this:

Have a loop that lasts 60 seconds, checking the pump status the whole time. When the pump status changes (on-to-off or off-to-on), add 10 to a variable. When the loop exits, if the variable is greater than zero, subtract one from it.

Think of it like a leaky bucket. Each event adds a cup of water to the bucket (+10), but it has a constant slow leak (-1). If the bucket ever overflows, then there must have been more than a certain number of events within a certain time. The ‘certain time’ and ‘certain number of events’ will need to be tuned when writing the program to reflect your needs.

EG:

Let’s say the bucket is full and holds 60 ‘drips’. And every second, one drip is lost. After 30 seconds the bucket is half empty, but then there is an event and 10 drips are added. Ten seconds later, the bucket is half full again. So long as the events occur less frequently than once every 10 seconds, then the bucket will never overflow. But if the average frequency of events is greater than once every 10 seconds, the bucket will eventually overflow.

You only need one variable to keep track of the current amount of water in the bucket, and one variable to store the current on/off condition of the pump.
 

Grogster

Senior Member
Hi guys.
:)

@ westaust55: Thanks for the link - will check it out

@ BeanieBots: Thanks - confirmation that my current sense was the right track then! Also thanks for your comments on pattern matching - we are in agreement there - the pattern matching or detecting was the bit I was thinking would be the hard part...

@ KMoffett: Thanks for the GIF! :) I have saved it so that I have a working reference.

@ boriz:
You want to override the pump’s automatic control and turn it off IF it has switched on/off more than a certain number of times in the last X minutes?
Yes, that's exactly right, but detecting the PATTERN at which point the system decides it has switched on and off too much, is the bit that has got me stumped for the moment. The idea, is to stop the main tank from being drained during the day, if someone leaves the tap on by mistake, as this house has no water-service connection. Water is trucked in when the main tank needs filling.

So, assume two cases: Case 1 - tap is left running at about 25% on or thereabouts(not turned off at all, and a constant, but controlled stream of water is running down the drain). The pump will therefore be switching on and off to maintain the pressure quite regularly as the pressure is constantly dropping from the pressure tank while the tap is on like this. Case 2 - tap is left dripping. The pump will therefore be switching on and off all day, but much less often then in case 1, as a dripping tap will not drop the pressure in the pressure tank anywhere as quickly as a running tap will.

In Case 1, the pump will likely have a duty-cycle somewhere around 50/50 or so, as it will be pumping every 5 seconds or so, for 5 seconds or so(high velocity pump), to rebuild the pressure. In Case 2 however, the pump will still only pump for 3-5 seconds, but will remain in the OFF state much longer - it could be 20 minutes or more, depending on how fast the drip is.

Hope this helps everyone to understand what is happening, and what I am trying to catch!
:D

Your loop idea is great - I will now rustle up a rough prototype and play around with some code and let you all know what happens.
 
Last edited:

Jeremy Leach

Senior Member
I don't think this is too hard really - unless I'm missing something. A steady leak will just cause the motor to come on at a constant repeating time interval. There will be interruptions of this regular sequence when taps are used for legitimate reasons, but I think all you need to do is to monitor for long stretches of repeating time intervals, with some tolerance built in. In pseudo code ...

Code:
'Initialise
SameCount = 0
LastInterval = 0

DO
      Gosub TimeNewInterval
	
	Gosub CheckIfIntervalIsSame
	
	'If the interval has remained the same as the last interval then increment counter
	'otherwise reset counter.
	If IntervalIsSame = Yes Then
	    Inc SameCount
	Else
	    SameCount = 0
	EndIf
	
	'Calculate the duration that the same interval has been occuring for
	Duration = SameCount * ThisInterval
	
	'Check for leak
	If Duration > LeakThreshold then 
	    GotLeak = Yes
	Esle
	    GotLeak = No
	EndIf

      LastInterval = ThisInterval

LOOP Until GotLeak = Yes

Turn Motor Off

End

TimeNewInterval:
	ThisInterval = 0
	
	'Time how long the motor in on, in seconds
	Do
	    Pause 1 second
	    Inc ThisInterval	
	Loop Until MotorIsOff
	
	'Add how long the motor is off.
	Do
	    Pause 1 second
	    Inc ThisInterval
	Loop Until MotorIsOn
Return

CheckIfIntervalIsSame:
	'Calculate the Absolute difference between the last interval and this interval
	HighestInterval  = ThisInterval Min LastInterval
	LowestInterval = ThisInterval Max LastInterval
	AbsDifference = HighestInterval - LowestInterval
	
	'If the difference is below a threshold then class the intervals as the same.
	If AbsDifference < SameThreshold Then
		IntervalIsSame = Yes
	Else
		IntervalIsSame = No	
	EndIf
Return
EDIT: Code corrected and clarified.
 
Last edited:

Grogster

Senior Member
Thanks very much for the pseudo code - have printed it to study.
:)

Sorry it took a few daze to reply - have been busy.
 

RobertN

Member
Since the tank level is your concern, it may be worth while to monitor its level (pressure head) change rate directly, with a pressure sensor or other? Then determine level change rate like boriz suggests. Or, assuming the pump pressurizes a tank, a pressure switch can be added to the tank to indicate pump activity.
 

premelec

Senior Member
You can set up a word variable "TANK" and then accumulate pump on times [+] and off times [-] into that and put a shutoff signal when TANK gets too high and still subtract off times and then turn on again when TANK gets down to another point...

I manage a limited production well system with 4 users - monitored with a HOBO on/off logger - my observation is that there are some long periods of drain which do not represent leaks - and then there are those which do... the big thing, for us, is to not exceed well production - we use a Pump Saver cutout for dry/dead head/brownout etc... as well. Happy monitoring!
 
Top