It's.. TankBrain!

MonteCarlo

Member


It's TankBrain!

Hi guys,

I've had a little more spare time then usual and have gotten into tinkering with electronics. So, I built myself a fishtank monitoring system and heater controller. Over time, the project had serious scope creep, but in the end, I think it came out pretty cool.

What is this thing?

Well, it started out as a heater controller. The idea was to try to keep the tank temperature a little more steady than the cheapo aquarium heaters. Then I decided to add data logging. Then I found out flow meters are pretty cheap. Then, eventually, I was limited by the memory of the microcontroller, so I had to stop.

I had two design goals:
- Maximize safety for the fish
- Look cool doing it

The system has multiple redundancies. In the photo above, you'll notice three temperature probes. Voting logic is used - if one guy is out of whack, show an error and ignore it. Otherwise, take the average. I'm going to use aquarium heaters (as opposed to heating elements) as an additional level of safety. The box can really only fail in two ways - heaters on when they should be off, or off when they should be on. If the heaters stay on, the temperature wont rise any higher than the heaters themselves are set to (the situation would be identical to just plugging them in to the wall). I'll keep the set heaters a degree or two above nominal temperature. If the heaters go off, there could be a third heater, not plugged in to TankBrain and set a degree or two below nominal temperature.

Additionally, I'm measuring the heater current. If current is flowing when it shouldn't be (because the relay in TankBrain is stuck), it will show an error. If current is not flowing when the heaters are on, show an error for a broken heater.

Errors also persist until manually cleared, so if something happens at four in the morning, I'll know.

Features:
- 3 Temperature probes
- Two 500W heater channels
- One 500W chiller channel for a home brew chiller I'll make come summer time
- Current measurement on the 2 heater channels
- Flow meter
- Data logging to non volatile memory (settings, temperature and flow data aren't lost if we lose power)
- Can also transfer data to a PC via USB if I want to make graphs or do other analysis
- Joystick for control
- OLED screen - this looks a lot better in real life than in the pictures
- 2 settable timers to remind me to clean the prefilter and filter



Here's what the main screen looks like. Time/mode info on top. Then temperature, flow and status below.

Here's another shot of the main screen with an error (in this case, because the flow meter is unplugged). Also, the circle R icon shows the right heater should be on.

Error screen - shows which errors have occurred. Also shows when its time to clean the filter.


Reset screen - allows you to clear errors and data in memory. This scrolls down,


Settings screen. Almost everything is adjustable. 16 menu items.


Temperature Screen - shows values from the three sensors, delta between them, what TankBrain thinks the current temperature is, room temperature, and some records. The numbers aren't right because I've been messing around with it for testing.

Heater screen - shows heater status, current and power. Currently reading zero because the heaters arent plugged in.


Temperature graph. Midnight on the left, vertical line at the present time. Shows a data point every 12 minutes for 24 hours.

Oops, looks like you can only attach ten images... I'll add another post tomorrow with a picture of the flow graph and a bunch of info about how it works under the hood.
 

Kribensis27

Member
This is super confusing, and I can’t pretend I understand any of this, but that’s cool.
 

SouthAmericanCichlids

Member
Kribensis27 said:
This is super confusing, and I can’t pretend I understand any of this, but that’s cool.
I completely agree, this is so cool. And useful, given heaters malfunction all the time. How long did this take you? Do you have an engineering major, programing?
 
  • Thread Starter

MonteCarlo

Member
Alright - after some Thanksgiving leftovers, I got a second wind.


Shows either 24 hours like the flow screen, or 60 days of data (2 points per day). I'm going to see what flow looks like versus time and use it to inform me when to clean the prefilter and filter.



Inside the beast. The heart of it is a clone of an Arduino Nano (the heart of which itself is an Atmel 328p microcontroller). The specs are TINY by computer standards. 16 MHz 8 bit processor. 32KB of flash to store the program (of which 2KB is used by the system). 2KB of RAM. 1KB non volatile EEPROM (read/writable). Current transformers and burden resistors for current measurement. Relays for power control. OLED Screen (128 x 64 pixels. top 16 rows always yellow or off. the rest are blue or off. looks sharp). Analog stick with push button. DC power supply. 16 bit quad channel ADC for temperature measurement. 10k thermistors for sensors. 3D printed chassis.
 

Kribensis27

Member
Hehe technology wizard go burrr
 
  • Thread Starter

MonteCarlo

Member
SouthAmericanCichlids said:
How long did this take you?
Thanks.

I'd say 200ish hours. But a lot of that was learning about various aspects of how to do it. And it took me like 4 tries to get the 3d printed chassis right.

SouthAmericanCichlids said:
Do you have an engineering major, programing?
Not exactly. PhD in chemistry. 9-5 title is "Senior Systems Engineer."

Kribensis27 said:
This is super confusing, and I can’t pretend I understand any of this, but that’s cool.
I'd be happy to explain any part of it if you're curious. I figured people would have questions.
 

AggressiveAquatics

Member
MonteCarlo said:
Alright - after some Thanksgiving leftovers, I got a second wind.

Shows either 24 hours like the flow screen, or 60 days of data (2 points per day). I'm going to see what flow looks like versus time and use it to inform me when to clean the prefilter and filter.

Inside the beast. The heart of it is a clone of an Arduino Nano (the heart of which itself is an Atmel 328p microcontroller). The specs are TINY by computer standards. 16 MHz 8 bit processor. 32KB of flash to store the program (of which 2KB is used by the system). 2KB of RAM. 1KB non volatile EEPROM (read/writable). Current transformers and burden resistors for current measurement. Relays for power control. OLED Screen (128 x 64 pixels. top 16 rows always yellow or off. the rest are blue or off. looks sharp). Analog stick with push button. DC power supply. 16 bit quad channel ADC for temperature measurement. 10k thermistors for sensors. 3D printed chassis.
If I just laugh and nod my head they will think I understand
 
  • Thread Starter

MonteCarlo

Member
Technical errata: Heaters

So, this thing is supposed to keep the tank temperature stable. On the back side there are three NEMA 5-15R receptacles (power outlets like the ones in your house (at least if youre in the US). Plug left heater into one, right heater in to the second. The box turns power to the outlets on and off, like somebody flipping a light switch. You tell it what temperature you want, and it will try to keep it there.

The control loop is 6 minutes long. There are technical reasons for using 6, instead of say 5 (related to making the graphs fit on an 128 pixel wide display and look right). However, it can't be too quick because you don't want to have them turning on and off all the time and wear out the switch (relay). How much can the temperature change in 6 minutes?

You may remember from chemistry or physics that the specific heat of water is 4184 Joules/liter-Kelvin, which is amazingly high. 1 Watt is 1 Joule per second. Tank is 75 gallons. Converting a bunch of units in to SI, blah blah. Heater is rated at 300W (I'm measuring more like 250W). In 6 minutes, a 300W heater will raise the tank temperature by 0.16 degrees F. IF no heat is lost to the environment. Real life temperature rise will be smaller. I'll use my charting thing to see how fast the temperature drops and I can measure heat loss too.
 
  • Thread Starter

MonteCarlo

Member
A few more pics, now that its daytime.


Front of the device, showing the tiny display and joystick.


Back of the device. Heaters and chiller plug in here. Also, the three temperature probes and a connector for the flowmeter.

Some plumbing. This is the flow meter. Its rated for potable water, so it should be fine for the fish. It goes on the output of the filter.

Its a neat little device. Inside, there is a paddle wheel that is turned by the water flow. On the paddle wheel, there is a magnet, and in the body, there is a coil. Every time the magnet moves by the coil, it makes a pulse of electrical current. This happens about 30-50 times a second. The microcontroller measures the time between pulses and calculates the flow.


This is a fish forum, right? Probably should show a picture of the tank. Today is water change day and the hornwort is a little out of control, but everybody is looking good.
 
  • Thread Starter

MonteCarlo

Member
Today was dress rehearsal. Things went pretty well.


Here it is, connected up to the tank.


Guppy gang, checking out the apparatus.


The rainbowfish seem completely disinterested.



And here we go - almost 24 hours of data. This is a graph of tank temperature versus time. Midnight is on the left side of the chart. Noon is in the middle. Eleven fifty something is on the far right. Vertical line is when I took the photo (about 7:30 PM) Temperature range for the day, like it says above is 80.5 to 82.83 F. Not too bad for cheap heaters, but hopefully we can do a little better. Note that the tank temperature drops at night when the heat goes down in the house, then rises in the morning.

This is the control test - TankBrain is not controlling the heaters, just watching the tank temperature. I have a few more bugs to fix tomorrow, then I'll download the data to my PC for further analysis.

Flow data printing is still buggy (the Y axis is messed up), but remarkably steady at 128 to 131 gallons per hour.
 

AquaBaby

Member
This is pretty cool. I'm curious how well it will work.

So, ball park figure, how much money do you think you have in parts? // How much do you estimate the whole "tankbrain" will cost once it's completed?

MonteCarlo said:
One 500W chiller channel for a home brew chiller I'll make come summer time
I am definitely interested in the chiller build! Do you plan to post that on Fishlore?
 
  • Thread Starter

MonteCarlo

Member
AquaBaby said:
This is pretty cool. I'm curious how well it will work.

So, ball park figure, how much money do you think you have in parts? // How much do you estimate the whole "tankbrain" will cost once it's completed?



I am definitely interested in the chiller build! Do you plan to post that on Fishlore?
So, for a lot of the stuff, things could be done a lot more inexpensively. Partly I used the materials and skills that I have on hand (like the analog joystick in my parts bin - couldve been buttons). That said, some of the stuff is also surprisingly cheap. But, if you count my time assembling it, the price would be high indeed.

(Side note - I've been entertaining a fantasy of doing a kickstarter or similar, if there was significant interest. At 100ish units, I could really bring the price down).

A few specific bits :
- I probably used $50 worth of plastic to 3D print the chassis. Partly big redos of the main body, but also sometimes 5 or 6 tries of a smaller piece to get, say, the positioning of the joystick right, or the power outlets to snap into their holes very snugly so they dont come out if someone yanks the cord).

- The microcontrollers are laughably cheap - $18 for 5 pieces off of Amazon.

- The temperature probes are dirt cheap and readily available. I went looking for something a little nicer and couldnt find anything I was happy with. If I did it again, I would consider using thermocouples, or platinum RTD's if money were no expense.

- In light of the above, I'm measuring temperature by measuring a voltage (the voltage changes with temperature because the resistance of the probe changes with temperature). I could use the built in measurement in the 3 dollar microcontroller, but it only has 10 bits of accuracy. The chip makes a reading and gives you a 10 bit number, which is between 0 and 1023. The best you'll ever do is +/- one part in 1024. This corresponds to an error of up to 0.3 degrees F. Unacceptable. I used a 16 bit ADC instead (actually, 3 of them out of four on the board). This part alone is $20 in small quantities. It makes an error of ~0.01F. There are other ways to do this.

I've spent all of the money that I will on this unit and I'll say that the cost is more than I spend on dinner most nights, but less than my most expensive night out.

AquaBaby said:
I am definitely interested in the chiller build! Do you plan to post that on Fishlore?
Absolutely. I'm not going to do until until it gets hot next year.

I think the most practical way to do it is to drill some holes in a mini fridge, but I really want to go overboard and use like a half ton compressor on a skid.
 

AquaBaby

Member
In the settings (below set time & date) it has heat or cool.

Do you manually have to choose "heat mode" or "cool mode" .... or will it choose between them what it needs to do?

MonteCarlo said:
I think the most practical way to do it is to drill some holes in a mini fridge
I actually tried this, but the fridge I used was too small (like the tiny ones that hold a six pack or so) and the return line was too thin for the distance and the water would be back to room temp by the time it returned to the tank. I tried to speed up the flow, and the little fridge didn't have time to cool it before it left the fridge. I couldn't use a larger line, as I couldn't fit enough coils inside. So basically, I was wasting electricity. LOL

I should've tried insulating the return line, but I didn't think of that until after my hubby had sealed the holes and claimed it for himself.
 
  • Thread Starter

MonteCarlo

Member
It would be easy to add an "auto" feature, but I set it up this way to be like a home thermostat - you choose heat or AC. In general, you don't want them fighting each other.
 

aquafrogg

Member
I like your funny words magic man, You could make and sell these for a pretty penny. I know a lot of people who would love this
 
  • Thread Starter

MonteCarlo

Member
I guess, more specifically:

The chiller outlet is always off when youre in heat mode.

The both heaters are always off in cool mode.

When you're in heat mode, zero, one, or two heaters will be on, depending on what it has to do to maintain temperature. I also implemented primitive wear leveling. It picks the left or the right heater to try to make sure they each run for the same amount of time, rather than making, say the right heater do all the work.

AquaBaby said:
I actually tried this, but the fridge I used was too small (like the tiny ones that hold a six pack or so) and the return line was too thin for the distance and the water would be back to room temp by the time it returned to the tank. I tried to speed up the flow, and the little fridge didn't have time to cool it before it left the fridge. I couldn't use a larger line, as I couldn't fit enough coils inside. So basically, I was wasting electricity. LOL

I should've tried insulating the return line, but I didn't think of that until after my hubby had sealed the holes and claimed it for himself.
Point taken. I think the key to making this work is good thermal transfer between the coldness of the fridge and the water in the lines. I'm hoping I can find a nice stainless steel heat exchanger, like a mini car radiator, but I think unless I can find a surplus one, it will be too expensive.

aquafrogg said:
I like your funny words magic man, You could make and sell these for a pretty penny. I know a lot of people who would love this
Thanks dude, this is the best compliment I've received in months.

If I can make my fortune in the aquarium accessories biz, that's a OK with me.
 

Dechi

Member
Really nice concept and work ! I wish I had your knowledge to build one for myself. I just bought a heater controller and have yet to start using it.

MonteCarlo said:
If the heaters stay on, the temperature wont rise any higher than the heaters themselves are set to (the situation would be identical to just plugging them in to the wall). I'll keep the set heaters a degree or two above nominal temperature.
This part leaves me wondering. I’m sure you’ve thought about it but the purpose of the heater controller is to cut power when heaters reach over their temperature settings. If one of the heaters malfunctions and gets stuck, will your device shut it off ?
 

NoahLikesFish

Member
How much did this cost to make?
 

Kribensis27

Member
Hehe brain wizard. your funny words make my brain go zzzzzz.
 

veggieshark

Member
So cool. I haven't made the time to read the arduino and the raspberry pie books I purchased a few years ago You could eventually develop this into a marketable product.
 
  • Thread Starter

MonteCarlo

Member
Dechi said:
Really nice concept and work ! I wish I had your knowledge to build one for myself. I just bought a heater controller and have yet to start using it.



This part leaves me wondering. I’m sure you’ve thought about it but the purpose of the heater controller is to cut power when heaters reach over their temperature settings. If one of the heaters malfunctions and gets stuck, will your device shut it off ?
Thanks.

So, I spent some time thinking this through. The way it works is that there are heater failures, and TankBrain failures. (I'm already wishing I came up with a better name.

Here are the failure modes I can foresee:

Heater Failures:
- Heater breaks, open circuit. Doesn't heat. Well, there are two heaters, so there is redundancy. The tank might drop a few degrees on the coldest day of winter, but the fish shouldn't freeze. "Heater On Current Low" error is displayed.
- Heater breaks, bimetal in heater is stuck on or similar failure. TankBrain's relay will shut it off. Might or might not result in an error message.

TankBrain failures:
- Relay stuck on. Tank should only go to temperature that heater is set to. Error : "Heater Off Current High". Only way the fish can get hurt is for this error, plus the bimetal sticking at the same time. Also, I suspect both sides would have to have both failures (for 4x total simultaneous failures) for the tank to really get in to the danger zone.
-Relay stuck off. The other heater should be able to keep it pretty warm for a while. "Heater On Current Low" Error.
- Box has a complete meltdown - the hardest to protect against. Worst case scenarios would be both relays on (which would still require at least one, possibly both of the heaters to be broken as well) or both relays off (in which case, the tank temperature could fall dramatically. however, if I use a third heater,not plugged in to TankBrain, set at say, 77-78F, that would save me in the event of anything other than a prolonged power outage).
 

Maxxx

Member
I'm gonna nerd out a bit with you here. I did a similar project in a thermo class in college using an Arduino and K thermo couple. For my project I was collecting data as a beverage cooled to room temp. I just had the data recorded on a computer and graphed using excel. Just out of curiosity what kind of temp probes are you using? I know for my probe I got it accurate to about .25 degree F with about one random inaccurate point with 1 reading every minute over a span of 3 hours. I just manually removed those points in my data. I'm really curious to see how the data will look over the course of a week. Comparing that to actual data based on natural habitat would be a great reference to how well we as fish keepers actually match natural habitat. I know it is difficult to even find data on one particular fish (multiple sites give different parameters) so a database with temperature and other water parameters would be an amazing tool. I know this would be a marketable device but collecting and supplying data with it would make it all the more attractive to hobbyist.
 
  • Thread Starter

MonteCarlo

Member
veggieshark said:
So cool. I haven't made the time to read the arduino and the raspberry pie books I purchased a few years ago You could eventually develop this into a marketable product.
Thanks. I strongly recommend playing around with this stuff if youre interested. The Pi is much more "computery" where as the Arduino is more like playing with electronics. The Arduino is also a lot cheaper - the Nanos mentioned above are like under $4 a piece, and if you want to get started, there are many Uno based starter kits in the sub $50 range.

One of the things Ive always liked about fishkeeping is the DIY ethic.

NoahLikesFish said:
How much did this cost to make?
Lets say more than a hundred, well less than five hundred.

Maxxx said:
I'm gonna nerd out a bit with you here. I did a similar project in a thermo class in college using an Arduino and K thermo couple. For my project I was collecting data as a beverage cooled to room temp. I just had the data recorded on a computer and graphed using excel. Just out of curiosity what kind of temp probes are you using? I know for my probe I got it accurate to about .25 degree F with about one random inaccurate point with 1 reading every minute over a span of 3 hours. I just manually removed those points in my data. I'm really curious to see how the data will look over the course of a week. Comparing that to actual data based on natural habitat would be a great reference to how well we as fish keepers actually match natural habitat. I know it is difficult to even find data on one particular fish (multiple sites give different parameters) so a database with temperature and other water parameters would be an amazing tool. I know this would be a marketable device but collecting and supplying data with it would make it all the more attractive to hobbyist.
I'll nerd back at ya, partner.

Temperature sensors are 10k thermistors. Aquarium grade ones are readily available on Amazon.

Thermistor is in a divider with a 1% 10k fixed resistor. So, one percent error here, but this would be a constant and can be tuned out. Thermistor is probably rated to a percent or two.

ADC errors are discussed above.

Each measurement is ten samples averaged together.

In light of all the above, the difference between the probes at any given time is about 0.2-0.3F between the highest and the lowest. This is displayed on the TC screen in my first post. +/- 0.15 F ain't bad.

Maxxx said:
Comparing that to actual data based on natural habitat would be a great reference to how well we as fish keepers actually match natural habitat. I know it is difficult to even find data on one particular fish (multiple sites give different parameters) so a database with temperature and other water parameters would be an amazing tool. I know this would be a marketable device but collecting and supplying data with it would make it all the more attractive to hobbyist.
So, TankBrain has it so you can set a day temp and a night temp and also when day and night start.

Does anyone know if this would be beneficial for the fish? I mean, I'm sure it depends on the body of water, but some fish must experience huge temperature swings in their native environment.
 

Pfrozen

Member
MonteCarlo said:
So, TankBrain has it so you can set a day temp and a night temp and also when day and night start.

Does anyone know if this would be beneficial for the fish? I mean, I'm sure it depends on the body of water, but some fish must experience huge temperature swings in their native environment.
That is a really cool idea and I've never heard of it being done before. It would for sure be super cool to mimic native temperature swings to see how the fish respond. Aside from that though I can see this being useful for breeding
 

Maxxx

Member
MonteCarlo said:
So, TankBrain has it so you can set a day temp and a night temp and also when day and night start.

Does anyone know if this would be beneficial for the fish? I mean, I'm sure it depends on the body of water, but some fish must experience huge temperature swings in their native environment.
That's what I was getting at with the need to collect or find data on their natural habitat. Given that the high enthalpy (water holds a lot of thermal energy) there shouldn't be a large swing in temp if it is a large body of water. Even in the summer the surface temp of a lake is warm but just diving 10ft down the temperature changes drastically because the heat doesn't get down that far and stays pretty constant year round. A smaller body of water will heat and cool more. Back to being beneficial to the fish, I think that would be really dependent on the specific species of fish but in general I don't think our understanding of temperature fluctuation in tanks has limited what we as hobbyists can keep. It would be really cool from a research standpoint to be able to run studies on different species to see if there is a difference.
 
  • Thread Starter

MonteCarlo

Member
Maxxx said:
That's what I was getting at with the need to collect or find data on their natural habitat. Given that the high enthalpy (water holds a lot of thermal energy) there shouldn't be a large swing in temp if it is a large body of water. Even in the summer the surface temp of a lake is warm but just diving 10ft down the temperature changes drastically because the heat doesn't get down that far and stays pretty constant year round. A smaller body of water will heat and cool more. Back to being beneficial to the fish, I think that would be really dependent on the specific species of fish but in general I don't think our understanding of temperature fluctuation in tanks has limited what we as hobbyists can keep. It would be really cool from a research standpoint to be able to run studies on different species to see if there is a difference.
Agreed on all counts. I like the way you phrased it - our understanding of temperature isn't really holding back the hobby, but there is so much science left to uncover,

OK, I fixed the flow data bug. Here is what the flow screen looks like:


The discontinuity in the middle is because that is when I started data collection. Looks like the flow dropped from ~130 GPH to around 125 GPH. In a day or two, I'm going to start collecting flow data the real way - every 12 hours for two months. Hopefully, I can determine how frequently the filter and prefilter should be cleaned.


Hmm, looks like TankBrain went in to a warning state overnight. I wonder why...

Oh yeah. I had set the filter and prefilter times to one day. So those both went off when they should have. Tomorrow will probably be the first day with the tank under microprocessor control.

I also got the exporting to the PC working. Here is 24 hours of flow and temperature data:

I think this is turning into a more general study. I posted a thread over in the heater forum, if anyone wants to hear me pontificate more.

Tank Thermodynamics
 

2fishinabowl

Member
This is DEFINITELY cool.

The engineer in me is fascinated and wants even more. The hobbyist in me is horrified. Haha!

How about a digital aquarium monitor/brain that continuously measures temp AND the usual ph, ammonia, nitrites, nitrates, hardness, alkalinity. Maybe even live plant magnesium, carbonate, potassium parameters etc.

I mean this is 2020 right? Analog test chemicals and strips are so old-fashioned and tedious...

I could see this all in a box with a few tank probes for just $39.95 on Amazon.

You set the parameters you want and track them in a free android/ios/Windows app. Again... 2020 not 1960.

On a side note I found an inexpensive breadboard build here.
 
  • Thread Starter

MonteCarlo

Member
2fishinabowl said:
This is DEFINITELY cool.

The engineer in me is fascinated and wants even more. The hobbyist in me is horrified. Haha!

How about a digital aquarium monitor/brain that continuously measures temp AND the usual ph, ammonia, nitrites, nitrates, hardness, alkalinity. Maybe even live plant magnesium, carbonate, potassium parameters etc.

I mean this is 2020 right? Analog test chemicals and strips are so old-fashioned and tedious...

I could see this all in a box with a few tank probes for just $39.95 on Amazon.

You set the parameters you want and track them in a free android/ios/Windows app. Again... 2020 not 1960.

On a side note I found an inexpensive breadboard build here.
Thanks.

I've thought about the chemical monitoring as well. Easier said than done. pH would be the "easiest", but that is still pretty tough (a transconductance amplifier that potentially has to work over 14 orders of magnitude - sign me up).

On the subject of price - I'm seriously considering trying to sell this thing, but I fear the price will just be too high. Think more like $239.95.

The DIY link you posted is neat too, but even that guy is wildly optimistic about price. For example, he is using a DS3231 - the same clock chip that I am. It's a high accuracy, temperature stabilized clock (coincidentally, that's how TankBrain knows what the room temperature is - you can read it out of the clock chip). That costs $14 in small quantities. He probably has more like $50 of parts. Also, since I'm using relays for control, I need a 5V DC power supply thats a little beefier than a wall wart. There's another 15 bucks. A nice metal case for it will run probably ~$25-30 at quantities of 100 or so. Plastic is cheaper, but making the molds is a five figure one time charge. Etc etc.
 

2fishinabowl

Member
MonteCarlo said:
Thanks.

I've thought about the chemical monitoring as well. Easier said than done. pH would be the "easiest", but that is still pretty tough (a transconductance amplifier that potentially has to work over 14 orders of magnitude - sign me up).

On the subject of price - I'm seriously considering trying to sell this thing, but I fear the price will just be too high. Think more like $239.95.

The DIY link you posted is neat too, but even that guy is wildly optimistic about price. For example, he is using a DS3231 - the same clock chip that I am. It's a high accuracy, temperature stabilized clock (coincidentally, that's how TankBrain knows what the room temperature is - you can read it out of the clock chip). That costs $14 in small quantities. He probably has more like $50 of parts. Also, since I'm using relays for control, I need a 5V DC power supply thats a little beefier than a wall wart. There's another 15 bucks. A nice metal case for it will run probably ~$25-30 at quantities of 100 or so. Plastic is cheaper, but making the molds is a five figure one time charge. Etc etc.
Yeah and then there's calibration for all the parameters. Maybe an FPGA design would cut down on components needed to measure temp and chemistry. That price point is tough. If something like this hit the market at say 50 dollars I bet lots of people would want one. Just sayin...
 

AvalancheDave

Member
MonteCarlo said:
I had two design goals:
- Maximize safety for the fish
- Look cool doing it

The system has multiple redundancies. In the photo above, you'll notice three temperature probes. Voting logic is used - if one guy is out of whack, show an error and ignore it. Otherwise, take the average.
I didn't see this thread until now but I've been dreaming for some time about a heater controller with 3 temperature probes that uses voting logic like rebreather O2 sensors. I looked into industrial temperature controllers but didn't see any with 3 sensors.

I would also like something with PID temperature instead of on/off control.

2fishinabowl said:
How about a digital aquarium monitor/brain that continuously measures temp AND the usual ph, ammonia, nitrites, nitrates, hardness, alkalinity. Maybe even live plant magnesium, carbonate, potassium parameters etc.

I mean this is 2020 right? Analog test chemicals and strips are so old-fashioned and tedious...

I could see this all in a box with a few tank probes for just $39.95 on Amazon.
Ammonia can be measured colorimetrically the way Seneye does it. Some people doubt its accuracy though. Nitrate and especially nitrite aren't coming anytime soon though. Nitrate and nitrite ISE probes are $300-2,000 and typically require calibration every 1-2 hours with three calibration solutions a decade apart each (10 mg/L, 100 mg/L, and 1,000 mg/L, for example). I'm not sure how you can get around that.

I think only one obscure company make nitrite ISEs.

Big water testing equipment companies like Hach have automated testers but they're basically just robots that automate the calibration of the ISE probes. The other approach is to run conventional colorimetric tests and just have a robot mix the reagents. Some of this technology has recently made it to the reef world. This is probably the only way we're going to see automated nitrite and nitrate testing at a semi-affordable price.
 
  • Thread Starter

MonteCarlo

Member
2fishinabowl said:
Yeah and then there's calibration for all the parameters. Maybe an FPGA design would cut down on components needed to measure temp and chemistry. That price point is tough. If something like this hit the market at say 50 dollars I bet lots of people would want one. Just sayin...
Not sure an FPGA would help. The micro is under $3 in unit quantities. If I do this, it has to be as a "luxury" product. I can't compete with Tetra and Marineland and the Walmarts of the world.

AvalancheDave spelled out the issues with chemical detection. Not easy. I use a similar product from Honeywell at work for hyrdride and fluoride gas detection. It uses a chemical coated tape and then a little spectrometer to measure color change. Nice units, but a couple grand a pop, plus the tape is a few hundred and has a short shelf life unless kept sealed and refrigerated.
AvalancheDave said:
I didn't see this thread until now but I've been dreaming for some time about a heater controller with 3 temperature probes that uses voting logic like rebreather O2 sensors. I looked into industrial temperature controllers but didn't see any with 3 sensors.

I would also like something with PID temperature instead of on/off control.
PID with IGBT's/Thyristors/FET's would be the way to do it. I would be tempted to rectify the line voltage and do a PWM'ed DC at say 50 kHz so it doesn't make any acoustic noise.

When I ran the numbers though, it didn't seem worth it. A six minute control loop with bang-bang control gets me to about a 10th of a degree. How much better does it need to be?
 
  • Thread Starter

MonteCarlo

Member
More Data: TankBrain vs Heaters

I go into some of the gory details in the thermodynamics thread, but long story short, I need to make some software tweaks, but the preliminary results are very promising:
 
  • Thread Starter

MonteCarlo

Member
Today's results are a mixed bag. On the one hand, I tried testing the new revision of the firmware and it was a dismal failure. I was overly ambitious, added a bunch of new stuff and something doesnt work right. I'm also at a point where I'm tethered to the tank for testing and for some reason, the Arduino IDE is acting differently on the junk laptop I'm using. The code BARELY fits and its a few hundred bytes bigger when I compile it on that machine for some reason. I think it will be easier to add some more connectors to the wiring so I can take TankBrain up to my normal PC than figure out why the laptop is acting funky.

On the other hand, the flow meter is performing admirably. I did a water change and cleaned the prefilter for the first time in about 19 days. Flow rate went from 106 gallons per hour before hand to 131 gallons per hour afterward. This will certainly be useful, and once I get TankBrain properly configured, I'll do a study on flows like I did with heat transfer.
 
  • Thread Starter

MonteCarlo

Member
No major updates for today. Running with the new heater control algorithm. I can't tell if it's significantly better until I get the data onto my main PC tomorrow evening, but at least it isn't significantly worse. Full data set expected tomorrow.

Also, I bought an in system programmer, so I can program the microcontroler without using USB. Best $5 I ever spent. Much faster, and I don't need 1.5 KB for the boot loader. On an Arduino, this is TONS of free space.

I'm also thinking about turning this into a product, as I hinted at above, so I'm thinking about what to do with my new found kilobyte and a half.

One of the things I feel I need to add is the ability to switch between degrees C and degrees F. Right now, its degrees F only. I also need to take up a little of the space to store a few more values in EEPROM. For example, if TankBrain looses power, it forgets where it is for recording data for filter flow. Unacceptable when it can hold 60 days worth of flow data. I also should probably add code to not show the flow information if a flow meter is not installed. Anybody have interesting ideas for small additions?
 

Pfrozen

Member
you could include a picture on the display and you'd have like.... 6 whole pixels to work with. don't squander your resources people love graphixx

lol jk, I would just make it power outage safe. that stuff is important. can you do that with 1.5 kb?

edit: most of this makes very little sense to me heh
 
  • Thread Starter

MonteCarlo

Member
Pfrozen said:
you could include a picture on the display and you'd have like.... 6 whole pixels to work with. don't squander your resources people love graphixx

lol jk, I would just make it power outage safe. that stuff is important. can you do that with 1.5 kb?

edit: most of this makes very little sense to me heh
Thanks. Yeah, to really put it to scale, the screen is 128x64 pixels, monochrome. 128 x 64 x 1/8 (because each pixel is only one bit or an eighth of a byte) is 1024 bytes or a whole KB.

Right now, its pretty resistant to power outages. The clock chip has a little coin cell to power it (good for 5+ years), so it will keep track of the time even if the power is lost. Or nag you on startup to set the time if the battery is dead, since the clock chip is smart enough to know if it lost power. Most things that are important are stored in EEPROM (persists even if power is lost).

Lets look at how quickly 1KB gets used up. In the C dialect for Ardunio, a character takes up 1 byte, an integer (-32 thousand to 32 thousand, approximately) is 2 bytes, a float (number with a decimal point) is 4 bytes.

120 data points for the temperature log (floats)
120 data points for the flow log (also floats)
Day temperature, day start minutes day start hours, all integers. Same for night
Values for error and warning levels for flow and temperature, 4 floats total.
Current limits are 2 floats (but I'm going to rewrite this section - no need to have separate limits for the on and off state).
High and low temperature records - 2 more floats.
Timers for filter and prefilter clean - 2 more ints.
Default values for filter and prefilter timers (so that when you go to reset it, it remembers you usually use a 30 day timer, for example). - 2 more ints.
Operation mode - heat, cool or force on (for testing) - 1 character/byte.

If my math is correct, I have six bytes of EEPROM left. Not a lot.
==============
Today's data will be delayed until tomorrow. I had a bug in the code, which thankfully I discovered before I went to bed.

On a completely different note, I was looking at gift suggestions on Amazon, and I stumbled across the product that the OLED screens I buy surplus were originally used for:

Amazon Link

That answers that question. Portrait mode, not landscape, but clearly the same part.
 
  • Thread Starter

MonteCarlo

Member
Latest data set. Improved control algorithm:

Green is the old algorithm, yellow is the new, red is just the heaters plugged in to the wall. Ignore the offset - I bumped the tank temp up a bit. The two look pretty similar on the graph, although yellow looks more random and less "overshooty". Lets look at the standard deviations:

TankBrain 1: 0.075 F
TankBrain 2: 0.066 F
Just Heaters: 0.385 F

and just for fun:
Air: 2.89 F

Man, the house gets cold at night. So, I gained a small improvement in stability, but also cut down the number of times the relays opened and closed. In retrospect, I should have had the computer track that. Oh well. Anyway, it's a net win.

Well, that's about all I have planned on this topic. I have a simple calorimetry experiment I may do next water change, but that's for the thermo thread. I'm still toying with the idea of turning this into a product, so someday I may be back, asking for beta testers (maybe even Betta testers) or trying to shill my kickstarter. Thanks for listening.
 
  • Thread Starter

MonteCarlo

Member
Alright, I lied. I can't get this thing out of my head. Further progress...

I made some tweaks to the temperature measuring circuit to reduce noise:


Looks like a small, low series resistance capacitor helps a bit. The values without the cap (blue) are also pretty good in the noise department since the software averages 10x data points before it reports a value.

I'm also playing around with a new CAD program and an awesome plug in to work with sheet metal. Here is an example (in no way what TankBrain will look like):

A box!

And...:


Here's what it looks like unfolded. This can be laser cut, then folded up to make a chassis.

I'm gonna do this guys...
 

Most photos, videos and links are disabled if you are not logged in.

Log in or register to view



Top Bottom