Sunday, May 24, 2009

DIY dosing pump for reef aquarium

Part of the daily maintenance on a reef aquarium is controlling the calcium and alkalinity levels in the water. Calcium is used by reef inhabitants to build their skeletons, and it is also precipitated abiotically (calcium deposits on pumps, heaters, etc). Even though this rate of calcium utilization is fairly slow, it must be replenished to ensure there is always a sufficient supply, and having a very consistent level is beneficial to the inhabitants.

The alkalinity level of the water is a measure of how resistant the pH is to fluctuations. It too must be replenished to keep the pH of the water stable. If you are curious about marine calcium/alklainity, search the web. There is a ton of information available, and it is quite complex and interesting.

There are a few ways to maintain proper calcium and alkalinity levels, but I prefer to use a two-part alkalinity and calcium supplement called B-ionic. My aquarium is 5 gallons, and so it only requires about 1 mililiter of each solution (alk and ca) added each day. The exact amount varies, and the two solutions may need to be dosed in unequal quantities. Well, this gets a little tedious after a while, so I built a device that would slowly add the desired amount of each of the alk and ca solutions over the course of a day:I bought two "syringe pumps" on eBay for under $15 each. The pumps consisted of a leadscrew assembly, split-nut, and holder for the syringe. There was no motor, but I knew that they were originally intended to be run by a clock motor. The speed of the motor was constant, hence the only way to control the dosing rate was by changing the motor or the syringe diameter.

I hacked up the syringe pumps a little, and fitted them with two stepper motors that I got at a surplus store for $17 each. The motors are unipolar (6-wire), 1.8*/step, 24V per phase at 300mA.
The motors are mounted to the leadscrews with a short length of Delrin shaft. This allows a necessary amount of flexing, since the motor shaft and the leadscrew are unlikely to perfectly aligned. This is a very low-speed low-torque application, so the strength of the delrin shaft is not an issue.



The motor driver circuitry is built from PN2222A transistors that are wired between the motor windings and circuit ground. Each transistor has a clamp diode and filter capacitor on its collector. Each transistor base is driven by a pin on the Arduino Duemillenove microcontroller board. There are four phases for each motor, so this took a total of eight pins on the Arduino. The Arduino is also connected to a 4x20 LCD screen via 6 pins (4-bit interface). I also wired two potentiometers to the Arduino's analog input pins. The pots are setup as variable voltage dividers between ground and 5V.

The Arduino runs code that reads the positions of the two knobs, translates the positions into timing intervals, and advances each of the stepper motors when its respective time interval has elapsed. I also added code to de-energize the motors 1/2 sec after they have been advanced. In this application, the time between motor steps ranges from 40 seconds to 3 minutes. I tested this power-save feature, and it appears the system has no tendency to push the motor backwards while it is unpowered. Thus, power is only necessary when the motor is moving, and it can be deactivated when it is waiting for the next step.

The circuit and motors are powered by a 20VAC wall transformer. I rectified this with 4 diodes, and used a 7805 to supply 5V to the Arduino and LCD. The motor windings get unregulated DC voltage about 20V, since the load from the LCD's backlight is substantial. The 7805 required a large heatsink for this same reason.


For display purposes, the Arduino code translates the motor timing interval to mililiters/day. Turning the knobs provides a very responsive update of the LCD value. It is easy to set the device with .01 mililiter/day precision, although I doubt the device mechanially has that level of precision.

I calibrated the device by turning the stepper motor a specific number of steps, and used a very sensitive scale to measure the mass of water that was pumped out of the syringe. Later that day, I setup the device running normally with its output directed over a vessel on the scale. I learned that my scale must have an anti-drift feature, as it did not register any mass! Instead, I measured the water with a small syringe, and it came it at 4.75 mL (should have been 5). I am not sure if .25mL evaporated, or if .25mL stuck the sides of the vessel, or if the system is inaccurate. Maybe it's all three. The .25mL discrepency is not too important, since the settings will be tweaked based on water testing results once it is up and running.

I am still testing the system, as I really want to be sure it is stable. If the device malfunctioned and dispensed all of its calcium in one blast, it might kill everything in the aquarium. The code is pretty simple, but the Arduino clock function will rollover every 49 days, and it's difficult to test what will happen at that time.

I'll make another post when I install the system on the aquarium.

5 comments:

  1. im currently working on a project like this.
    Did you solve the rollover problem with millis ?

    regards
    Vegard

    ReplyDelete
  2. Vegard, I believe the problem with millis is automatically resolved by performing the correct math functions. I forget the exact order and method of storing times that I used, but the integer math in the arduino code will also roll over, so there is no problem with the counter wrapping around. http://www.faludi.com/2007/12/18/arduino-millis-rollover-handling/

    I've never noticed a problem with my dosing pump since I started using it.

    ReplyDelete
  3. Hello, found your nice project about aquarium doser. I want to make similar doser myself. You have used arduino. Which platform it was? And maybe you have schematics and code for you project?
    i have found similar project at http://expanser.wordpress.com/. There three peristaltic pumps, not syringe pumps were used. Interesting, which is better (more accurate, cheaper) to use for doser?
    My email is yandx@yahoo.com

    ReplyDelete
  4. Anonymous, sorry I don't have schematics for the project. I probably used the Arduino Uno (this project was done a few years ago). I imagine syringe pumps would be more accurate than peristaltic pumps, but they can not hold as much volume.

    ReplyDelete
  5. Recently I had a chat with my chemistry-equipment-salseman-friend, he knows his stuff, and he said that peristaltic pumps are one of the most accurate pumps out there, more accurate than styringe pumps (his words). Probably when pumping very small quantities (small diameter tube in the pump).

    ReplyDelete