Open/close ball valve with Arduino

Hi all,

I'm a homebrewer (beer) looking to automate the bottle-filling process. My plan is to connect a cheap cordless drill motor (9v) to a ball valve, then use an Arduino to tell the motor to do quarter-turns to open and close the valve. I've never programmed a microcontroller before, though I'm plenty comfortable with basic scripting on the computer, and my electrical knowledge is limited to a few trips to Radio Shack to put together some light bulbs and switches for school dioramas. :slight_smile: So I'd really appreciate some advice...

First off, I've read a bunch of the threads here, and I understand I'll need an opto-isolator to prevent the Arduino from getting fried by the motor's power supply. Does that mean I'll be plugging two things into the wall? Will I be able to send "Turn clockwise, stop. Turn counterclockwise, stop." through the opto-isolator? Or does that depend on the motor?

Thanks all, I'm pretty excited to get to try programming a motor for the first time! :smiley:

That's a pretty complex way to turn a valve 90 degrees. You would probably get by simpler with a R/C type servo that is rated for the torque requirments for the valve in question. The Arduino platform has servo library routines for controlling servos.

Lefty

Hmmm, I hadn't heard of them. Ball valves can be a little tough to turn, is there any way I could measure the torque required before I start buying servos?

Also, do you know of any way I could get the Arduino to sense when the bottle is full? There won't be a lot of space in the neck with the fill tube in there, but someone suggested having the liquid complete a circuit somehow.... hmm.

Okay, I found some specs online, and it looks like most ball valves under 1" are between 35 and 80 lbf/in. Servocity.com hardly has any servos with that much torque, and the ones they do have are over $100. So I'm back to looking at converting my (free) cordless drill motor, which I assume has plenty of torque to do the job. Will I be up a creek without those servo libraries? Do you need libraries to be able to tell a motor to turn both clockwise and counter-clockwise?

I found this with the Google, looks almost exactly like what I want to do, except they're using a valve that needs 4 complete turns instead of a quarter-turn ball valve: http://www.parallax.com/tabid/323/Default.aspx

You need some way of detecting how far the motor has turned and command it to stop when it has reached the required position.

If this is a multi turn motor then some form of rotation counter optical or magnetic are usually favourites. If it is less than a fill turn then limit switches are useful and these could be mechanical micro switches in addition to the magnetic and optical switches of a multi turn system.

If you really wanted to isolate the circuits, you could get one servo to push the button on the drill and the other to flip the switch to change direction. Assuming you haven't taken apart the drill yet. You could also use a relay.

Ok cool, so like a rotary encoder switch? I'd hook that up somewhere in the system, and have it send signals back to the Arduino to let it know when to stop. Sounds good.

I like the idea of using servos to operate the drill like a human would, but I'm wondering if I can go halfway and have the Arduino interface electronically with the controls on the drill. When I open it up, maybe there will be obvious contact points for the forward/reverse switch and the trigger. Or not. We'll see!

Another way to sense open/close is to measure the current draw. A stalled motor would draw more current. Place a small (0.1 ohm 25 watt) resistor in the ground side of the motor and use an A/D line to measure the current draw. To determine what the current draw is over time, write a small loop that waits for a switch to be closed, starts the motor turning and starts logging the current (voltage from the A/D). Once the motor has stalled, view the log to see what the current over time looks like. I suspect you will see a high current spike at the start of the run followed by low current and then high current again at the end. Now program the open/close to ignore the initial high current and wait for the current to increase signalling the end of the cycle. Reversing the motor can be accomplished with relays if you don't want to use the servo method described elsewhere.

Or you could find an old refer somewhere and yank the solenoid valve out of the ice maker and use a solid state relay to turn it off/on to control water flow.

Jim.

Okay, so here's what I'm working with. I'm thinking I'll be able to use the drill's chuck to attach this to the ball valve, which is cool, cause I have no idea how I'm supposed to connect things to the smooth cylinders most hobby motors have for shafts.

Motor and switches:

Closeup of switches:

So this just controls the forward/reverse, and the amount of current being delivered. I plan to replace both switches with ones that can be controlled by the Arduino somehow. Can anyone point me in the right direction for parts? I've never used anything but physical switches, and there's going to be a decent amount of current running through this (9.6v, ?a).

So then it's just a matter of figuring out how to measure how far the motor has rotated, and badda-boom! I'll be bottling that beer in no time. :slight_smile:

I'll be bottling that beer in no time.

Wanna bet? :wink:

You will need a full blown H-drive motor driver circuit rated at the motor stall current for safety. Then you'll have to figure out how to attach the motor/gear train to your valve, which looks like a real headache. And then of course you will have to work on the feedback hardware.

Like I said a bit complex, especially for someone pretty new to electronics.

So again, a high torque servo might work:

http://cgi.ebay.com/GWS-S136GM-Landing-Gear-Retract-Servo-for-Aircraft-NIB_W0QQitemZ230330154491QQcmdZViewItemQQptZRadio_Control_Parts_Accessories?hash=item35a0bf3dfb

And as you probably don't need adjustable flow you could consider solenoid operated valves. Example:

http://cgi.ebay.com/1-2-Gravity-Feed-Electric-Solenoid-Valve-DDT-CD-240VAC_W0QQitemZ300351271912QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item45ee54b3e8

OR

http://cgi.ebay.com/1-4-Electric-Solenoid-Valve-12-volt-Air-Water-BBTF_W0QQitemZ300348191408QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item45ee25b2b0

I would go with the solenoid operated valve. No feedback required.

Question? How will you know when the bottle your filling is full and to turn off the valve? Simple timing probably won't cut it as the head pressure will change as you remove stock from it and therefore the fluid flow pressure will change as your source head pressure decrease. Or are you going to have a constant regulated pump moving stock through the valve?. I think the big beer masss production lines meassure the weight of the filling bottle to determine when to stop filling?

Your move brewmaster ;D

I need a beer after all that....

Lefty

Haha, okay, thanks for the reality check. And that second eBay link you gave me is PERFECT. I'd been looking all over for a part like that.

Okay, so here's my idea so far, then: - YouTube

So the beer comes from the big white bucket, and is pumped up to the filling rack. The raising and lowering of the fill tubes would be done by hand, but the actual filling would be done by pressing a start button, which would start a timed flow from the pump (on the floor in the animation). One of the solenoids from retrolefty's eBay link would turn the flow on/off. The Arduino is on the wooden rack above the fill tubes, next to the buttons.

What I'm pretty sure won't work in this setup is the six-tube manifold. I assume that the first bottle will fill a lot faster than the last one, right? Or will they fill evenly if I pump the beer in at a high enough pressure? Is there any way I could set this up to get all six bottles to fill evenly?

Damn, just read the part about the timing changing. Does that happen with pumps, too?

Measuring the weight is an interesting idea... especially if I can get all 6 to fill evenly. I'd only have to measure the weight of one.

darn, just read the part about the timing changing. Does that happen with pumps, too?

Probably not, as the pump should supply a pretty constant pressure. However pumping it might cause the beer to foam really bad while filling which could be quite a problem, no?.

Most project like this I've run across just use gravity feed where the beer tank is higher then the bottles to be filled and gravity via head pressure causes the beer to flow. The manifold flow to four bottles at a time might be OK but I'm still not sure that a simple timing function will accurately fill the bottles to the correct level.

You probably should work out and test all the mechanical and process flow stuff manually first and then work on automating it.

Unless you find a proven project where someone has worked out all the details you really have picked a pretty ambitious project to figure out on your own.

Have a few brews and think it over some more. :wink:

Lefty

dube posting

Okay, after an hour in the Home Depot plumbing aisle, I tested the manifold system today:

It's not 100% perfect, but I wasn't expecting it to be at this point. The important part is that the water is making it all the way to the end... it'll just be a matter of fine-tuning the valves once the pump arrives next week. For today I used a 10 foot gravity feed, which should be about 4 PSI, less than the pump I ordered. It's a diaphragm pump, very gentle on the liquid, and safe for drinking water. I know people use it for transferring wine to barrels.

I think this is going to work! Fun stuff. :slight_smile:

Aja,

It sounds like you're going to a lot of trouble to reinvent the wheel, er, valve.

A simpler (but possibly more expensive) solution would be to use a solenoid valve. This is an electrically operated valve, which, with some additional circuitry, could be controlled by an Arduino. Google 'solenoid valve' for lots of hits. I'm guessing you could find a food-grade valve that wouldn't hurt, or be hurt by, the beer.

If you really want to go high-tech, put in six solenoid valves, one for each bottle, and six optical sensors to detect when each bottle is full, so you know when to shut off that bottle's valve. You might even be able to have the optical sensor detect the presence or absence of a bottle, so you could fill fewer than six bottles, since it wouldn't turn on the valve if a bottle weren't present.

I'm looking forward to seeing the video of the finished product, however you do it! Just thinking about it is making me thirsty!!

-Mike

I totally agree, I'm going to go with this solenoid that retrolefty suggested: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=290351616928#ht_2016wt_779

The pump and some hose barb adapters will arrive next week, and then I'll find out if the timing plan will work, or if I'll need to set up some weight sensors or something to automate the shutoff. Either way, this is going to be a much better system than the way I bottle beer now. :slight_smile:

I think this is going to work!  Fun stuff.

Nice start. Damn I'm getting thirsty. ;D

Lefty