Instructables

Topper

This is the beginning of a project I've been wanting to do for a while now. I'm just learning microcontrollers and electronics, so anyone if there is anyone out there who notices me doing something stupid, please let me know. I have a 12-gallon Nano Cube reef aquarium. I want to automate as much of the maintenance as I can. I'm going to start with adding top-off water. This is Topper v1.0 and like any vX.0 you can count on it having problems.

Now I know some of you are probably wondering why I don't write this up as an instructable. Well, that is on my list, but it has a ways to go before its ready. I mean, take a look at it! Isn't that the ugliest thing you've ever seen?

When the whole thing is finished and prettied up I'll make an instructable out of it. Eventually I'll want to switch to an AVR microcontroller because of the cost. But the Parallax Basic Stamp is just so much easier for quick and dirty programming.

Here is the initial controller program.

'---------------------------------------------------------------
' FloatSwitchTest.bs2
' First attempt to control the top off pump with the Stamp

' {$STAMP BS2}
' {$PBASIC 2.5}

DO
IF (IN15 = 0) THEN 'Reads float switch
HIGH 14 'Turns on pump
HIGH 6 'Turns on LED
ELSE
LOW 14 'Turns off pump
LOW 6 'Turns off LED
ENDIF
PAUSE 1000 'One second pause
LOOP
'----------------------------------------------------------------

This is just to get things started, but already its nice not having to top it off every day and even at that, the swing in salinity was more than I was happy with.

The pump is a Tom Aquarium Products AW-20. At 3.5 gph and a 30" head, with nearly that from top off water to tank and a "one way valve" I wasn't sure how often it would come on or how long it would run at a time. So far, its been running 3-4 times a day for 35 - 40 seconds at a shot.

I've started adding Kent Marine Superbuffer-dKH to the top off watch. I want to keep it at about 10 dKH.

Anyone looking closely at the photo will notice an IC not listed on the circuit diagram. Its a DS1302 real-time clock and microcontroller isn't currently using it. Next up is connecting that and a 16x2 LCD display to show the time and track how long the pump runs.

All comments are welcome, from "I'm curious why you..." to "ARE YOU INSANE?!?!".

Picture of Topper
topper1.0.gif
GlobalVillageIdiot (author) 6 years ago
Here is the second installment of this project. I've connected the DS1302 real time clock and an LCD display. I want to track how long the pump has been pumping for several reasons. I'm going to want the uC to make predictions about how long the pump should run and if it goes over that, it'll know there is a problem. Second, I want to add a second pump. Right now the top off water has Kent Marine Superbuffer-dKH and iodine. The second top off tank will include calcium, strontium, and all the other additives. With trial and error I've found I can put the additives in two separate groups but if I mix some of these together they react and a white powder (probably calcium carbonate) precipitates out of the mix. Once diluted in the tank they're ok, but in more concentrated form, they react. So I'll have it pump from one tank first then the next time it tops off it'll pump from the second tank. That way it'll handle both top off water and additives. This is a cheap 16x2 LCD display with a +5v RS232 connection. The 3 pins on it are 5v, ground and RX, which is connected to pin 10. The DS1302 uses a small cylinder shaped watch crystal and 3 pins connected to the uC using pins 0-2. After looking at the first message I realize that the forum editor doesn't handle white space very well so I'm taking the listing from the stamp editor. We'll see if this works better.
DS1302.giftopper2.gif
Have the relay or transistor turn on both pumps at once and put the outlet from the seperate tanks ant opposite ends of the tank.
Well, the picture of the program listing worked even more poorly than the text in the first message. For anyone interested, here it is:

'***************************************************************************
'* Title: Topper v2.0 *
'* Description: Top off controller with LCD display for time and total *
'* accumulated seconds the pump has run. *
'* DS1302 routines by Jeff A Martin *
'***************************************************************************

' {$STAMP BS2}
' {$PBASIC 2.5}

DATA (49)
RTCCmd VAR Byte
Clk CON 0
Dta CON 1
RTCReset CON 2
Temp VAR Byte
Seconds VAR Byte
Minutes VAR Byte
Hours VAR Byte
Date VAR Byte
Month VAR Byte
Year VAR Byte
I VAR Byte
FS1 VAR Bit
Pump1 VAR Bit
PumpTotal VAR Word
PumpCurrent VAR Byte

'Define Pin 15 as FloatSwitch
INPUT 15

'Define Constants
SecReg CON %00000
MinReg CON %00001
HrsReg CON %00010
DateReg CON %00011
MonReg CON %00100
YrReg CON %00110
CtrlReg CON %00111
BrstReg CON %11111
DIRS = %0000000000111111
OUTS = %0000000000000000

' Initialize LCD

SEROUT 10, 396, [27, 67] 'Clear
PAUSE 150
SEROUT 10, 396, [27, 98] 'Backlight off

' Clear Write Protect bit in control register

Temp = $10
RTCCmd = CtrlReg
GOSUB WriteRTC

Temp = $07
RTCCmd = YrReg
GOSUB WriteRTC

Temp = $12
RTCCmd = MonReg
GOSUB WriteRTC

Temp = $29
RTCCmd = DateReg
GOSUB WriteRTC

Temp = $12
RTCCmd = HrsReg
GOSUB WriteRTC

Temp = $30
RTCCmd = MinReg
GOSUB WriteRTC

Temp = $00
RTCCmd = SecReg
GOSUB WriteRTC

Temp = $80
RTCCmd = CtrlReg
GOSUB WriteRTC

DO
GOSUB ReadRTCBurst
GOSUB PrintTime
GOSUB GetFS1Status
' DEBUG HOME, BIN Pump1, BIN FS1
IF ( Pump1 = 0 AND FS1 = 0 AND Seconds = 0 ) THEN
GOSUB PumpOn
ELSEIF ( Pump1 = 1 AND FS1 = 1 ) THEN
GOSUB PumpOff
ELSEIF (Pump1 = 1 AND FS1 = 0 ) THEN
PumpCurrent = Seconds.HIGHNIB * 10 + Seconds.LOWNIB
ENDIF
GOSUB PrintPumpStatus
LOOP

PrintTime:
'Print 24-hour time format on LCD display
SEROUT 10, 396, [27, 72] 'Home
SEROUT 10, 396, [HEX2 Hours,":", HEX2 Minutes,":", HEX2 Seconds, " "]
RETURN

GetFS1Status:
'Read FloatSwitch1
FS1 = IN15
IF (FS1 = 1 ) THEN
LOW 14
ELSE
HIGH 14
ENDIF
RETURN

PrintPumpStatus:
'Print FloatSwitch1 status on LCD display
SEROUT 10, 396, [27, 76, 0, 1]
IF Pump1 = 1 THEN
SEROUT 10, 396, ["Pump ON ", DEC PumpTotal + PumpCurrent, "sec "]
ELSE
SEROUT 10, 396, ["Pump OFF ", DEC PumpTotal + PumpCurrent, "sec "]
ENDIF
RETURN

PumpOn:
Pump1 = 1
HIGH 6 'Turn Pump1 on
RETURN

PumpOff:
Pump1 = 0
LOW 6 'Turn Pump1 off
PumpTotal = Seconds.HIGHNIB * 10 + Seconds.LOWNIB 'Update PumpTotal
PumpCurrent = 0 'Reset PumpCurrent
RETURN

WriteRTC:
'Write to DS1202 RTC
HIGH RTCReset
SHIFTOUT Dta, Clk, LSBFIRST, [%0\1,RTCCmd\5,%10\2,Temp]
LOW RTCReset
RETURN

ReadRTCBurst:
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours,Date,Month,Year,Year]
LOW RTCReset
RETURN
No need for a microcontroller, just a simple circuit... Basically a simple single transistor circuit with two contacts in the water, like so, the two wire contacts are placed at the ideal level, thr circle with P in it refers to the top up pump and the top Led glows when working, the lower led is there for discharge purposes and to show that the circuit is on...
fishtank cicuit.bmp
Just a few quick questions about your design. First, what transistor would you use to switch on and off the AC pump? Second, how would you prevent the wire contacts from desolving in the salt water and damaging or killing the corals (coral are very sensitive to copper)? Also, when I get the second top off tank set up, how would it switch between them?
Maybe use different metal for the contacts, I'm not sure, I don't know alot about what coral are sensitive to, The circle with the P in it was reffering to the pump motor or if needed a relay.
So what would be the best way to switch between the 2 tanks and control how much is pumped from each?
You mean two fishtanks that are both needing topped up by one circuit?
No, one aquarium but 2 tanks of top-off water with additives. >>Second, I want to add a second pump. Right now >>the top off water has Kent Marine Superbuffer-dKH >>and iodine. The second top off tank will include >>calcium, strontium, and all the other additives. >>With trial and error I've found I can put the >>additives in two separate groups but if I mix >>some of these together...
NachoMahma7 years ago
. Great idea. For level control, a uC is over-kill, but it will make it a lot easier to add control for salinity, temp, lighting, &c, later on. . Why are you having to add water to a 12 gallon tank 3-4 times a day? I used to keep 10-50 gallon fresh- and salt-water tanks and don't remember ever having to top off a tank that often. Every 3-4 days, maybe. . As for over-fill protection, only let the pump run every X hours|days, for Y secs/filling, and for Z seconds/day|week|month. More reliable than adding extra switches or relays and should prevent big changes in salinity, also. . Keep us posted on your progress.
GlobalVillageIdiot (author)  NachoMahma7 years ago
Thanks for the words of encouragement. I wasn't topping off 3-4 times a day. I was doing it once a day (unless I forgot and missed a day). As a result, salinity was swinging from 1.023 up to 1.025 or more. I doubt marine fish would notice the difference and with fresh water fish it isn't an issue at all, but coral is a lot fussier. The uC has been topping off 3-4 times a day. As a result, the SG has been pegged solidly at 1.023 and unlike me, it never forgets. When I was topping off manually I would notice the polyps extending less in the evening. This is what would usually remind me to check. Just over the couple of weeks I've been using the new setup I've noticed a difference. Polyps stay extended all day, and their color is getting better. Corals like stability. I looked at timers for the pump. Even the digital ones can only be set in increments of 1 minute (the mechanical ones, its 15 minute increments). With the uC the pump is running for 25-40 seconds at a shot and some of the cheaper AVR uCs are only a couple bucks each. I always enjoy learning new things and figuring out how to make things work. The more of a challenge, the better, so I'm getting a lot of mileage out of learning uCs. After I'm finished with the aquarium I have other projects in mind, like hydroponics.
hmmmm. I guess I'm not really explaining the project very well. That's something I need to work on. The level of the water in the aquarium isn't really that important. It's mostly just an indicator of how much water has evaporated out of it and how much has to be put back in to keep the salinity at a constant level. There are ways of measuring the salinity directly and adding water based on that, but I just thought a $4 float switch would be easier and cheaper than an $60. One of my first ideas was something like this one, but it would need a float valve to close the line, otherwise salt will migrate into the fresh water container, lowering the salinity of the tank.
zachninme7 years ago
Last year, I set up something to water my xmas tree from an external water bottle, it used only phsyics :P Air pressure & the like. Heres a quick sketch: The green tube is always below the water level of the bottle, and the red is always above it. If the red is above the basin's water level, air can get in and water will run through the green tube. However, if it is submerged, air can't get in, and no water will drain through the green tube because of air pressure. (excuse my terrible terrible drawing, laugh if you'd like)
guyfrom7up7 years ago
you could get rid of the whole micro controller part, just have a floater that's a normally open switch, and when it gets high enough it makes contact, turning on a relay, turning on the pump. Just use the floater as a 1st class lever so that the contacts are out of the water.
GlobalVillageIdiot (author)  guyfrom7up7 years ago
Defiantly a simpler solution and often simpler is better. But this idea grew out of incidents that have killed a number of reef tanks over the years. What happen can is that the relay jams. Its just annoyance if it jams in the 'off' position, but if it jams in the 'on' position the pump empties all the top off water into the tank. The salinity dropped too far, too fast, which kills some or all of the coral and inverts and the resulting ammonia spike from the decaying material takes the rest. Then after soaking the carpet, the pump burns out from running empty. All in all, not a fun day. Right now, there isn't anything in v1.0 to preventing that happening to me, but future additions will include a second float switch, upside down and higher up in the tank, which will alert the microcontroller to an impending overflow, a back-up relay and I'll program the controller estimate the level in the tank based on the time the pump has been running, so that even if everything looks ok, but the pump has been running too long, the controller can turn it off (possibly shutting off both the main and back-up relay) and sounding an alarm to get me to take a look (or get my wife to call me). In a far future version, the controller, running a small, internet connected server could send a text message to my phone and I could check in on a webcam to see what is going on. That is actually possible with current technology, but right now out of my league! Topper is just the first step.