Reef Central Online Community

Reef Central Online Community (http://www.reefcentral.com/forums/index.php)
-   Do It Yourself (http://www.reefcentral.com/forums/forumdisplay.php?f=3)
-   -   Disc1 Arduino Doser (http://www.reefcentral.com/forums/showthread.php?t=2015868)

disc1 05/05/2011 07:22 PM

Disc1 Arduino Doser
 
I promised over on the equipment forum to post this. This is a project still in development, so it looks ugly. But I think you can see how to utilize these pumps to build something cheap for yourself. I'll try to come back and post updates as I finish it.

I bought these cheap peristaltic pumps off e-bay for about $30 each. I wanted to use them to dose 2-part. To my surprise I found that they were quite precise. So I built a little Arduino sketch to run it.

These are the pumps that I got.

http://www.reefcentral.com/forums/pi...ictureid=30459

These pumps run from about 6V to 12V dc. The flow rate of the two pumps did not match, one pumps 26ml/min at 12V and the other pumps 40ml/min. I think the slow one is defective, but there's really no sending it back and even though it is slow it is consistent. I use it for alk since I like to drip that slower anyway.

The flow rate is nice and linear with voltage, being about half at 6V. So I decided to use a MOSFET (RadioShack IRF510 was what I had on hand.) and PWM signal from the arduino. Power goes from positive to the pump, then from the pump to the drain pin, and then from the source pin to ground. The PWM signal goes to the gate pin. Since the pump doesn't run below 6V, use PWM values from 127 - 255 in the Arduino sketch.

Here is the full set-up...

http://www.reefcentral.com/forums/pi...ictureid=30460

And a close-up on the breadboard part.

http://www.reefcentral.com/forums/pi...ictureid=30463
http://www.reefcentral.com/forums/pi...ictureid=30464

The knob and the two ic chips are part of a rotary encoder that was put together for an entirely different project and ended up getting absorbed into this when I got tired of pushing buttons over and over. It's a horribly inefficient use of a rotary encoder using two 555 timers and an 8-bit shift register, but it worked well for what it was originally built. When I build a permanent version to put on a board I will trim this whole part down. Besides, it doesn't work very well.

Aside from that there are two pushbuttons, both of which are connected to arduino, but only one is used. It is used to select menu items or values. The knob allows you to scroll through the menus and adjust values. There are a couple of capacitors to keep the power smooth and two diodes running backwards towards positive from the drain on the MOSFET's to handle any kick-back from the pumps. Without these two diodes, you arduino will reset everytime the pump runs.

Once I had the program working, I wanted to make it pretty so I could put it in a box and use it on my tank. So I added the LCD screen I had laying around and added some functionality to the program. There are options to calibrate the pumps, prime the pumps, and build a dosing schedule. The schedule is stored in a seperate class that has arrays full of times and volumes. The flow rate is the same for all doses. There is currently room for two schedules, Alk and Cal, but I am going to trim the program down a bit once I am satisfied and probably add functionality for more pumps. It also saves the schedule and the calibration in the EEPROM so you don't lose it on a reset.

Right now the schedule is built by selecting a start time, end time, total volume, and max volume per dose. Right now I dose 60ml per day of the bicarbonate recipe so I do 5ml every two hours and I do the calcium doses on the odd hours. It runs the schedule every day and starts over at midnight. There is absolutely no error checking to see if the schedule will fit or to make sure that two additions don't coincide. I want to add that, but as of right now you have to calculate things before you put it in.

That pretty much does it. If I can find somewhere to host the code I will post it. It uses several of my home-made libraries. I'll package them up and post them too if anybody wants it. I'm sure a real programmer would have a field day with my code, but it works and that's good enough for me. I'm not claiming any real skill here. Just didn't want to pay big bucks for a dosing pump.

disc1 05/05/2011 07:28 PM

Oh and here's a couple pics of my 75gallon.

http://www.reefcentral.com/forums/pi...ictureid=30457http://www.reefcentral.com/forums/pi...ictureid=30458

shifty51008 05/06/2011 06:27 AM

very nice job. I would be intrested in seeing the code and your lib.s:D

BeanAnimal 05/06/2011 06:49 AM

Nice work :)

I built a fairly complex dosing controller using an Atmega, but the code is in BASCOM basic. Oddly, I used a grayhill rotary encoder for menu navigation.

In any case, the code allows for dosing windows to be set and the dose to be metered in many modes (all at once, in even increments, etc.). External input can also "hold" or "push" or "cancel" the current dose (for example if the system is in maintenance or feeding mode).

With all of the error checking and functionality to split the dose and fit it into the dosing window, calibration functions and other features, the code got very bulky. While I am pleased with the outcome, it was extreme overkill in the sense that I only use the basic function of dosing a fixed amount per day over a fixed time window :)

Nothing like beating a horse with a microcontroller when all you needed was a carrot to get the job done :)

disc1 05/06/2011 02:54 PM

Quote:

Originally Posted by BeanAnimal (Post 18739733)

Nothing like beating a horse with a microcontroller when all you needed was a carrot to get the job done :)


Amen to that.

disc1 05/08/2011 01:38 PM

1 Attachment(s)
Let's see if I can just upload the code here. You will need to move the libraries into you library folder. You will also need the latest version of the Time library from the arduino site.

For you programmers out there, take a look at my QuickPin library and tell me what you think. It make my life simpler in programming, but it's relatively new so I haven't really had a chance to run into any major problems with it. It's sort-of documented. You should be able to figure it out from the header.

disc1 05/08/2011 05:24 PM

1 Attachment(s)
And here's a basic diagram of what's going on on that bread board. I've got it in an Eagle file if anyone wants it.

nrbelk 06/07/2011 01:36 PM

How complicated is it to learn how to use something like arduino? I have basic coding knowledge and have done some soldering and working briefly with a bread board.

Would this be something I would be able to pick up quickly or is it a complicated process?

disc1 06/07/2011 02:03 PM

The coding is as complicated as you want to make it. I learn computer languages fast, it took me a week or two with an old text book to get moving in C++. That's all the arduino language is, a fancied up C++. But for someone who's not familiar with programming, it has pretty much all the commands you need to write a basic program. If you understand loops and if/then type logic you can pick it up pretty quick. If you understand how to use pointers and arrays and referencing, and more hardcore C++ stuff, then you can get real dangerous. It all works. Except the feakin new operator. But somebody wrote one, it's actually commented out on one of the pages of code with this thread.

Go on the Arduino website and look at the reference section and the playground. If you get what's going on there, then Arduino will work for you. Go put C++ tutorials into google and check out some of that. If you get what's going on there then Arduino will be a breeze to master and you can do some really neat stuff with it.

nrbelk 06/07/2011 02:27 PM

I did three college classes in C++, I know arrays, loops, if/then, but pointers and references I haven't had to ever use even though we were taught about them. Currently I write little scripts in perl to automate some menial tasks at work every once in a while. With this background, would you feel comfortable telling me to go for it?

I looked up arduino boards and I saw that there are various types/models. Which one is a common one to get for this type of project?

disc1 06/07/2011 02:42 PM

Oh yeah. You should be good to go, ahead of the curve even. Anything you don't know how to do google it. It's just the nature of the web to have great info on writing code. Go figure.

There are basically two types of arduino to start out with. The others are variations on the theme. There's the ATmega328 chip like in the UNO. That's what the one in this thread is, an UNO. There's also the ATmega2560 which has more inputs / ouputs and more memory. That's the Arduino Mega. It's more the scale for like a full on controller for the whole tank. Then there's all sorts of versions that are flexible, or have built in blue-tooth, or are the size of a button, whatever you can imagine.

Start out with an UNO or a mega (or one of the clones) since they are pretty much plug and play. Get a kit or something with some little leds and caps and diodes and resistors and stuff to play with. Spend a few days just writing programs around an led, make it come on, make it blink, make it fade, fade based on a pot. By the time you have written a few of those, you will know what's up.

nrbelk 06/07/2011 02:46 PM

Thanks! This is great, I'm getting way excited!

To do all that, do I need a bread board?

Also, with what you said about the differences of the two, uno and mega, I think I will go with mega so that perhaps I can eventually make a full on aquarium controller. When I get proficient that is :)

disc1 06/07/2011 02:53 PM

It will make it a whole lot easier to build circuits. When things are trial and error, you don't want to have to unsolder things to hook it up a different way.

Check out this site. www.sparkfun.com
I don't know if it is the absolute best prices, but it's reasonable and it will have just about everything you need to get started. digikey.com and mouser.com are two more that I use a lot, but they are more the type of thing where you need to know what you are looking for. Sparkfun has all sorts of good tutorials and how-to's on all of their products. I can get lost for days in there.

nrbelk 06/07/2011 04:12 PM

thanks for the site! I found kits that come with mini breadboards, I think it would be perfect for me at this time!

Ok, I think I have one last question before I pull the trigger and buy a mega instead of an uno. Would you be able to do things like dim LEDs? I'm guessing that turning high power LEDs on and off would be similar to the pumps, but what about dimming them? and how do I find how many inputs/outputs the arduino has? Also, are there ways to add more inputs/outputs?

Ok, I guess it was more than one question..... sorry.. but now I'm so excited! :)

disc1 06/07/2011 10:22 PM

To dim LEDs with an arduino, you are going to be using pulse width modulation to control your LED driver. It has to be a dimmable driver that works with pwm. The ATmega328 boards have 14 IO lines with 6 that can be pwm outputs. The mega has 54 IO lines, 14 of them with pwm. There are other chips you can get that can extend the IO capabilities of either board.

http://arduino.cc/en/Main/Hardware
Go to that site and look all over it. At the top of the page getting started, reference, learning. And check out at the very very top of the page, the playground.

You feed the pwm signal to the driver on it's dimmer line and viola, all you gotta do is write code. Well there's a little more to it, but nothing you can't do. There are TONS of arduino LED threads on here. And lots of ways to get the same thing done.

nrbelk 06/08/2011 10:05 AM

Thanks! I bought a starter kit, can't wait to start. Perhaps I will do a DIY write up too!

nrbelk 06/15/2011 01:32 PM

what do you use to get the arduino board to be able to turn the pumps on and off? I'm not exactly sure how to do this. Do I get a power cord for the pumps that accepts an input from the arduino or is there a better way?

I can't find the link of what I'm talking about with the power cords. They look like a PC powercord (with the brick thing) but on the brick thing, there are connectors for an electronic on/off switch

theshoes 06/15/2011 01:57 PM

take at look at MOSFETs
That's what I'm using
Sent from my T-Mobile G2 using Tapatalk

disc1 06/15/2011 02:30 PM

Quote:

Originally Posted by nrbelk (Post 18905064)
what do you use to get the arduino board to be able to turn the pumps on and off? I'm not exactly sure how to do this. Do I get a power cord for the pumps that accepts an input from the arduino or is there a better way?

I can't find the link of what I'm talking about with the power cords. They look like a PC powercord (with the brick thing) but on the brick thing, there are connectors for an electronic on/off switch

That's one solution. The cheaper thing would be to use a transistor. I like a MOSFET for arduino stuff since it depends more on voltage and arduino doesn't source a lot of current. The "real" correct answer is to use a MOSFET and then an NPN to switch the MOSFET. With a built arduino board, you have enough protection that you can do away with the NPN without burning anything up.

Basically, a transistor is like a switch. You use a voltage on one pin to control a much larger voltage and/or current on the other two pins. If you look at the schematic with this thread, you can see how to hook them up.

nrbelk 06/15/2011 04:59 PM

Thanks! That is perfect, hopefully my local radio shack has them in stock.

Now the other part of the question would be what do I plug into the wall to give the pump(s) power. I'm fairly new at this electrical stuff so I'm still working on figuring it all out.

Do I take just a spare electrical outlet cord and cut and then strip it to get to the wires? Sounds excitingly dangerous! :)

disc1 06/15/2011 05:09 PM

The pumps probably take DC. SO you will have to have some sort of transformer. A wall wart will do. In my project the pumps were 12VDC. So if you were using a MOSFET transistor the positive would go to the pump. The other side of the pump goes to the MOSFET drain, the source goes to ground. The base gets the signal from the arduino. You need to protect arduino and the mosfets from the kick-back voltage from the pumps. The easiest way to do this is to put a diode backwards between the ground from the pump and hot. That way if the positive voltage goes below 0, like on start or stop the pump, the diode acts like a short to ground. Without something like that, arduino will reset or lock up every time the pump runs.

Look at the right side of the schematic in post #7. The rest of that stuff on that pic is just to be able to use a rotary encoder instead of buttons. The right side towards the top has the two transistors.

nrbelk 06/20/2011 01:18 PM

I'm trying to look at the diagram you included in post #7 but it shows up pretty small. Could you attach a larger version (or send it to me in an email if that works better?).

I want to review it and see what I can learn from it.

Thanks!

disc1 06/20/2011 02:31 PM

It won't let me post the eagle file here. I sent you a PM.

theshoes 06/20/2011 03:41 PM

Can I get the eagle file too

Sent from my T-Mobile G2 using Tapatalk

BeanAnimal 06/20/2011 05:16 PM

You still havent turned off that silly tapatalk signature?

Sent from my Commodore 64 using Multi-Term 5.2


All times are GMT -6. The time now is 11:10 PM.

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