PDA

View Full Version : DIY Controller - lots of features - reasonable to build


mprygh
11/03/2011, 05:36 PM
I have a 240 gallon system, currently with a Reef Angel controller.
I chose that because it is the only open source one out there.
A good controller, cheap, and has quite a few extensions, but it
really did not fully satisfy my needs.
Plus I wanted to build one from scratch for fun.

There are a lot of good threads on reef controllers here.
Mine is a bit different in that a key goal is to be easy to build.
So a fair bit of soldering, but nothing complex, no need for a schematic,
and no custom PCB.

High level view of features


Arduino based easily progammable micro-controller
Controls LED drivers, for programmable color, plus smooth dawn/dusk transitions.
Handles automatic water top off
Handles automatic salt water change
Timer controls for alkalinity and calcium dosers, plus turf scrubber and other equipment.
Handles house-water-heater based heating system
Handles chiller
Audio alarm and self diagnostics
Network interface, with automatic email status
Logs data and status
Less than $300 cost
Reasonable to hand solder on proto board with no schematics



Hardware feature list:


Uses Arduino Mega 2560 board as basis
Uses Arduino Network shield
8 buffered PWM/Standard 5V outputs
8 open collector 500mA sync outputs 0-12V
12 standard 110V, 10A relays, buffered at relay
4 high power 110V, 30A relays
3 temperature sensors
Special sump e-tape water level measurement, to ⅛ inch.
3 standard float switches
Alarm buzzer
Small keypad and display near main tank.
External real time clock with battery backup
256Kbit EEPROM for data log storage



Following (slowly) will be notes on each major section.
I am about half way done with the build, waiting for a few parts.

mprygh
11/03/2011, 05:39 PM
I2C Real Time Clock and EEPROM

The real time clock restores time in case of power failure or other reset.
The EEPROM logs data and status, and keeps it in case of the same power/reset issue.
Both of these communicate through standard I2C.
The I2C pins need a 1K pullup on each.
Connection:
Arduino[21] = SCL RTC-4 EE-6 SCL 1K pullup
Arduino[20] = SDA RTC-5 EE-5 SDA 1K pullup

Real Time Clock
This uses a DS1307 real time clock chip.
http://www.sparkfun.com/products/99
Pin 1 = VCC = 5V
Pin 2 = GND
SQW unused

EEPROM
This uses an AT24C256 2 wire serail 256Kbit eeprom chip.
Wire pin 4 to gnd, 8 to vcc, and connect I2C.
Leave A0, A1, WP floating.
Internal will pull all of them to 0, which is adr00 (0x50), no write protect.

mprygh
11/03/2011, 05:39 PM
Temperature Sensors
There are three sensor ports.
One for sump, one for main tank, and one for special water heater section.

This uses a DS18B20 digital temp chip
Pin 1 = GND
Pin 2 = Signal : 1-wire interface
Pin 2 = VCC

Pullup required on sensor interface : 4.7K to VCC

Arduino[48] = Temp sensor 0
Arduino[50] = Temp sensor 1
Arduino[52] = Temp sensor 2

They could all be tied to a single wire, since they have unique addresses.
But it is trivial to connect each separately, and it improves reliability due to lower capacitance.
Plus, makes reading them simpler and faster.

mprygh
11/03/2011, 05:40 PM
Standard Relays
Standard Relays are 110V, < 5A draw, normal plugs.
Instead of wiring up all the transistors and relays, simply buy the pre-made sets.
Use this handy board. It is even optically isolated, so you are protected from the 110V.
http://www.futurlec.com/Opto_Relay_4.shtml
Buy 3 boards, so 12 total relays.
Each has a simple 10 pin ribbon cable connector.

mprygh
11/03/2011, 05:42 PM
External and high power Relays
High Power Relays are 110V, 30A. These use a igh drive coil.
External are normal 10A, but also require a high drive line for coil.
The plan is to use a Darlington pair to drive them.
A ULN2800A array is a convinient package. It includes 8, and has the appropriate pullups and clamps all built in. One side of the relay coil will be connected to 12VDC. The other side is connected to the darlignton output.
The darlington input connects to micro-controller. A high 5V from micro-controller will drive the output low.

High Power relays

Main LED power supply Arduino[23] DLG1 p1-p18
Standard 300W Heater Arduino[25] DLG2 p2-p17
Water heater pump - A Arduino[27] DLG3 p3-p16
Water heater pump - B Arduino[29] DLG4 p4-p15


External 12V relays include

Fans on Display Tank LEDs Arduino[31] DLG5 p5-p14
Sump cooler fans Arduino[33] DLG6 p6-p13
Extra Arduino[35] DLG7 p7-p12
Extra Arduino[37] DLG8 p8-p11

mprygh
11/03/2011, 05:43 PM
Buffered PWM Pins / Buzzer : HCT244


Start at PWM 2, to avoid TX/RX for future use, since they share PWM[0], PWM[1].

LED PWM:

Arduino[7] = PWM[7] HCT244.1 p2 - p18 Conn-Grey : Red LEDs
Arduino[6] = PWM[6] HCT244.2 p4 - p16 Conn-Brown : Royal Blue LEDs
Arduino[5] = PWM[5] HCT244.3 p6 - p14 Conn-Green : XPG CW LEDs
Arduino[4] = PWM[4] HCT244.4 p8 - p12 Conn-Red : NW/BL LEDs


MISC:

Arduino[3] = ---- HCT244.5 p11 - p9 Buzzer


For HCT244
Connect pin 1, 19, 10 to GND
Connect pin 20 to VCC
Bypass cap between pin 10 and pin 20

mprygh
11/03/2011, 05:45 PM
Numeric Keypad
This is used for lighting control, for feeding modes, and misc setup.
Uses a simple ACT-07-30009-000 keyboard.
Numbers 0-9, up/down/clear/help/enter/2nd.


The keypad uses a simple 4x4 matrix, so needs 8 I/O pins.
This uses the analog input pins as digital, 0 to 7.
Could be standard IO of course, but worked well on PCB layout.

Unfortunately, I only had a 10 connector cable.
Note that 10 pin cable connector is centered, 2 extra wires, so first black and last red wire are unconnected.
Keypad connection

Arduino[54+7] = ANLG[7] = Second Black Wire = Keypad Pin 1
Arduino[54+6] = ANLG[6] = White Wire = Keypad Pin 2
Arduino[54+5] = ANLG[5] = GreyWire = Keypad Pin 3
Arduino[54+4] = ANLG[4] = Brown Wire = Keypad Pin 4
Arduino[54+3] = ANLG[3] = Blue Wire = Keypad Pin 5
Arduino[54+2] = ANLG[2] = Green Wire = Keypad Pin 6
Arduino[54+1] = ANLG[1] = Yellow Wire = Keypad Pin 7
Arduino[54+0] = ANLG[0] = Orange Wire = Keypad Pin 8


// The +54 is the odd software offset to get to analog-in as digital pin set

mprygh
11/03/2011, 05:46 PM
Standard inputs with pullups
These 5 inputs have simple 2 pin headers.
One side is ground.
The other side is an Arduino pin, with a 3K pullup.

Connections

Arduino[22] = Input 1
Arduino[24] = Input 2
Arduino[26] = Input 3
Arduino[28] = Input 4
Arduino[30] = Input 5

mprygh
11/03/2011, 05:47 PM
That is all I have done so far.
Pictures and more to follow.

dbmet
11/11/2011, 08:14 PM
Sounds Cool..Wish I had the time to do something like this..

Let me know when you sell the Reef Angel..Hehe

mprygh
11/12/2011, 12:15 AM
Sounds Cool..Wish I had the time to do something like this..
Honestly - I wish I had time for it as well. :headwally:
But getting there.


Let me know when you sell the Reef Angel..Hehe
Not like they are expensive brand new.
But I plan to keep it for backup.

mprygh
11/12/2011, 12:20 AM
Display
Used a 20 character x 2 line VFD display.
Available from Adafruit. Item 20T202DA2JA
Nice because of the bright VFD display.
But extra bonus is the simple 3 wires needed for SPI interface, and that
adafruit provides simple ready to run display code for the arduino.

Does not use the normal SPI interface. Reserved that for Ethernet.
This just uses 3 standard IO pins. Uses some of the unused PWM pins.
Arduino[13] = Conn 3 = SIO
Arduino[12] = Conn 4 = STB
Arduino[11] = Conn 5 = SCK

mprygh
11/12/2011, 12:27 AM
Quick board pictures.

I am a bit stalled waiting for parts, so took some pics.
Only about 20 more wires to go, so almost done.

perpetual98
11/14/2011, 01:42 PM
Nice parts list. I'm just doing initial research into messing around with Arduino and have more basic requirements than you. Would the board you listed be able to support one of those touch-screen displays?

What I'm trying to accomplish is:

Temperature monitoring/control
Topoff control (via float-switch/relayed 120v for solenoid)
Lighting control.

I figure I'd need a half dozen or so relayed 120v outlets, a temperature probe/circuit. The topoff float switch should be easy enough to wire in.

mprygh
11/14/2011, 04:27 PM
Nice parts list. I'm just doing initial research into messing around with Arduino and have more basic requirements than you. Would the board you listed be able to support one of those touch-screen displays?

What I'm trying to accomplish is:

Temperature monitoring/control
Topoff control (via float-switch/relayed 120v for solenoid)
Lighting control.

I figure I'd need a half dozen or so relayed 120v outlets, a temperature probe/circuit. The topoff float switch should be easy enough to wire in.
Thanks.

That Arduino mega board can definitely support many touch screen displays.
It has a ton of programmable I/O, plus 4 serial ports.
A bigger concern is drivers. Unless you want to do all the coding yourself,
make sure that the display + screen has some sort of support already.


You also may want to rethink the display.
I was originally thinking of doing a big fancy display like that as well.
I decided instead to go with a web based approach, using the network card.
In theory, it is more flexible, plus can be accessed remotely.
But hard to say. I am not advocating that strategy, just think about it.

The fancy screen I was considering was this one:
http://www.adafruit.com/products/376
It simply plugs in, and includes software.
Although arduino-mega support is weak.

perpetual98
11/14/2011, 07:22 PM
The fancy screen I was considering was this one:
http://www.adafruit.com/products/376
It simply plugs in, and includes software.
Although arduino-mega support is weak.

That's the exact board I was looking at. :spin1:

I wasn't sure if I was going to go with a Mega, or stick with one of the other boards. Just getting my feet wet, was reading a bunch about the Uno, but this is still more in the "nice dream" stage than gathering a parts list yet.

mprygh
11/14/2011, 07:43 PM
Always fun to dream and plan.
Yes, sounds like an Uno might be better.
Note that you can always use an I2C based I/O expander later if you
run out of pins.

waverz
12/06/2011, 05:52 PM
Awesome, I'm basically doing the same thing for a school project. So far I have a running clock and a partially working temp probe.

Planning on ordering the relays and other components soon. I am a total newb when it comes to programming so it's a bit of a challenge.

Great thread!

mprygh
12/06/2011, 06:02 PM
Awesome, I'm basically doing the same thing for a school project. So far I have a running clock and a partially working temp probe.

Planning on ordering the relays and other components soon. I am a total newb when it comes to programming so it's a bit of a challenge.

Great thread!

Quite a school project! Best of luck.
If you have some big problems, feel free to post.
Although since it is a school project, I guess you can't really ask
for code too much.

mprygh
12/06/2011, 06:05 PM
Quick update:
I finally received my relays last week. Took forever. Shipped from Hong Kong.
I am not sure futurlec is the best vendor.
So I am working on connecting those up.

Also, a fair bit of the network stuff is done.
Time update from internet NTP is reliable, and updates RTC clock module.
Data loging push out to internet is looking good.

You can see some of it here.
(Measures tank temp, one unconected, air temp, and water top off)
https://pachube.com/feeds/38937

waverz
12/06/2011, 06:13 PM
Quite a school project! Best of luck.
If you have some big problems, feel free to post.
Although since it is a school project, I guess you can't really ask
for code too much.

LOL, it's a community college. Anything goes! :celeb1:

waverz
12/06/2011, 06:13 PM
Quick update:
I finally received my relays last week. Took forever. Shipped from Hong Kong.
I am not sure futurlec is the best vendor.
So I am working on connecting those up.

Also, a fair bit of the network stuff is done.
Time update from internet NTP is reliable, and updates RTC clock module.
Data loging push out to internet is looking good.

You can see some of it here.
(Measures tank temp, one unconected, air temp, and water top off)
https://pachube.com/feeds/38937

Cool man! I was leaning in the direction of pachube myself. What a great service!

mprygh
12/14/2011, 10:59 PM
Main bank of 8 relays are done!
Picture below. Also connected up, with software, and tested.
Relay status is now on pachube web page as well.

I had 3 sets of 4, so could have done 12 relays, but decided to double-up
4 of them, for extra reliability.
So 4 normal, 4 doubled = 8 relays.

Relays can get stuck "on". And Calc/Alk/ATO stuck on is a disaster.
Doubling that up reduces the risk.
It does increase the risk of stuck off. But that is more rare, and not a
horrible problem if it happens.

mprygh
12/18/2011, 09:10 PM
Updated the statistics site. Much easier to read.

http://www.theryghs.com/aquarium_stats.html

I need to tweak the power supplies, and test LED-PWM,
but otherwise done, so getting close.

WindowMaker
12/18/2011, 09:48 PM
great info! I should be starting mine in the next week or so, hopefully it works out equally as well.

WindowMaker
12/19/2011, 07:57 AM
quick question about the relay boards from futurlec. where did you get the ribbon cables to go with them? and where is it connected to your controller?
thanks!

windowlicker916
01/03/2012, 09:33 PM
any updates?

On a side note, I find my name and windowmaker's name in the thread hilarious

mprygh
01/03/2012, 10:25 PM
quick question about the relay boards from futurlec. where did you get the ribbon cables to go with them? and where is it connected to your controller?
thanks!

Ribbon cables came with the relay boards.
However, they are not very long, so I made one myself.
I buy most of my misc parts from Jameco

I soldered a male connector the the board, wired that up, and plugged
in the ribbon cable.
You can see it in the enclosed picture.

mprygh
01/03/2012, 10:33 PM
Post holiday update:

Getting close to done.

I am debugging the PWM connections.
(I made a mistake and connected a couple to standard I/O)
But seems to be working.

Ethernet, relays, temperature, Clock, and ATO sensors are all working.

I need to wire the PWM controls to the main lights.

I need to make a fancy holder for the display, and mount to tank.

Plus, I am a bit worried about one failure mode:
It turns out, if I lose power to the micro-controller, but not
the relay board, all the relays turn ON.
They are on same power supply, but not the same connector.

dread240
01/26/2012, 10:16 PM
So are your relays wired normally open or normally closed? seems swapping that and changing the code to go from low to high or vice versa would eliminate that issue fairly easily

WindowMaker
01/26/2012, 10:20 PM
any updates?

On a side note, I find my name and windowmaker's name in the thread hilarious

that made my day!

WindowMaker
01/26/2012, 10:23 PM
Post holiday update:

Getting close to done.

I am debugging the PWM connections.
(I made a mistake and connected a couple to standard I/O)
But seems to be working.

Ethernet, relays, temperature, Clock, and ATO sensors are all working.

I need to wire the PWM controls to the main lights.

I need to make a fancy holder for the display, and mount to tank.

Plus, I am a bit worried about one failure mode:
It turns out, if I lose power to the micro-controller, but not
the relay board, all the relays turn ON.
They are on same power supply, but not the same connector.

I have had a similar experience, when my controller resets all of the relays blink for about 1/2 second. I am not too worried about this, though I am thinking a small backup battery would prevent some of this.

mprygh
01/26/2012, 10:53 PM
Regarding relay issue:
The problem is:
At boot, your I/O are tristate, so float.
However, if you disconnect power to board, the I/O go low.
(Probably due to protection diodes pulling to power rail, which is zero)

The relays are active low. So when it power off, they go on.
I could switch them to normally open mode.
But that scares me a bit as well, since during boot, the relays will be on.
And if something goes wrong, and board resets, they go on and maybe stay on.

A backup battery would certainly fix things, as long as it is not a long term failure.

In reality - the odds are it will be fine, and I am probably being paranoid.

But my planned fix is to add a high power 30A relay to the main plug.
That one will be normally closed, active high, with a pulldown.
(Which is the way I like it)
Extra redundancy. And a pretty simple fix.

mprygh
01/26/2012, 10:54 PM
Quick update:

The PWM drivers are all debugged and working.
I had a weird problem where something else was using one of the PWM pins.
Probably the ethernet drivers.
Switched pins.

Still a bit of programming to do for the alarm modes.

But in general, it is up and functional.

WindowMaker
01/26/2012, 10:55 PM
Makes plenty o sense. Overall I am not concerned about a quick blink if the system resets. Most of my pumps, etc... are set to turn off on low, so it will just delay the startup of the pumps if the power resets.

mprygh
01/26/2012, 11:09 PM
Quick picture of the display.
It is attached to the bottom of the TV shelf, next to tank.

General Status.
Time
Temp
And some hex codes on relays and sensors.

Those cables are for the TV. The display cable is tiny.

mprygh
01/26/2012, 11:14 PM
Power cable pic.

The heater and lights draw too much power.
So what I did was put a heavy duty relay in a small acrylic box,
and spliced it into a heavy duty extension cord.

The nice thing about this specific cord is that it was
easy to determine the "hot" line.

mprygh
01/26/2012, 11:17 PM
The main electronics:

Here is a picture of all the guts.

Upper left = relay boards.
Lower left = ethernet board, main arduino, and buffer.
Upper right = 5V supply, 12V supply, and big 24V supply.
(The big supply is for the tank LEDs)

It may look a bit like a hazard, but all the 120V is pretty protected.
Armor cable, plexi covers.

WindowMaker
01/27/2012, 05:44 PM
just tested something new, if you put the relays high in your setup, the relays will do about a 1/4sec blink on startup. that is about as fast as I can make it go though.

porksmash
02/07/2012, 02:42 PM
The bootloader is what causes the delay. It waits some time after a reset/power on to see if something wants to talk to it over the serial connection before running your code. There are ways around it, but you need some special hardware to flash the new bootloader code: http://www.ladyada.net/library/arduino/bootloader.html

mprygh
02/07/2012, 03:09 PM
Bootloader - argh, another thing I need to tweak.
Not because of the delay issue mentioned though.
What I want to do is enable the watchdog timer reset.
And that means switching to the optiboot or other bootloader.
And last I checked, that was an issue the the Mega.

Good link!