Go Down

Topic: This has me stumped! (Read 2565 times) previous topic - next topic

helichuck

WOW Paul, that works great!!

PaulMurrayCbr

For any newbies/lurkers: remove the comment on #define DEBUG, and the serial output will give you a look at what a circular buffer looks like in operation.

The buffer is the key to the algorithm. Without it, you'd only be turning off the water at the 20-minute mark. With it, the water gets turned off within 30 seconds of the trip point being reached. Now, because our sensitivity is set to 90%, this is 18 minutes of water running. The sketch could be made more sensitive by reducing this, at the cost of possible false positives. It really depends on the cows.

You know - this sort of problem is very amenable to baysean analysis. By getting records of the switch operation, we get prior probabilities for the sensor behaviour when the water thing is working correctly and for when it is stuck. We can then ask, "If the sensor is more than A% on over B time period, what's the probability that the switch is stuck?" Then one asks the question, "for a given time period B, what setting for A will give us no more than a 5% chance per day of getting a false alarm?" Finally, one can ask "what's the optimal A and B that wastes the least water while giving us a false alarm no more than about once every couple of weeks?".

That's the trade-off, of course. Water waste vs. walking out to the cow trough to reset a false alarm. There's no avoiding that.

Now, if we could hook this baby up to a solenoid whose job it was to give the lever a thump with a rubber mallet when it was stuck …


http://paulmurraycbr.github.io/ArduinoTheOOWay.html

helichuck

The good news is you don't have to walk out to the trough, the alarm circuit will be in the house.

The bad news is I got to thinking, and all the water that the house uses goes through the flow valve, so, say, you do dishes and a couple of people take a shower you would have a 90% senario and could trigger the alarm.

Does hitting the reset also start the sequence all over??

Or should it auto reset any time the valve closes, and only time while the valve is open, and have it alarm only when you have a flow for a constant 20 minute period?

Boy this could be interesting.


Also on another note, I wonder if you could take the original Blinky sketch and add 2 pots, one would adjust how long the light was on and the other how long the light was off???

PaulMurrayCbr

The bad news is I got to thinking, and all the water that the house uses goes through the flow valve, so, say, you do dishes and a couple of people take a shower you would have a 90% senario and could trigger the alarm.
Well! Looks like you need to log the data for a while (as in, a few days at least) and examine it. Store it on an SD card, or upload it to a web server. Once you log the data and keep a diary of when you needed to un-jam the cow thing (v important), then maybe you'll be in a position to decide how to tell when the gate is jammed open.

Or you could just put a stronger return spring on the gate and not have this problem at all.
http://paulmurraycbr.github.io/ArduinoTheOOWay.html

Go Up