Using raspberry pi to control pump and solenoid valve

Reloadron

Joined Jan 15, 2015
7,501
I see Mike is up and about. :)

I also neglected to include the use of an isolated power supply which is why a opto coupler is used. I intended to include that and went off on a tangent. Bad Ron on that note.

Should it not be I= V/R = (5V - 0.2V) / 75Ω = 64mA ?
Your drawing in post #17 reflects 12 volt power to the relay coil, so I used 12 volts. 12V - .2V = 11.8V / 75 Ohms = 157.3mA which I made 160mA in the example. That is how I went about it anyway. :)

Overall the best way to go about it is to start with the isolation Mike has covered.

Ron
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
i don't understand what you mean. In the model mentionned at #17

There is not connection between the GPIO - GRND and the pump / solenoid.

Did i miss something ?

ps Reloadron : for what i understand the coil is on the left side so that why i tought i would be the 5v . that's why i picked this relay cauz the coil side need 3-30 VDC and the contact side is 12VDC.
 

Reloadron

Joined Jan 15, 2015
7,501
No, you didn't miss anything, I sure as heck did. :) I looked at the drawing and saw the 12 Volt supply and coil. Can't believe I did that and it's morning. You are indeed correct. It's a good thing my days for doing this to eat are done. My technicians would have eaten me alive for that plus likely have enjoyed a free lunch on me.

Ron
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
No probem, you helped me a lot .

But now the thing Mike highlighted intrigue me .
With the circuit on #17, using the 5V supply directly from the RPI is really that bad ?
 

Reloadron

Joined Jan 15, 2015
7,501
Yes, it can be. While things look good on paper sometimes at first glance when we look deeper we see potential problems. I don't know what tools you may have at your disposal but sometime place a scope across a relay coil as it is energized and then de energized, even with a snubber or flyback diode across the coil. While in some circuits noise spikes and the like are not a big deal when it comes to circuits that involve micro controllers and other sensitive parts weird things begin to happen and to complicate things they are often random in nature. Even when good decoupling is used, even when power supplies only share a common ground. This is why Mike is stressing isolation, it's good design practice. When we design a circuit, each step of the way, start to finish, we try to incorporate good design practices. Doing so precludes many headaches later and debugging issues as in looking at each other when something bad or quirky happens and saying why did it do that?

I have an old relay card here with a dozen small relays on it. It also has a dozen little opto couplers and a dozen 2N2222A transistors and a few dozen disc caps. I yanked it out of an old Omega device with a DIO and these were outputs. Someone placed considerable time and work into this at design time years ago. :)

Ron
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
I don't understand the design of the circuit Mike did :


Can you precise the nature of the (a) and (b) inputs/outputs ? Or will my design at #17 work if I exchange the Relay with the optocoupler and modify a bit the transistor and the resistance ??
 

SgtWookie

Joined Jul 17, 2007
22,230
When using a transistor as a saturated switch, use 10 for hFE; thus a desired Ic of 160mA would require an Ib of 16ma, which would be a bit too taxing for an I/O pin on a Pi.
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
Thanks to your answers i came up with this :


Will a gravity feed system be enough to get some flowrate ? 5L / minute will be perfect ... or do i need a pump ?
Because what i found on internet, it will be very low .
 

MikeML

Joined Oct 2, 2009
5,444
The flow rate into the printer tank is a direct function of head height (pressure) and orifice diameter in the solenoid. The volume delivered is proportional to time.
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
I did a bit of search .

So Flowrate is defined by Q = v * a where v is the velocity and a the section of the hole.

in my case the hole of the valve equal 15 mm ( 0,015m )

the velicity is defined by v = √( 2 * g * h) where g is 9,81 m/s² and h is the height of the tank .

In this case i don't know i need to pick the height of the tank or the height of the tank + the distance to the valve ( because the valve is vertically feeded by a pipe situed on the bottom of the tank )

htank = 20 cm ( 0,2m ) ?[+ 2m from the pipe length ]

v = √( 2 * 9,81 * 0,2 ) = 1,981 m/s ?[ √( 2 * 9,81 * 2 ) = 6,264 ]

a = π * r ² = π * ( 0,015 / 2 )² = 1,767 * 10-4

Q = v * a = 3,5 * 10-4 m3/s = 0,00035 m3/s = 0.35 L/s = 21 L/min

It seems a bit too much is my calcul correct ?
 

MikeML

Joined Oct 2, 2009
5,444
You can always add a new flow-restriction orifice which is smaller than the one in the solenoid valve so as to make the printer tank filling take longer. You want a fairly high head pressure so that the depth of water in the header tank is a small percentage of the elevation of the header tank.
 

MikeML

Joined Oct 2, 2009
5,444
My rough calculation:

a 2m column height of water makes a head pressure of 0.2bar.
0.2bar through a 15mm orifice makes 2813 l/h, which is 0.781 l/s, which would require 5.11s to fill a 4l tank.

I would be inclined to make a smaller orifice, so that the time is a bit longer.
 

MikeML

Joined Oct 2, 2009
5,444
You cannot power the solenoids or the pump from the Pi board. You need a separate high-current power supply. You could power the PI board on the separate high-current supply provided it is no higher than the max allowed input voltage for the Pi board.

If it takes less than 16mA to turn on the optocoupler, you do not need the ULN....

If you need the ULN, you can should be able to "borrow" it from the PI board without needing an extra 5V supply.
 

Thread Starter

Deathyzz

Joined Feb 16, 2015
18
yeah i know for the pump and the solenoid , that's why i use a relay board, i didn't show it here but there is a other power supply 12VDC connected to the relay on the right of the relay board.

i picked a extra supply because i will certainly use a 8 CHANNEL board channel and will surely need to active more than 1 pin at the same time. And i read i was better to use a external power supply .

PS : the PCB817 ( optocoupler ) need 20 mA
 
Last edited:
Top