The Pond Tap is at the base of the garage tank and runs into the top of the ponds

between my house and next door.

But the level switch is three ponds downstream, so it is quite complicated regulating the water level, when there is such a delay in response times. The first system used a 68705P3 28 pin MCU. These had to be erased under UV light and programmed in DOS - all a bit cumbersome. So time to move forward. The second version MC9S08QD4 8 pin MCU, (8 pin just to prove it could be done - 16 pins are no more expensive). These can be erased and programmed in circuit.

2 pins for power, one to read the level switch as a digital Input; another reads the zero switch on the tap: this comes on when the tap is fully closed, so we can set the tap position to zero; Another pin is an analogue input - a mix of the line voltage to the main return pump logic and a torridal current sense on the pumps so it can shut the system down if the pump doesn't run for more than 15 minutes, or runs continuously (means the return pump has failed or the return level switch has stuck); but not if the tanks are full which switches off the 15V supply to the pump controller logic. It also monitors the 15V: If its less than 14V it must be running on the backup battery, which means there's no AC - the return pump won't run and so the MCU shuts off the tap. Two are outputs: one to step the stepper motor on the tap, the other for direction of the stepper. And the eighth pin is the BDM programming pin. The circuit is simple, but the program and interrupt routine are quite involved.

 

The Third version uses an ARM cortex LPC2138 CPU but already on a prebuilt board. With the advent of surface mount 64 pin chips, it's difficult to make your own boards and solder the chips on. However I had to make an ancillary board

This also now runs the Solar heating - monitors the inside upper, inside lower, outside, garage, and solar roof temperatures, runs the circulation fan, opens and closes air dampers).

This board is an ARMweb by coridium corp. It has internet connectivity, 512K flash, 32K RAM, 6 10bit AD's, 31 programmable i/o's, spi, I2C, 1-wire etc.... But now the program is written in BASIC - who would have thought going back to basic! However the basic is compiled and is oriented to embedded MCU's, has access to flash, onewire in and out (I use 5 Dallas 18B20 Thermometers on a twisted pair), PWM control, >> and << ASR and ASL register operators, On Interrupt0,1,2 & Timer, write directly to a memory address/port, etc. The latest version also supports x = IF (n>8, 60, 22) and i += 1 etc. So now I could easily visualize what was going on the display on my house monitor web page

shows everything necessary. The following goes into the details.

Restart after serious error :- If the tap was still open, this will attempt to re-zero the tap at the closed position.
It will only travel down 2000 steps - then I have to re-start again. This is to prevent the stepper wearing the belt if the "zero" magnet is not detected - which has happened (a corroded connector)

Errors: Any errors are shown here in blinking red.

Tap Position :- 0 = closed, 18000 = fully open. A 40mm ball valve arm driven by a stepper motor/tooth belt/ old printer spiral drive.

There are 4 water level switches - D is lowest, A highest

Average Tap Pos :- ATP = ATP - ATP/128 + TapPosition; done every minute. Ave will reach (1- e-1) of a new tap position in 128 minutes. Can't be too long or it won't respond to a change of conditions (rain, some dirt clogging an outlet). The program actually calculates ATP128 = ATP128 - (ATP >> 7) + TapPosition. This is fast averaging especially if in an interupt routine reading an AD that you have to smooth. ATP128 means average tap position * 128.

Slow speed:= When the water level goes lower than C or higher than B, the tap travels to the target (ATP +/- TapBoost) and waits 60 minutes. Then it slowly steps at slow speed. If the level moves outside the A or D switches then it travels +/- the remaining time from the 60 minutes * 4 , waits (remaining time>>1); and then steps at [(slowspeed>>1) + (remainingtime>>3)] per minute. These time dependent variations give a differentail boost.

Pond Switch voltage:= IF all switches are working then > 1000 = all off; about 914 = D on; C & D on ~ 750
B,C & D ~ 555; All on ~ 362. System will work on one switch errors, but shut down on two switch errors. I only have two wies, so I couldn't put in an R-2R network to make a binary divider. So I just used R on board to 3.3V with A switching R, B switching 2R, C switching 4R and D switching 8R to ground.

Shut down - shut down the ponds - password required.

Heater Mode Before/After warming/cooling, it takes 1 minute to open/close the damper valves. Then it "suspends" for 20 minutes to avoid cycling on semi-cloudy days. Its also got provision to switch on a supplementry heater in off-peak hours. Theres not enough sun in June and July, but the rest of the winter is fine.

Target Temp = target temp = desired temp + (desired temp - ave inside temp)/2 + (desired temp - AveOusidetemp)
This means in winter it will extract all solar energy possible, but in summer it will remain off. Averaging periods for inside/outside temperatures (1-e-t/T) = 32 and 256 hours respectively.

Main Pump On - When a pump is running (there's 3 of them), or when the tank is full or overflowing, the message appears here. If the tank is not full, then the pump must run at least once every 15 mins, or it is assumed the pump switch is stuck or it has failed.

Line Voltage below 13.8V assumes on backup battery - so shut down after 10 minutes of no AC

Downloads to the Right hand frame data of various types as set by flags - the ARMweb comes with a default web page to handle control settings, run/stop program execution, as well as a text area (txta.htm) to which all print statements are directed. The right frame has its src="txta.htm", so any print statements come here. This select button sets certain flags so that conditional print statments in the main program are displayed here. In the pictured display are comma separated variables of time, tap position, ave tap position, and pond switch voltage that can be cut and pasted into an ongoing spreadsheet, that automatically adds to a graph. Here you will see slow speeds of 2 steps/minute and tap boosts of 150 steps. In versions 1 and 2, without any visual feedback, I'd had these set at 30-60 steps/minute and then accelerating, and boosts of 1000 steps.

The ARMweb has a RTC, which I use for timing but it runs about a minute fast a day. So in here is a selector that sends the PC clock yy:mm:dd:hh:mm:ss via cgi to the program to sync the NXP2138 RTC. The time displayed under the restart from error is the RTC time.

SO the htm is here, click on this then right click and select view page scource (or save link as) to see the code and the program is here

 

Â