Reef Central Online Community

Reef Central Online Community (
-   The R3CA Project (
-   -   Yet another arduino based controller (

gbru316 10/27/2014 04:57 PM

Yet another arduino based controller
I've decided to undertake an arduino based aquarium controller. It's a lofty project as I don't have a background in programming. I had to take an introductory C++ class for my BSEET degree and I have some familiarity with LabView and LabView CVI from work, but that's about it.

A professor at my school sells Arduino Uno boards to students for $10 apiece, so I figured I'd take him up on it.

Here's my desired functions:
- Temp controller
- Doser
- Electrical equipment control
- light timer
- PH monitor

The ATO is going to be totally DIY using ebay float switches. 1 to turn on and off, the other to cut power to the pump regardless of the state of the main switch in the event of a stuck closed scenario.

The temp controller is going to be just that. It'll use a temp probe to monitor temp and control the heater via the electrical panel.

The Doser is also going to be DIY utilizing eBay dosing heads.

The light timer will control my LED array. It's merely a timer for now because the drivers I'm using are cheap (maxwellen) and don't support PWM or 0-10 Vdc tuning. I thought about designing a resistor array with a few mux chips to step up and down the light intensity, but I don't think the benefits of a gradual change in lighting, if there are any, are worthwhile.

The dosing heads, float switches, 16x2 I2C LCD display, RTC and temp probe are all in the mail. I'm currently using a crude sketch to turn an aqualifter on and off for ATO. Crude, because I'm using "delay" for timing. It turns on for 15 seconds every hour and outputs the calculated time to the serial port. Obviously, the RTC is a much better solution to timing events as it frees up the processor for other tasks.

The serial port is currently monitored and logged using PuTTy on an old laptop with a broken backlight. I can't see anything but I've set it up so I can access it with remote desktop from my desktop PC. The laptop is powered on, connected to wireless, and stashed in a desk drawer with the screen closed. I may just end up keeping it that way so I can easily interface with the Arduino without purchasing any additional shields.

gbru316 10/29/2014 01:23 PM

Got a chance to play around with the uno, LCD, ds18b20 and ds1307. Within 2 hours I have a functional, datalogging thermometer with overtemp alarm. Datalogging is accomplished with a program called "gobetweeno" which monitors the serial stream and logs data to a text file that can then be opened with excel.

This isn't nearly as difficult as I had imagined, thus far. Granted, I haven't gotten to user selectable menus or anything, but I'm pleased with the progress.

gbru316 11/09/2014 08:29 PM

Finally had a chance to sit down and play with the ebay peristaltic pumps.

I initially used the default PWM frequencies of 488 and 976 Hz. Both of these resulted in a very audible whine and no functionality below 50% duty cycle.

After much googling, I discovered that it's possible to adjust the ATmega328's internal timers using prescale factors. Through trial and error, I've arrived at a frequency of 3.8 Hz as my final value. To get there, you take the base frequency of the pin (31.25 kHz for pins 9-12) and divide by the prescale factor. I'm using a prescale factor of 8096, which corresponds to a timer prescale value of 8192.

It seems as though these motors lose quite a bit of torque at the default frequencies, so anything less than 50% duty cycle resulted in whining but no movement. Lowering the PWM frequency allows me to dose as little as 0.225 mL/minute or as much as 60 mL/minute. It also eliminates the annoying audible whine. The consistency at this setting is not bad, either. At one minute of dosing, I measured a low of 1.19 mL and a high of 1.25 mL, with an average of 1.22 mL/min. Not bad at all for $12.

reefology1 11/16/2014 02:57 PM

Hey, any updates?

I purchased some components years ago to make a controller but put it on hold because i was overwhelmed by how complex the threads were getting. I have a mega board, 1307 rtc, 2 DS18B20 temp sensors and an 8 channel 5V relay sheild. I also have an old laptop running xp that hasnt been touched for a while. Would also like to monitor pH if possible but not sure what i need.

Would like to make a working unit this time around...hope i can keep up ;)


gbru316 11/16/2014 10:40 PM

Yep, slow but steady.

I wasn't able to transfer the PWM code for the dosers to a standalone function, so I'll probably just use "delay" to cycle them on and off. If I figure out how many milliseconds it takes to dose x amount of liquid, I can use the delay in a "for" loop to control the dose.

I have built half of my controllable power supply box today. I still need to build the arduino-relay interface. I'll be using BJY devices to switch the relays. The arduino regulator can source 200 mA max. As current controlled devices, I needed to make sure that I don't draw too much current. With a 10k series resistor on the base, current draw of each BJT is less than 5 mA. The doser uses MOSFETs (voltage controlled, practically infinite gate impedance) so I should be well under 200 mA.

gbru316 11/17/2014 05:03 PM

1 Attachment(s)
Got the relay box switching circuits built today. Just need to solder the base wires to the D-sub that will connected to the pump/control box, and wire the AC into the relay box.

The 2N2222 transistors get a bit warm during operation even though there's only about 100 mA collector current (rated at 1A). I'm going to do some burn in testing during the remainder of the week to make sure they'll be reliable.

Here's a crude schematic of 2 of the switching circuits in the relay box. It has a total of 8 relays, 7 normally open and 1 normally closed (so 8 total transistors). The load of the normally closed is in series with one of the normally open. This is for redundancy for the ATO. The ATO has 2 float switches. If the bottom switch fails and/or the normally open relay sticks, the normally closed relay and top float switch (which is controlled by a separate arduino pin) will ensure that the ATO doesn't overflow the tank.

I cut the connecting tab between the terminal of 3 of the outlets. The 4th I left intact.

As far as the heater goes, I'm going to continue to allow the internal thermostat to work as designed. The relay (in combination with the ds18b20) will only be used as a fail safe to cut power to the heater if the tank exceeds a certain temperature.

gbru316 12/02/2014 07:47 PM

3 Attachment(s)
I've decided to use Labview to control the Arduino instead of the arduino IDE. Given my basic programming background, I feel that the graphical programming of Labview will allow me to implement complex features more easily.

Here are some pictures of the power supply box:

I used one of these for the box. There's a 9 pin d-sub connector on the side of the box which carries the digital control signals for the transistors from the arduino over a standard serial cable. I didn't feel like designing a power supply for the relays so I used an old 12 volt, 2 amp switching wall wart instead. Seemed like the easier option.

gbru316 12/05/2014 02:52 PM

Having some trouble properly implementing the ds18b20 1-wire temp sensor with labview and I don't feel like paying for a license for the precompiled 1-wire vi's so I just placed an order for some tmp36 temp sensors. Labviewhacker/LINX has prewritten VI's for this sensor so implementation should be relatively painless.

Also ordered a 16 pin i2c i/o expander for more digital pins and 3 digital pots that I plan on using to control my LED array. I'm using cheap maxwellen drivers that don't have 0-10v or PWM dimming. They use a pot, but I haven't really looked into what kind of signal they use. The digital pots were $1.50 ea, so if I can't get them to work, no big deal.

I also got labview to read and display data from the ds1307 last night. However, since this controller will utilize a PC based GUI and a dedicated PC, I'm not sure I'll be needing it now.

gbru316 12/20/2014 01:56 AM

1 Attachment(s)
I had the chance to sit down with LabView today and made a ton of progress. It is actually pretty easy to use. has a package for around $50 that includes an arduino uno and LabView software if anyone is interested in playing around with it.

The majority of the relay control is complete and the user interface is about 90% complete.

Things to finish:
- Dosing pumps
- ATO control
- LCD screen
- Datalogging
- Email alerts
- long term functional testing

gbru316 12/23/2014 11:33 AM

Found a problem today: LabView control of the lights doesn't work. The relays work fine, but as soon as an LED driver is plugged in, it causes LabView to become unresponsive.

As I'm using cheap maxwellen drivers, I suspect that they are causing EMI issues which the relays are not entirely isolating from the arduino. I might borrow an oscilloscope from work to check it out, but I can't really think of any other reasons why other loads work on the exact same circuit while the LED drivers don't.

I've got 2 options. First, I could replace the drivers with better quality drivers. Second, I could use in-line low pass filters. As I've got a bunch of components lying around, I might try the second and install a LPF on one of the arduino digital controls and see if that solves the problem.

gbru316 12/23/2014 07:31 PM

After some troubleshooting, it looks like the error is related to the labview program I'm writing.

Using the arduino IDE, the relays control the lights perfectly fine. This is both a relief and a worry, as I'm far more familiar with hardware problems than software.

All times are GMT -6. The time now is 03:18 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2022 DragonByte Technologies Ltd.