Introducing iZac, the Android Bartender
Posted by Nick Johnson | Filed under iZac, android, barbot, adk, arduino
In a previous post, I alluded to a larger project I was working on in the physical/electronics/maker world, and now after much development, I'm pleased to present iZac, the Android Bartender!
A while ago I was inspired by Drink Making Unit 2.0 by Evil Mad Scientist Labs, and decided I wanted to build my own barbot. In this post I'll go over the high level details of what I did and why I did it.
One problem with any drink-dispensing machine is the difficulty of sourcing parts for interacting with food liquids. Pumps are expensive or impractical, valves are likewise problematic and difficult to obtain. My original intention was to use syringe pumps - effectively a DC motor hooked up to a threaded rod that pushes a syringe plunger in and out - and that was the reason behind my making the motor driver shield I wrote about previously. Unfortunately, syringe pumps turned out to be too fiddly and unreliable to use for the barbot, so I had to look for an alternate solution.
I ended up using a similar approach to that used by the DMU2.0, employing a battery powered aquarium pump to pressurize the bottles. For the outlet, however, I've taken an entirely different approach, and designed and fabricated my own laser cut pinch valve design. Pinch valves are handy because they don't require interrupting the tubing through which the liquid flows, and hence they're perfectly foodsafe. They're also simple to build (assuming you have a laser cutter) and quite cheap - just the cost of some acrylic and a cheap micro servo (about $5 per valve all up).
Since the flow rate depends on a large number of factors, including how much liquid is in the bottle, how much pressure has built up, and what the viscosity of the liquid is, I also needed a reliable way to measure the amount dispensed. The simplest way to do this is also the most accurate: digital scales. Digital scales typically use a load cell. A load cell is a piece of material that bends slightly (typically steel with a hole bored out in the critical section), with variable resistors top and bottom forming a wheatstone bridge. The result of this is that if you apply a voltage on two of the pins, the other two pins will exhibit a similar output voltage, with one pin slightly higher and one slightly lower depending on the load on the load cell. Load cells are available cheaply - less than $10 for a precision 1KG one, which was ideal for this project.
The difference between the two output pins is very small - typically on the order of 1 millivolt per volt of input at full load, or just 5 millivolts difference if you're using 5 volts input - so obviously it's not practical to connect the output directly to a microcontroller. Some sort of amplifier is required, and fortunately there are several made for precisely this purpose. The one I ended up using is the INA125 (PDF), and it has several advantages: It's very precise, provides a built in voltage reference to power the load cell from, and requires only a single external resistor to set the desired gain. It's also cheap - less than $5 even in small quantities. The output of the INA125 can be fed straight into the analog pin on a microcontroller like an Arduino.
Having something merely workable wasn't enough, however - I wanted something theatrical! One of my workmates made the excellent suggestion that the bottles could be placed on a turntable, with one spout per bottle, and the turntable could rotate to present the appropriate spout above the glass before dispensing the liquid. This turned out to be a really good idea, though surprisingly fiddly to implement. It also became quickly apparrent that one turntable for all 6 desired liquids would be too large; I settled on two turntables with 3 bottles each, on opposite sides of the scale and dispensing area. Rotation of each turntable is controlled using a 'sail winch' servo, which is capable of turning a full 360 degrees, in contrast to regular servos, which only turn at most 180 degrees.
We still needed a user-interface for our barbot, and this is where the Android came in. Android recently released the Android Open Accessory Development Kit, which is ideal for our purposes. The development board consists of an Arduino Mega with an onboard USB host for communicating with the Android device; provided libraries for both platforms make interfacing the two straightforward. My colleague Angus Lees kindly wrote the Android code (available here), and we loaded it onto a Motorola Xoom tablet so users could easily interact with it. The interface consists of a list of cocktails you can order; after selecting one, you place a glass on the scales, and iZac swings into action, dispensing liquids from the appropriate bottles. An "I'm Feeling Lucky" button picks 3 liquids at random (possibly overlapping), leading to hilarious and/or disgusting results.
The complete workflow, then, goes something like this:
- User selects a cocktail from the list.
- The Android sends a command to iZac "wait for glass", and instructs the user to place their glass on the scale.
- Once the user places their glass, the Android sends a command "dispense x grams of liquid y".
- iZac zeroes the scales and rotates the appropriate turntable into position.
- iZac turns on the aquarium pump - each turntable has one - and opens the appropriate valve.
- iZac then samples the analog input from the instrumentation amplifier connected to the scales repeatedly until it detects enough drink has been dispensed. 1024 times oversampling coupled with the Arduino's native 12 bit ADC provides 17-bit precision, providing theoretical accuracy of about 8 milligrams; due to physical constraints on the valves, real accuracy is about 1 gram without any tuning. iZac sends back regular status reports to the Android.
- Once enough liquid has been dispensed, iZac closes the valves and turns the pump off.
- The Android repeats this sequence for each liquid in the drink; once done, the user can take (and enjoy) their cocktail!
To interface the electronics with the Arduino board, I initially soldered up an ad-hoc board using a protoshield; I grew extremely tired of fiddly and messy soldering around the time I started trying to wire up the socket for the second turntable, and ended up designing a shield that I ordered off Seeedstudio at fairly short notice. They were prompt as usual, and the shield arrived even earlier than I expected. Here's a shot of it fully assembled:
In brief, the significant components are:
- In the bottom right, the INA125 instrumentation amplifier, and the socket to its right for connecting it to the load cell. The trimpot (R5) above it adjusts the load, and the diode (D1) provides the output of the reference voltage generator to the Arduino's analog reference pin.
- In the bottom left, an LM317 voltage regulator provides a regulated 6v for the servos (6 micro servos for pinch valves, 2 larger ones for the turntables).
- Up the top center and right, two 2n7000 MOSFETs switch the pump for each turntable on and off. The motors are powered from the 3v rail.
- Directly below the FETs are the two sockets, one for each turntable. These carry servo power (VCC and GND), servo signal lines (one for each servo - 4 per turntable), and motor power and ground.
Each turntable has a straightforward breakout board that breaks out the ribbon cable from the controller, providing headers for servos and the pump. A brief note on this: it turns out that regular protoboard (the type with power and ground rails and 2-pin pads interleaved) is perfect for this, with the ordering of power/ground/individual-pins being perfect for connecting servo motors.
After all the preparation, I finally got to demo the bot last week, and it went brilliantly. First, on Saturday the 5th of November, I took it to the Sydney Hackerspace for their party, where I demoed it making italian sodas by mixing flavored syrups. It got an excellent reception, and I ran out of syrup!
Taking the experiences learned from the Saturday party - primarily that to work best, the syrup has to be diluted down a bit - Angus and I demoed it again at GDD Sydney, once more making italian sodas, and once more being a hit - and running out of syrup. "I'm feeling lucky" works fairly well for sodas, with only the occasional undrinkable result, too.
Finally, we demoed it at the "Creative Sandbox" after GDD where, due to the liquor license, we were able to make "real" cocktails. This was a real blast, and we often had people crowding around waiting for their turn to try it out. Despite our stern warnings, a number of people tried "I'm feeling lucky", with usually terrible results - my apologies to the person who got 2/3 lemon juice, 1/3 campari - but the regular cocktails were generally agreed to be pretty good, for which we owe thanks to our local mixologist, Dan Nadasi.
Naturally, all the code and schematics are available online as open source. The Android app is available here, the Android source and the schematics for the shield are here, and the schematics for the turntables and pedestal unit can be found on thingiverse here.
Before I wrap up, two other things of interest. First, what did I learn, and what would I do differently in a revision 2? Let's see...
- Digital scales are a really cheap and high precision sensor, and they're easy and fun to interface with. Definitely worth a look on any application they might be useful on.
- The turntables are a neat idea, but driving them with servos may not have been the best approach. Backlash due to the way the servos connect to the turntable top means that getting the spout positioned just-so above the glass can be iffy and takes a lot of tuning. A more complicated but more precise approach for a version 2 would be to use DC motors and an optical encoder connected to a geared ring around the outside of the turntable.
- Making sodas was at least as fun as making "real" cocktails. People don't hesitate to try one, and are more willing to experiment.
- If I were building a version 2, I'd probably use smaller flasks, and a lot more of them (edit: and skip the turntables). Imagine a bot that can dispense any of two dozen flavors on demand!
- The pinch valves work well, but are a bit fiddly. I have a few ideas for a significant design revision; chief amongst them replacing the rollers with linear 'wedges'.
- The pumps are powered off the Arduino's 3.3v rail, which is a bit nasty, since that's generally reserved for logic; even with capacitors they probably inject a lot of noise. A better design would use a dedicated regulator for the pump motors.
Last of all, since the minimum order for PCBs from Seeed is 10 units, I have a few spare PCBs that I don't need. I'm happy to post these out to the first 10 people who send me an email at arachnid AT notdot DOT net. If you're thinking of building your own drinkbot, or even just something tangentially related - controlling a lot of servos on an external breakout, or interfacing a digital scale, say - shoot me an email and I'll send one your way. If you can, let me know what you've got in mind for them, and I'd love to see what you do with them once you've got hands on them. Just a couple of caveats about this v0.1 board:
- I neglected to include an electrolytic capacitor for the pump motors; as you can see from the photo, I soldered one on myself between the 3v and gnd pins. If you intend to use that functionality, you should do the same.
- Pump motors should have a reverse biased rectifier diode and a small (100u) smoothing cap connected directly across their terminals.
- The transistors are labelled wrongly (1n7000 instead of 2n7000) and following the silkscreen will lead you to insert them backwards. Ignore the silkscreen and rotate the transistors 180 degrees.
- The resistor values on the voltage regulator should be 240 and 840 - these give the same output voltage, and are easier to get your hands on, being standard values.
That's it! Got feedback or suggestions? Leave them in the comments below!
Previous Post Next Post