Using raspberry pi to control pump and solenoid valve

Discussion in 'The Projects Forum' started by Deathyzz, Feb 16, 2015.

  1. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    Hi all, bit of an amateur looking for some advice. Have done quite a bit of web searching but want to validate my proposed design. The project is a water control system using a raspberry pi.

    I have a water purifier with a tank, and i need to move the water to 4 printers when they need water.
    However, the printers contain a water tank so i need some kind of precision.

    I tought about this design :

    [​IMG]

    Thanks to the precision needed, i don't think i can use the gravity to move the liquid. That's why i tought about using a pump. But i think that might cause some troubles. Will it be troublesome to active the pump when all valves are closed ? if i open the valve one at a time and then active the pump will it work ?

    Maybe another design will work better ?

    I need advice ...

    Thanks
     
  2. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,969
    744
    If the solenoids are DC controlled, use 3 diodes to create an OR gate, one from each solenoid to put a relay on that will put the pump on, or if they are AC solenoids use 4 relays and 3 diodes, or use four separate relays from four outputs from the Arduino.

    How do you intend to monitor the tank levels?
     
    Deathyzz likes this.
  3. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    the printers send a message in a database . For the moment i send the error message to a raspberry pi with sockets .

    Now i want to use these messages and when one of the printers need water , i want to refill it automatically.
    When i receive the message , i know that the printer need, for example, 4L of water. That's why i need a pump so i know i need to avtive the pump for 30sec and approximatively 4l of water will be refilled.

    But i'm afraid, il will cause problems with the pump and the solenoid in series ...
     
  4. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    Let's make this simple. You have a tank, you have a pump and you move water from a main tank to one of four other small tanks. Running the pump with all four valves closed is called "dead heading" the pump, here in the US anyway. Some pumps can be deadheaded and some can't. There are ways around all of this. How does your main tank get filled? The big tank, how do you maintain a level in that tank? Can the main tank be pressurized? Can it maintain pressure?

    Ron
     
  5. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    My Main tank is filled manually for now because it is a water purificator . The purified water fall into a tank.

    The tank is not pressurized that's why i use a pump because a gravity water system is irregular ( depends on the level of the water ). And i need some precision.


    So if open the valve on at a time and then turn on the pump, il will not cause trouble ?

    I tought about using a micro pump with like a flow about 4-5L/min and for the solenoid about something like this http://www.adafruit.com/products/996
     
  6. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    Those are common solenoid valves, I have used many of them. Here is what I would do. Run a solenoid on each tank. Place a check valve at the main tank exit and in front of the check valve place a pressure valve. When all four solenoids are off the line will have pressure, on pressure rise turn off the pump. If any solenoid valve opens to a small tank the pressure will drop and the main pump comes on. Note that the valves you linked to under pressure show a min and max. The min shows 0 which is fine. Many valves like this require a min pressure to operate or they won't open. Anyway, open a any solenoid and pressure in the line drops and pump comes on. When all 4 solenoids are closed there is a pressure rise and pump shuts off. Will that work for you?

    Ron
     
  7. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    i understand what you mean but your solution will build pressure in the system for no reason and the pump will each time run a bit in "dead heading" like you said earlier.

    Will it not be better to juste open one valve then turn ON the pump wait for the tank to be filled ( check with a sensor or estimate the time to fill the tank with the flow rate of the pump ). Then turn OFF the pump and then close the valve ?

    Thanks for your earlier answers btw, it helped me a lot .
     
  8. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I would put a pump between the water purifier and a new tank I will call the Header tank. Elevate the Header tank a couple of meters above the printers to provide a consistent static head pressure. Put a solenoid at each printer.

    Put a normally-closed float switch in the Header tank. Run the Pump only when the float switch is closed.

    Optionally, you might also put a float switch in the water purifier to alert the operator that it is running out of water...
     
  9. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    I like Mikes thinking as to elevating the Header tank, that is why I asked if the Header tank could be pressurized. I guess you could do as you suggest as long as you only fill one tank at a time. I have never been fond or keen on timing a tank fill, personally I like the use of sensors. Also, per Mike you want to know what is going on with level in your Header tank.

    Ron
     
  10. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    the problem is that i can't use sensor in the printers tank because of acces problem. Thus i need to calibrate the water i let pass . If you have a way to calculate the water that i let pass, i will definitively use a elevated tank. It was my first tought but once the tank will be half emptied, will not the pressure fall down ? Because if the pressure fall down it'll be impossible to calculate the time (for opening a valve) needed to refill the printer tank.


    Or maybe a level sensor in the header tank, when i get a request for water, i check if the level is enough then i open the valve, and check the quantity of water with the decrease of water in the header tank. Then i close the valve and check if the header tank need to be refilled .
     
  11. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    If the header tank is 10cm high, and is elevated 200cm above the solenoids, the delta pressure change from header tank full to header tank empty is only 210/200 = 1.05 = 5%. A 5% pressure change will cause a 5% flow rate change through the solenoid. It is not everyday I get to use the water analogy backwards: I=E/R

    If you dont like 5%, elevate the header tank higher...
     
    Last edited: Feb 16, 2015
  12. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    Ok, but now that i think about it .

    I need to know if there is enough water in the header tank, so i better just check the tank level to calculate the quantity of water.

    Anyway, thanks a lot :)

    I've have only one last problem.
    It's about how to power the valve and the pump with the Raspberry pi.

    I checked several circuit online and i picked up the ideo of using a 1 Channel Relay with optocoupler .
    http://www.amazon.com/gp/product/B0...s2&tag=skiwithpete-20&linkId=TUNLQVZMZJEIVWTE

    But i d'ont know if i can connect it to my Raspberry or if i need a buffer .

    Each time i find a different answer , so i don't know what to pick ...
     
  13. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    That is why I suggested a simple float switch in the header tank.

    Is the Pi's Vdd= 5V or is Vdd=3.3V?
    Look up the PI data sheet to see how much current the PI's port pin can source/sink?

    Likely, the Pi's port pin can drive the input LED on the optoisolator directly.
     
  14. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    the PI port pin can only source 3,3V, but i searched for your idea and i found this :



    I will look a bit about the float switch, but it sound like a good idea.
     
  15. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    The NPN transistor is not needed. The PI GPIO pin will sink 16mA if configured that way. Here is how to hook it up. Max current out of the opto-isolator is still only ~10mA, so you will need a solenoid driver/pump driver to follow...
     
    • 4.gif
      4.gif
      File size:
      31.3 KB
      Views:
      52
  16. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    I search a bit and found out that relay are easier than optocoupler because they support higher current and do the job as well .

    [​IMG]

    Is this circuit alright ? How do i calculate the value of the resistance, the relay and the flyback diode ?

    I found some with the solenoid before the relay, does that change anything ?
     
  17. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    i forgot a flyback diode : the correct circuit :

    [​IMG]
     
  18. Reloadron

    Active Member

    Jan 15, 2015
    963
    232
    You start with your solenoid valve and look at the data sheet for the valve. In the example you linked to earlier in post #5 the relay coil is 12 Volts and the current is 3 Amps . So your relay needs to have contacts that will easily handle a 12 Volt 3 Amp DC inductive load. Let's say I go to my local automotive store and buy some 12 volt coil automotive relays and some sockets. Automotive relays are designed for DC current on their contacts and are actually reasonably priced. Typical automotive relays have around 75 to 80 Ohm coils that draw around 160 mA (give or take). Now I know what my switching transistor needs to handle o drive the relay coil. Using your circuit design a 2N2222 would work as they handle up to 800 mA.

    First calculate the collector current when the switch is on. I = V/R = (12V – 0.2V)/75Ω = 160mA. Now calculate the needed base current required to turn on the transistor. Looking at the datasheet, Hfe could be as low as 30 at 160mA. The base current should then be IC/ Hfe = 118mA/30mA = 5.33mA. We will add a factor of about two for safety and use a base current of 10mA (to make sure the transistor turns on fully). Finally calculate the value for R2, the base resistor. Note: When the transistor is turned on there will be about a 0.7V drop across the base emitter junction. Therefore R2 = V/Ib = (3.3V – 0.75V)/10mA = 255Ω. This value isn't critical so use the closest standard value (260Ω). The flyback diodes can be 1N4002 common diodes.

    Doing it this way you add parts. You might be able to use a ULN2003A since you will have 3 tanks. The ULN2003A is a Darlington Transistor Array which looking at the data sheet should work.

    There are also other transistor options out there. Since Mike did a circuit wait and see what he says.

    Ron
     
  19. Deathyzz

    Thread Starter New Member

    Feb 16, 2015
    18
    0
    Should it not be I= V/R = (5V - 0.2V) / 75Ω = 64mA ?

    Let's say i pick this relay : http://www.amazon.com/2pcs-Power-Relay-SRD-12VDC-SL-C-Type/dp/B00MPEUPUE

    it'll be I = (5V-0.2V)/~100Ω = 48mA

    The base current should be Ic / Hfe so : 48mA / 30 = 1,6 mA

    Let's say i use a transistor 2N2222 like you said. I need to calcul the base current. i think 5mA will suffice.

    R = (3.3V - 0.75V)/5mA = 510Ω

    i would like to know if my reasoning is good

    Thanks
     
  20. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    When driving highly inductive loads (solenoids, pumps) it is much better to use an isolated power supply to drive the load, and not have to make a common connection between the Pi's gnd pin and the isolated supply. The opto-isolator I showed in the earlier post can drive 10mA into the base of an NPN darlington or gate of an NFET which can switch multiple Amps....
     
Loading...