How would someone make this type of dosing pump ?

Hi,

I have been looking at a DIY dosing pump system for my reef tank... I found this on thetube:

and thought it was a cool idea. though its probably not as precise as normal dosing pumps this can work for my application.

The only issue i have is the following: I have never programmed before nor done any electronics so i'm looking for some help doing this 8)

I searched and found out about arduino so i got myself a arduino Uno, and i got some cheap servos off of thebay.

They are 4.8V servos (4ea)

started looking into how arduino boards work and there are a ton on youtube. Looked at programming which is complicated for me since i have never done this before... If the setup gets more complicated than just blinking a LED bulb i'm completely lost :frowning:

But i think this is the right place to get started and get some help.

I have a couple questions though:

  • can i run 4 servos off of the UNO, or do i need an external power supply for those 4 servos.
  • if so, can i connect them in parallele into one P/S? what would be the voltage needed: 4.8V or 4.8V*4?
  • are there more than one pwm connectors on the UNO? ( I searched how servos worked )
  • Is there a way of setting up different times for each servo to come on? I would like them to come on each multiple times a day but not neccesarily all at the same time each time.
  • what other components will i need to complete this project?

I have the following:

  • arduino Uno ( should arrive end of the week )
  • Servos (arriving any day soon )
  • soldering iron, solder
  • couple LEds, resistors, 2N2222, wires,
  • LCD screen off of a typhon controller: I broke this controller so i got a new one and kept the borken one. screen works fine, I have some buttons aswell

would like a screen if its possible to modifiy the timing of the servos via that screen instead of having to hook it up to a comupter. Donc know if thats possible

you can make out the screen in that picture. it has i think a 16 pin connector on it

thats about all i have

please help me out =)

thanks

Yes, you need a separate supply for the servos.
Most servos I've come across are happy up the 6V, but 5V is probably easier to find.
The servo library supports up to 12 servos on a UNO, and they don't need to be on PWM-capable pins; the library generate the PWM.

The servo library is very easy to use; if you can blink a LED, you can drive a servo.
Have a look at the blink without delay example in the IDE, and substitute servo movements for LED blinks.

what is the IDE?

I thought you had to use the pwm wire and signals to be able to control the servos... every time i see a servo n a arduino that signal wire is hooked up to a pwm outlet.

You do need PWM to drive R/C servos.
However, this is not the PWM from the Arduino's analogWrite, which is closer to 500Hz and full-range (0-100% duty cycle) than the 50Hz low duty-cycle (typically 10% maximum) signal required by the servo.
It is possible to wire a servo to a PWM-capable pin, but it isn't the timer-based PWM hardware providing the signal.

okay, thanks for the explanation.

looked through the Examples and found this:

this could be easily modified to suit my servos... i think...

so to be able to control 4 seperate servos i would need to star of with the following: ?

int servo = A1;
int servo = A2;
int servo = A3;
int servo = A4;

not really sure i should be using the analog inputs?

You can use the analogue input pins if you want - they also serve as digital I/Os.

looked through the Examples and found this:

http://arduino.cc/en/Tutorial/Blink

Better still, use the blink without delay example.

how would i connect 4 servos to the board ?

first of all since i need an external power supply, and then also because i don't need to use the pwm outputs...

AWOL:
You can use the analogue input pins if you want - they also serve as digital I/Os.

looked through the Examples and found this:

http://arduino.cc/en/Tutorial/Blink

Better still, use the blink without delay example.

going to look for it =)

how would i connect 4 servos to the board ?

Individual signal wires (usually white) to the respective pins, red wires to external supply positive, black wires to external supply ground AND to the Arduino's ground.

nice thanks. so i need to wire the black wire on the servos to the power supply and to the GND on the arduino?

found it: http://arduino.cc/en/Tutorial/BlinkWithoutDelay

So this is actually the same type of setup as on the other example but you just take away the "delay" in the program and replace it with "long interval"

how do i add another command for another servo? do i start over again from "void setup"

You can't (well, let's go with "shouldn't") start again from "setup" - "setup" is called only once after reset.

You're not replacing "delay()" (a function) with "long interval" (a variable), you're using a completely different mechanism.
If you want two devices to run at different rates independently, you'll need more than one "interval" (reading about arrays may be a good idea here), and separate "previous" variables, because the last time you did something to a device should be personal to that device.

But, for now, just play with "blink without delay" and a single LED/servo, and get it to vary things like on-time vs. off-time.

okay ill try that then when i get the parts. thank. will come back with more questions lol

so i had a go at fritzing. Is this the way i would wire everything up?

Assuming i use a 5V power supply for the servos.

Note that the control pulses for the servos do not by any means have to be simultaneous - the whole nature of the radio control system for servos is such that the servos are pulsed one after the other, so your loop code can do exactly that - determine what the position should be for the first servo, pulse that servo accordingly, then the second and so on.

It is OK (but perhaps not perfect) to use a delay to generate each servo pulse as long as it is only to generate those pulses and you do not need to do anything else time-critical.

Paul__B:
Note that the control pulses for the servos do not by any means have to be simultaneous - the whole nature of the radio control system for servos is such that the servos are pulsed one after the other, so your loop code can do exactly that - determine what the position should be for the first servo, pulse that servo accordingly, then the second and so on.

It is OK (but perhaps not perfect) to use a delay to generate each servo pulse as long as it is only to generate those pulses and you do not need to do anything else time-critical.

I think what you are explainning is what i want to acheive...

I would like to have like the first servo come on maybe every 2 hours for a certain amount of time (will depend on how much product i want to dose ), then the second one could maybe come on each hour and so on throught the day. none of the servos will work at the same as another one. (its best too does products one by one instead of all at the same time, unless its a two part product)

I have looked at different sketches for servos on the examples and the forum and the only one i honestly understand the best (not saying i understand it completely) is the on using the "delay"

this means to have a servo come on each hour i need to delay by 3600000ms ? if i'm correct?

Is my wiring above correct? not missing any components or anything?

thx

The wiring for the servos looks fine.

Given that you want to be able to control the servos independently it would really be worth your while to spend the extra time now to understand the blink without delay sketch.

Although it will be easier using delay() instead for very simple functionality, I think that if you try to extend that (blocking) approach to the whole solution you will end up with a very messy and complex solution. The asynchronous approach demonstrated in blink without delay makes this sort of problem much cleaner and simpler to solve.

fiesta90150:
I would like to have like the first servo come on maybe every 2 hours for a certain amount of time (will depend on how much product i want to dose ), then the second one could maybe come on each hour and so on throughout the day. none of the servos will work at the same as another one. (its best too dose products one by one instead of all at the same time, unless its a two part product)

I have looked at different sketches for servos on the examples and the forum and the only one I honestly understand the best (not saying I understand it completely) is the one using the "delay"

this means to have a servo come on each hour I need to delay by 3600000ms ? if I'm correct?

OK, this is getting into a number of tutorials here but I will see what I can say.

It rather depends on what you mean by the servo "coming on".

Servos:
Servos are servo controlled motors. The electronics takes a a reference, a recurring pulse in the range 1 to 2 ms (milliseconds) with a "centre point" of 1.5 ms. It expects a pulse at least every 20 ms (50 Hz), and what it does in the absence of a pulse may be undefined - it might stay where it was last put, it might simply shut down as if it was turned off - which means that it will not resist any external force that might tend to move it - or it might decide to move fully in the direction corresponding to the shortest pulse length or attempt to keep moving beyond that which is clearly very bad!

Someone may (well) correct me on this, but unless you have tested exactly what your servos do when connected only to power and the signal line grounded - no pulses and not the same as low battery/ no power - it would certainly be wise to both ensure that the "end" position corresponds to no dose delivered and presume you need your program to be generating a continuous pulse stream no matter what else it is doing.

Now I was therefore not referring to having each servo perform its task in sequence, I was referring to just how you would arrange to continuously generate the stream of pulses every 20 milliseconds. The very last thing you want to do is to use a "delay" function for an hour. I was suggesting that it might be acceptable to use a delay function in the range of 1 to 2 ms - milliseconds - at the very maximum to generate each pulse to a given servo, one after the other.

Beyond that, as is repeatedly emphasised here, the "delay" function should be regarded as a "demonstrator" only, almost never to be used in a serious application. If you wish to use servos, they need to be serviced in the main "loop" function at least every 20 milliseconds, and anything else that you do in that loop must not delay matters for a significant proportion of that time. This is why it is stressed to avoid "blocking" function calls. This for example includes sending messages out on the serial line; you cannot safely use string sending functions because they may take many milliseconds to complete (even at higher baudrates), you need rather to arrange to send one character at a time as you traverse the "loop".

This comes down to code structure and is why you are referred to the "blink without delay" example and really do need to understand how it works. The general concept is that you are again, looping at a rapid rate, substantially faster than the events you need to either generate or assess. For inputs, you poll on each traversal of the loop and note (save) the time from one of your clocks (timer or millisecond counter which is updated by timer interrupts) comparing the time difference between one part of the event and the next. For outputs, you note the time when you started the event and determine at what time the event (such as a servo pulse) must be stopped, every time you pass this function in the loop you compare this to the current time such as to act upon it if that time has passed.

Of course, if you are generating servo pulses in this manner, they can easily be completely independent and may well overlap (without any interaction), or you could combine them into one piece of code to select one after the other by an array index - such an array could include the pin number for the servo and the current position expressed as a time in microseconds. Non-array variables would include the index to the servo presently being controlled, whether there was a pulse in progress and the time at which the current pulse should end. (In basic radio control, the end of the pulse for the first servo is the beginning of the pulse for the second and so on.)

wow, didn't think this would be complicated to understand :~

when i mean servo come one well when it starts to dose till it comes back to its original position and rasy to start again.

I looked at the blink without delay example,

void loop()
{
// here is where you'd put code that needs to be running all the time.

// check to see if it's time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();

if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;

// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}

can someone show me how i would add another servo to that last part of the program?
I get how you guys are telling me to set the program up but no idea of actuallyhow to write it correctly

thanks

when i mean servo come one well when it starts to dose till it comes back to its original position and rasy to start again.

Wow, that was complicated to understand.

how i would add another servo to that last part of the program?

That code (next time, use code tags, please) doesn't mention a servo, so adding "another" would be hard.
What exactly are you expecting to do?

Wondering if servos are the most appropriate method...my feeling is that a stepper motor/leadscrew would give you much better control over dosing.

As the name describes, you tell the stepper motor to make small rotational 'steps'..usually of 1.8 degrees of rotation...so 200 steps for 1 revolution. If you know this factor, the pitch of the leadscrew and the diameter of the syringe you can give precise dose volumes.

Do a web search for 'syringe pump' for some commercial units....

Another possibility may be a peristaltic pump and either a DC or stepper motor...