Difference between revisions of "Water control project"
Line 1: | Line 1: | ||
back to [[electronics]] | back to [[electronics]] | ||
===[[water control project]]=== | ===[[water control project]]=== | ||
====cascada 0.2 - http://10.0.1.186/?status=ON&til=1==== | |||
[http://alanesq.com/arduino/ethernet_test.txt alanesq.com] uses findKeyVal | |||
<syntaxhighlight> | |||
if(pos) { | |||
char* data = (char *) Ethernet::buffer + pos; | |||
Serial.println(data); | |||
if(strstr(data, "GET /?status=ON") != 0) { | |||
ether.findKeyVal(data + 6, til , sizeof til , "til"); | |||
Serial.print("Will stay on for "); | |||
Serial.print(til); | |||
Serial.println( " minutes.\n"); | |||
int until = atoi(til); | |||
//Serial.println(until); | |||
timer = millis() + until*60000; | |||
... | |||
</syntaxhighlight> | |||
====cascada 0.1 - enc, timer==== | ====cascada 0.1 - enc, timer==== | ||
*simple timer | *simple timer |
Revision as of 19:48, 9 May 2013
back to electronics
water control project
cascada 0.2 - http://10.0.1.186/?status=ON&til=1
alanesq.com uses findKeyVal <syntaxhighlight>
if(pos) { char* data = (char *) Ethernet::buffer + pos; Serial.println(data); if(strstr(data, "GET /?status=ON") != 0) { ether.findKeyVal(data + 6, til , sizeof til , "til"); Serial.print("Will stay on for "); Serial.print(til); Serial.println( " minutes.\n"); int until = atoi(til); //Serial.println(until); timer = millis() + until*60000;
... </syntaxhighlight>
cascada 0.1 - enc, timer
- simple timer
- setup
- loop
- turn of ligth after 5 seconds
<syntaxhighlight> ...
pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, HIGH); timer = millis() + 5000;
} void loop() {
if (millis() > timer) { digitalWrite(RELAY_PIN, false); }
} </syntaxhighlight>
- Switched from wiznet shield to cheaper enc shield getting up to speed from lucandentella tutorials
cascada 0
Click the button pump goes on in pond.
- send '1' to arduino, to tun on relay
- send '0' to arduino to turn off device
Arduino-Ethernet-Shield-Tutorial
version 1
todo
Pick up my phone, go to a web site, have there be a series of buttons on, off, 10, 20, 30, 60.
The idea was to automatically control the level of the pond by using a (cheap) lawn sprinkler relay to inject water into the pond when it falls below a critical level. Water gets added while the pumps are on until it reaches the max level then it goes off. If you turn on the pumps again it doesn't continue filling but waits to inject water til the water falls to the low water sensor.
The buttons could be from a client side jquery-mobile page. Timing would seem suited to the server. Server would send an on message and start a timer. After the time elapsed it would send an off message. Client would poll server to see what the status is and the time remaining.
Basic control is working in an outdoor circuit box mounted on the bridge next to the lawn sprinkler relay.
basic control
- comparators - LM324N quad op amp
- flip flop - 74HC74AP dual D flip flop pin-out
The water level sensors are just thermostat wire. When immersed the resistance decreases to about 50K. Each sensor goes to a comparator. Comparators work in this setup by outputing LO if the minus input is a lower voltage than the +input and HI if the + input is higher.
For the bottom sensor, the -input was hard wired with an even voltage divider that gave it 1/2 VCC. The +input had an uneven divider of 47K to VCC and 57K to GND when the sensor was out of water. More of the voltage dropped across the 57K than the 47K so the +input was higher than the -input and the output was HI. Submerging the sensor put approx 50K in parallel with the 57K so then the equiv resistance wasless than 47K so the -input is at a higher voltage and wins. The hi water sensor had a similar comparison.
The low level comparator goes HI when out of water and the high water sensor goes HI when immersed. The output of the low level comparator goes to the D input and the output of the high level comparator drives the clock. When the D flip flop output Q is HI the pump goes on.
how the flip flop works
The flip flop was setup with <math>\overline{clr}</math> set to HI. Then, whenever a clock pulse goes HI, whatever is on the D input gets transferred to 'memory' and shows up on the Q output, EXCEPT, if <math>\overline{pre}</math> goes LO, it forces Q HI no matter what.
how this circuit works
loop
- The bottom sensor comparator is wired to the D and through a NOT gate to <math>\overline{pre}</math>. <math>\overline{pre}</math> forces Q HI when it is LO which only happens when the water level is below the low sensor. The HI turns the pump on.
rising water
- Once the water reaches the lower sensor and forces it LO that LO on D just hangs there waiting to be transferred by a rising clock pulse. That doesn't happen until the water rises sufficiently so the high sensor is immersed. Then it sends a rising pulse to the clock which puts what's on the D input on the Q output. In this case that is a LO. So the output goes LO and the pump goes off.
falling water
- When the water falls below the high limit sensor the pump stays off since when the high limit opens it sends the clock LO on a falling pulse which does not change Q (only a rising pulse does). So the pump stays off until it falls past the lower sensor. LOOP
loop
revision
After using for awhile I decide to change the function a bit. As designed, when the switch was thrown to run the circulation pumps if the state of things was between high and low water then D saw a LO, and Clk saw a LO. When you flipped the switch that state caused the pump to come on, ie be HI. I decided I didn't like that, I'd be filling the pond when I didn't really need to and end up wasting water.
So I had to change what happened on power up. If I could force a rising pulse on the clock I could drive it HI and since the lower sensor was LO it would transfer that LO from D to Q and keep the water relay off. Putting a capacitor between ground and the -input of the upper sensor comparator drove that pin to ground when the power came on (as the capacitor momentarily looked like a short) which sent a rising pulse to the CLK which transferred the LO on D to Q turning off the pump. When the capacitor charged then the -input went back to winning the comparison and sent the CLK LO which as we know has no effect on the Q output.