Im using ball valves controled by a H bridge for a home brew set up.
Ive seen this posted on another web site
" All my electric ball valves are going to be switched using an H bridge. They are all two wire valves, EG they open with forward voltage and close with reverse voltage. I have made sketches in Arduino that allow me to fake proportioning(sorta) using a PWM to control the speed and a time to control the total opening/closing of a valve. The valves i have i can get to position reliably and repeatably using this method "
This would be very usefull but i havent the first clue how to sketch it.
Can any one give me a shove in the right direction please ?
Do some experimenting with the valve you have selected. Find out how long it takes to completely open and close the valve. Then divide that time by the number of "steps" you want to have the valve stop at. I would start at about 10 steps. Each time period should open or close the valve by about 1/10th of the total.
OK so if i have 10 positions can i call a position, lets say i have a valve at position 5 i want position 8 can i do that with out a mountian of code.
Im thinkin i can do a "current position" and "requested position" and do some simple maths to decide what direction to move in and how much but thats gonna be a lot of code would i need to code every eventuallity or is there a way to do this
Yes, you've almost done it, except for the first line: If requestedpos == currentpos , do nothing, it's already there! and the logic to tell the valve which way to move and for how long/far.
gosh, I hate to be the one to bring the bad news......
ball valves are not even close to being linear. you might have to close it about 80% of the way before you see much of a change. then all the throttling will be in that last 20%. in other words, 80% of control is in 20% of the span.
there a formula you should look into and understand. google water valve sizing. you will quickly become acquainted with coefficient of velocity of Cv. Get your spreadsheet dusted off.
one point to consider is the port size. you may think you have a half inch water line so you should use a full port valve. this means that when open the valve, it offers no reduction is diameter. control is all about reduction in the opening. you can buy reduced port valves and start out with a higher level of control. or reduce the pipe even smaller as needed.
remember, time is on your side. no really. Time. You open a valve for a second, you get a little volume, open it longer, more volume. timed opening can help where throttling will not.
Pesho77:
OK so this is just to control flow i need about 60L / Hour ( 1Ltr/Min) so i have a hall sensor to read flow rate already, so i can just do
Not exactly. Remember "If it ain't broke, don't fix it!" Try:
if flowRate > 1 // Ltr / Min
//do nothing if the flowRate is =1 (it's correct, don't change it)
requestedpos = currentpos - 1 ,
// move the valve
currentpos = requestedpos //keep track of position
Else if flowRate < 1 // Ltr / Min
//do nothing if the flowRate is =1 (it's correct, don't change it)
requestedpos = currentpos + 1
// move the valve
currentpos = requestedpos //keep track of position
You'll also need to check that you're not trying to move the valve past the 'fully open' or 'fully closed' positions.
You'll also need to check that you're not trying to move the valve past the 'fully open' or 'fully closed' positions.
[/quote]
This is a good point, i plan to have all valves closed at the start so there always running up to volume not reducing flow so they shouldnt get too much past 1 Ltr/min. they wont physicaly drive if there at limit anyway.
Im planning using
if flowRate = 0
// close valve (ie pin 1 HIGH, pin 2 LOW) or which ever way there wired.
then after cleaning ill have to drive all valves closed ready to start the next batch.
So i can get this to open or close a ball valve that's easy enough but how do i get it to stop,
Lets say i want to pulse the ball valve to slow down opening to 1/4 or 1/2 second pulse's would i turn the "enable pin" on and off
digitalWrite(enablePin, HIGH);
delay(250) // or (500)
digitalWrite(enablePin, LOW);
Delay(250) // or (500)
This sketch is for a rims pump that should run between 2 -3 Lts's / Min and needs a slow run up if i detect a blockage in the sysytem (coz im working with a slurry) i need to stop the pump and re-run up to 3 Ltr's / Min
so ill do some thing like
if (currentflowRate <= lastflowrate - 2 )
PumpRunning = 0 , // Stop pump
pumpblocked ++ ,// Add 1 to pump blocked (this is displayed on a TFT screen)
// Close ball valve
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
delay(10000),
PumpRunning = 1;
The pin1 HIGH and pin 2 LOW still needs tested but i can change that easy enough.
const unsigned long PERIOD1 = 250; //1/4 second
Timer t;
// set enablePin LOW so that motor is off:
digitalWrite(enablePin, LOW);
t.oscillate(enablePin, PERIOD1, HIGH);// Turn ball valve on or off every 1/4 second
if (currentflowRate <= lastflowrate - 2 )
PumpRunning = 0 , // Stop pump
pumpblocked ++ ,// Add 1 to pump blocked (this is displayed on a TFT screen)
// Close ball valve
digitalWrite(motor1Pin, LOW); // set leg 1 of the H-bridge low
digitalWrite(motor2Pin, HIGH); // set leg 2 of the H-bridge high
delay(10000),
PumpRunning = 1;
Will stopping your pump for 10 seconds clear the blockage, or do you need to flush the system with water? Are you restarting the pump against a closed valve? That doesn't sound like a good idea. Maybe I've got your idea wrong. A rough drawing of your system (pumps, valves, pipes, etc.) and a description of what you want it to do would help.
Stopping the pump wont clear the blockage but its the best plan i have, i do wnat to run the pump against a closed valve then slowly open it, hoping this alows the blockage to run through the pump.
The pump i have will only pump at 15Ltr's / MIn i need 3 and the pump head is 8M i need 0.5 M so i have to control the pump some how .
I cant seam to upload an image but the pipe works just a tank out let a hall sensor to a tee on one side of the tee is a pump back in to the tank with a ball valve , on the other side of the tee an out let the ball valve leading to the next tank.
So 1 hall sesor, 1 pump 2 ball valves one to control the flow and one on the system out let.
Can you not control a pump and one valve based on the level of liquid in the tank? If the level of the liquid falls below a certain level, start the pump. If the level of the liquid rises above a certain level, stop the pump. If the pump is blocked the level will fall below the minimum and you stop the outflow by closing a valve. A hand valve is used to adjust the rate of outflow, but once set to the right rate, will never need to be readjusted. That way, your pump is either on or off and your one controlled valve is either open or closed. Much simpler that continuously adjusting rates of flow. The level of liquid in the tank can be measured in several ways, but the easiest is by some kind of floating device. Look inside your toilet cistern to get the idea.
opening the valve would let the blockage pass, but if it is at the pump it might need human attention.
on some systems the run the pump full throttle all the time and have two valves or a 3 way valve. one allows re-circulation so the pump can operate in the work envelope of the impellers. with insufficient flow they may not be able to operate properly.
of course that would mean your flow sensor would need to be on the valve line.
of course if there is a system failure, some form of alert would be in order.
The best way to deal with the blockage is to not create one in the first place so a very slow run up of the pump is needed, there is a screen between the solid particles ( the malted grain) and the tank outlet to help prevent creating a blockage .
But putting too much pressure (suction) on the grain is a bad idea too as this wil reduce the over all efficiency of the mash.
So i need a slow controlled run up then to run continuously for about 1 hour, if i get a blockage i need to stop the sytem and restart, but hopefully cn avoid creating a problem in the first place rather than have to deal with it.
No the pump i have cant be controled by pwm, so i was thinking i should just get another pump, but it needs to be pwm controlable, food grade, able to take 100c heat, easy to clean small enough to fit my kit and a reasonable price, and if i can find one i don know that it can pump liquid up high enough at low power to do the job any way.
So i think using a ball valve the best solution for now this can be changed if i can get a pump i know can do the job.
I think somebody already suggested this but in case you didn't pick up on it, I suggest that instead of using the valve to restrict the pump output you use it to open a recirculation path. This means that even in the 'no output flow' condition the pump runs at full flow with no restriction, so there is no pressure drop across it and it is receiving maximum cooling and generating minimum heat - this is also the best way to ensure the pump doesn't clog.
Ive been tryin to do this with out having to teach people how to brew, the advice im gettin here is (mostly) excellent advice but some just wont work (not with my set up any way) using a second recirculation path would only increase the pressure on the grain bed this would allow the liquid to flow round the bed and not pick up the sugars there.
This process is called a "mash" to mash we step grains in water at around 65c for 1 hour, the grains sit on a screen called a false bottom, liquid is drawn from under the false bottom out through a pipe via a pump and back on top of the grain bed ( a temperature sensor may be placed inside this pipe work to take a more accurate temperature read from the liquid rather than the slurry) this recirculation is called RIMS (recirclation infusion mash system), tiny particles may pass through the false bottom but are deposited on top of the grain, the grain itself creates a filter for particles and clears the liquid.
If the hydraulic pressure is too high the grain bed compacts causing liquid to flow round it (not through) this reduce's mash efficency.
This is what im trying to aviod i just need a slow run up of the pump to do this, this set up is a standard set up for home and comercial brewers, so i know it can work.
I hope that helps explain what im tryin to achieve