5-12v Water Pump control problems

Hello everyone!

I have recently received the stater kit from Adafruit and started tinkering with the Arduino :

For my "HydroDuino" (automated hydroponics using the arduino) project
-i am currently trying to control a 5-12V water pump (basic on /off ) using one digital pin
-i need very precise timing in order to avoid overflow : this part works very well (tested with a simple led)
-i am not really good at electronics but after looking around i decided to go with a tip 120 transistor (with a diode for security) (schematics found here Fortellerorkesteret | Connect the Dots example

More info etc in my blog http://www.kaosat.net/?tag=hydroduino

THE PROBLEM:

  • i am having HUGE speed fluctuations in the pump, so each and every time i start the system, i get different speeds, which pretty much defeats the whole “precise timing for a precise filling”.

*o in a lot of cases the motor starts of veeery slowly, and the speedup rate to an acceptable level always varies
o sometimes about halfway through the timing interval (set at 180 seconds for now), i will get a sudden decrease in power : my guess is this is tied to the tip120 transistor, and the lack of sufficient "differential" : i managed to reduce this problem somewhat by exchanging the 1k transistor that goes to the base from the Arduino digital pin with a lower rated resistor

  • these problems are unlikely to come directly from the pump as i did not have such fluctuation when running it directly on the power supply

  • i am also aware that using a cheap 8$ pump which eats up 2.2A at 5v (twice what was indicated on the seller's site) is also begging for problems

  • I am not really good at electronics, but from what i gathered, i might need to add a few capacitors to smooth out the current and reduce the spikes?. like here ? http://www.tigoe.net/pcomp/code/category/Picbasic%20Pro/62

Sorry for my obvious lack of mastery in this field, but i am more than willing to learn :slight_smile:

Any help , comment or suggestions is appreciated!
Thanks in advance

i might need to add a few capacitors to smooth out the current and reduce the spikes

See:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

cheap 8$ pump which eats up 2.2A at 5v

Was it specified to run at 5V? If you are running it at a lower voltage you might get excessive current because of the nature of an inductive load.

by exchanging the 1k transistor that goes to the base from the Arduino digital pin with a lower rated resistor

You actually mean low value resistor, a lower rated one refers to the power dissipation capability. That being said what value did you use? A TIP120 does not have too higher gain, you could try adding an other small signal transistor to make up a Darlington pair (Goggle it). The other thing you could consider is using a MOSFET in place of a transistor. These tend to switch on harder. You could also use a relay to get a better hard switch.

i am having HUGE speed fluctuations in the pump,

Basically you are implementing an open loop system. That is, there is no feedback, so there are fluctuations like this. To make a closed loop system you would have to monitor how much water you pump wit a flow meter, forget the timing and pump until you have pumped enough water.

hey yo!

u could put 2 cables into the tank and connect each cable to a high resistor (1MOhm or so) and connect one cable to arduino's GND and the other to an analog input, that is pulled up to arduino's 5V via a 10MOhm resistor...

in case of a little error the current would be quite low (5V / (2MOhm) = 2.5uA)...
in normal operation mode u would have an even lower current (5V / (12MOhm) = 417nA)...
maybe that current would damage the electrodes over the time and poison the water? :-?

or u use an empty (just filled with air) bottle, that pushes against a button, when it is lifted by the rising water... :slight_smile:

bye

what RIDDICK is suggesting is a homemade float switch. Search around and you will find plenty off the shelf items.

If you want to have full control over the pump then i suggest a PID controller. Have a look here for more details: Arduino Playground - PIDLibrary

In order to use a PID controller though you will need to calculate error, for which you will need a measure of the amount of fluid in a tank. Essentially you need a sensor which will report the level of fluid in the tank. As the level rises closer and closer to the setpoint, the PID controller begins to decrease output to the pump, thereby slowing it down, until it finally reaches the setpoint.

If you post more details about the scenario, you will get better responses. The above assumes the pump is pumping water into a tank, but I'm pretty sure that is incorrect. If that isn't the case, then you need to use a flow meter instead, which will report the rate of flow. By monitoring the rate of flow and elapsed time, you will have a clear indication as to the volume of liquid which has been pumped. In this case, you can use the PID controller to control the motor with respect to the flow meter.

Wow, thank you all for the very quick replies!

I guess i really wasn't clear enough about the project itself:
-This will control the water flow in a homemade ebb & flow irrigation system: basically the water is being pushed up through the BOTTOM of the bottles at set intervals per day.
-Once the set level in the bottles have been reached , the pump shuts of and releases the water BACK into the container.

more on it here :http://www.hhydro.com/cgi-bin/hhydro/ebbFAQ.html

-some picture for more clarity (on these photos i only linked up two bottles but normally it's four)

bigger versions just in case :


Grumpy_Mike:

-thanks for that link, i have read it but i will do so a couple more time to understand all the concepts:)
-well i am running it at a lower voltage : normally it is a 6-12v pump, but i tried it at 12v and not only is it way too fast , but it also almost fried the tip120
-to get the Amperage i measure the resistance of the motor (when not running it is about 2.2 ohms), and then i divide the actual voltage used by the resistance
-yes sorry about that it is a lower valued resistor :100 ohms
-i will take a look at the Darlington pair thanks for that :slight_smile:
-i am not really sure what way i would have to measure the water flow, as the tubings are 1/4" ...hmm although, now that i think of it i could perhaps calculate the flow based on the elapsed time between two set level of water..i will study this !

RIDDICK & FusiveResonance
-you are both quite right, that is indeed a possible solution
-given the requirement in the system i think i would need to add one such electrode per bottle and use any kind of "logical OR" operation to gather the input of all the bottle and switch the pump off if the water in ANY of the containers reaches a critical level
-i don't really know if there would be a danger of running 5v though the water but i doubt it , if i remember right i have seen EC meters with way higher voltage
-actually i even think i might be able to use this electrode system to both measure the water level AND monitor the electrical conductivity of the water ...then again, if the resistance of the water changes...hmm
-the float switch would unfortunately be very impractical in this case (see pics)
-wow, didn't know about the PID controller, but i'll definitely have a use for it, since i will need to monitor and control a lot of other parameters thanks:)

i have new idea after i saw the bottles:
u could use 2 light dependant resistors (LDR): one at the critical level and the other right above it...
when the difference is high, it is hopefully not a shadow, but the rising water... :slight_smile:

If the TIP120 transistor is getting too hot, that may be because it is not fully switched "on". A transistor that is fully "on" is said to be "saturated", and has a low collector-to-emitter voltage (less than a volt, maybe as low as 0.2V). Could you measure the voltage across C and E of the TIP120, when the pump is on? A transistor needs a certain amount of base current to get it into saturation, so one way would be to reduce the value (Ohms) of the base resistor.

why not avoid all the saturation problems and just use a logic level mosfet? (edit: oops, already suggested)

The TIP120 is a darlington pair with a minimum gain of 1000 and a max base current of 120 mA per this data sheet:

http://www.st.com/stonline/books/pdf/docs/4128.pdf

So you should be able to saturate it with a 125-250 ohm resistor between the Arduino and the base of the TIP120. At 220 ohms, you'll deliver about 23mA to the base, which will give you up to around 2A of available drive current to the pump motor. (150 ohms -> 33mA and just over 3A drive current) Don't go below 125 ohms or you risk overloading the pin on the Arduino. To saturate a transistor means to provide more current to the base than necessary in order to fully switch the transistor 'on'. This allows the least voltage drop across the collector and emitter, freeing up that voltage for your load (the pumps).

If you're still not getting a consistent speed, you may need to run the motor closer to its rated voltage and/or use a power supply that provides more current. Motors draw more current when they start up, especially when they are loaded down. In the case of a pump, load is present as long as there is water in the pump. So it's going to draw a big surge of current right as it's first powered on. My bet is that you don't have a strong enough power supply for the motors. It may also be that the current draw of the pumps at start up is high enough to take the transistor out of saturation mode, which will cause it to eat voltage, heat up and slow the pump down.

To be sure, post the current rating (amps) or wattage rating of the pumps and one of us can verify for you.

The TIP120 is a Darlington: looking at the datasheet, it would be dissipating about 2W if it were sinking 2.2A. Not enough to fry it, but it would probably be happier if it had some help from a heatsink.

Ran

ckaos:

have a look here for an idea of a float switch: http://www.meder.com/levelsensor_ls02.html?&tx_jppageteaser_pi1[backId]=2952

The picture isn't oriented properly, but imagine that the assembly suspended inside your tank with the cable going up and out. Now, as the liquid level rises, it will contact the float and will cause it to also rise. As soon as the float hits the contact surface, it will close the circuit. This assembly is waterproof obviously.

I don't understand why you're saying that this is impractical. Please explain.

This float switch is around $8 to $12. Search for the LS02 series.

Another approach:
Take a piece of plastic (like a disposable plate) and cut it so that it will fit into the tank. You can see that this platform will raise and lower accordingly with the water level.

Now you have a multitude of options:

  1. Affix a magnet onto the platform and mount a hall effect sensor at the top of the tank.

  2. Use a distance sensor like this GP2Y0D810Z0F Sharp Microelectronics | Mouser Canada. The sensor is mounted at the top of tank (so as to keep away from liquids) and measures the distance between it and the platform. (Use an opaque platform)

Now that I understand the situation better, might I suggest disregarding a PID controller. Might as well keep things simple: Run the pump at low speed, and simply stop it when the preset distance is reached.

I don't mean to undermine folks assistance, but after reading a little on the link you provided and studying your pictures, I don't think you need to sense the water level at all. Since each jar is its own space, which is open on the top, and you only have one pump, flow and level sensing won't be very accurate. If you had a pump for each jar, you could do that. What you need is an overflow drain at the top of each of your jars that will allow extra solution to drain away if a jar fills before the others. The overflow drains should flow faster than the pump can fill the jars. Depending on how powerful the pump is, you might start at about twice the ID of the fill hoses. So if the fill hoses were 1/4" ID, then the drain hoses would be 1/2" ID. You'll need to experiment to find the best size.

Then you only need to work out the timing between fills and how long to run the pump each time.

EDIT: Actually a float won't work even if you did have separate pumps because the growing medium would not provide any free water volume to float on.

koyaanisqatsi:

The method you suggest is simple, hence elegant. I like it, but have only one concern, but this might not be of much concern to the OP.

There is no feedback being received from your system. You're assuming that the pump will always work perfectly, and that the water will always flow. What if the water supply is shut off? The pumps will turn on for their predefined period of time, and then turn off. The system will continue to run without faulting. Sensors allow for a more intelligent system which can have error detection.

Good point! Probably ought to have sensors to detect when the reservoir is low and maybe even leakage or spill detection too.

So how about something like this - because I do think having overflow drains will be necessary in any case: put liquid detection in each of the overflow drains. Poke a couple stainless steel wires into each drain tube and when they all sense flow, then the pump can be shut off. That way you can handle the likely scenario of the jars not filling at the same speed and avoid overflowing some and under filling others. You could track the time it takes to fill them each cycle and monitor the health of the pump or identify really bad differences in fill rates between the jars (in case of a clog, maybe).

Yeah, PID wouldn't work since you need to vary the pump speed. You might want to try using the transistor to turn on a relay, and letting the relay drive the pump motor. Relays are either on or off, and as long as you have enough current through the transistor to switch the relay, you won't have any weird issues. You can also use a higher voltage (like 6 or 8) on your pump so you're not under-driving it. You still need the protection diode on the relay though.

-to get the Amperage i measure the resistance of the motor (when not running it is about 2.2 ohms), and then i divide the actual voltage used by the resistance

That will only give you the stall current not the running current. The running current will be much lower due to the way inductive loads work.

but i tried it at 12v and not only is it way too fast , but it also almost fried the tip120

As mentioned that is a function of the current through the transistor and the voltage across it. But if you have not got a heat sink then you do need one with this sort of current. A MOSFET would be better but even that might need additional heat sinking.

i am not really sure what way i would have to measure the water flow, as the tubings are 1/4"

You can get paddle type flow meters that give one pulse per revolution. Given they are likely to be expensive you could rig up something yourself that uses opto switches to count revolutions of a paddle.

could perhaps calculate the flow based on the elapsed time between two set level of water.

If it elapsed time then you are in the same boat as you are now, but you could just use level detectors or a float switch arrangement that empties the reservoir and then fills it again only when the bottle empty rather like a toilet cistern.

Wow thanks a lot to everyone for all the feedback, a lot of possibilities i had not thought of which will come in handy!

-I have done a bit more testing this weekend:
-First observation: these pumps are either pretty much junk, or the undervolting really doesn't help: now i am getting speed variations even when hooking the pump to a very stable computer psu ( still 5v)!!
-Here is a small side view/slice to make things clearer:


-As you can see , no room for a float switch there
-There is already a simple overflow system in place

RIDDICK
That wouldn't work unfortunately, given the configuration :slight_smile: (see drawing above) but thanks none the less!

Anachrocomputer koyaanisqatsi Ran Talbott and weirdo557
-i will check the actual current rating of the pump this evening and will post the data
-need to get some heat sinks indeed, never would have thought i would be facing such heat dissipation
-about mosfets : sorry for my ignorance, but from what i have read, mosfets are working similar to transistors except for the fact that they "filter"/stabilize the current ?

koyaanisqatsi and FusiveResonance
-You got that exactly right, i have no room to place a float switch, since the bottle will be closed up by the netted cup/plant with the clay pellets
-I actually already have an overflow drain system (the small plastic bottles with the plants in them are fitted inside a bigger bottle with a tubing leading back to the reservoir)
-The timing of the fills is where the problem lies since it is not reliable
-Your ideas of combining the overflow system with sensor feedback and adjustment seems to be the best solution so far
-i will also HAVE to add additional feedback from the water supply as well as running to pump from an empty reservoir wouldn't do much good:)
-since clogging of pipes is a very common problem in hydroponic systems (excessive root growth etc) some form of detection of such problems is pretty much a necessity:)

jpgr87
-i will look into the possibility of using relays aswell, but i haven't got any at hand currently so i'll see if i can iron out the problems first.
You are right about the higher voltage though, will try that tonight.

Grumpy_Mike
-would i then need to monitor the running current while the pump is on with a multimeter?
-given the small size of the setup, i still ain't sure i would be able to use any kind of water flow meter, but i'll give it a try

Anyway, i will experiment some more with all the solutions provided , and will post back with further data/results as soon as i can!

MOSFETs work like transistors, but do not filter the current. They are switched "on" by voltage, not by current as bipolar transistors are. When fully "on", they behave like a very low-value resistor (from source to drain), not like a forward-biased diode (small voltage drop), as a bipolar transistor does (collector to emitter).

Please tolerate my foolishness (and tardiness):

Two wires at the top of the overflow (OF), two wires at the bottom of the small bottle (SB) and two wires directly under the pump (PW). Water Closes the "switch" that is each pair of wires.

Only EVER power the pump if PW is Closed.
If SB Is Open (and PW is Closed) run pump until OF is Closed, then wait until SB is Open again.

Is that ridiculous?

That's very close, actually. But I don't think you'd need the 'SB' sensor. As long as the 'PW' sensor was closed, you would start the pump on a schedule and run until ALL 'OF' sensors closed, then stop. The PW sensor would be your "water exists" sensor. You would need to limit the time the pump runs to some maximum to avoid burning it up if one or more OF sensors never closed for some reason.