BarBot - The Drink Pouring Robot

BarBot is an MBED controlled robot that pours drinks. You text BarBot, and he'll pour you a drink. He doesn't even work for tips.

BarBot in Action

WebSocket Interface

The first thing that BarBot does to begin operation is open up a WebSocket client. This client connects to the prototype WebSocket server that is hosted by MBED at http://sockets.mbed.org/sid. This WebSocket server sends all incoming messages to the BarBot WebSocket client. This makes it very easy to add a new tool for controlling BarBot. In our case we used a text message based interface, as will be explained in the Backend Server section of this notebook page. Code that opens a WebSocket connection to the server can be seen below.

WebSocket Client Interface

#include "mbed.h"
#include "EthernetInterface.h"
#include "Websocket.h"

int main() {
    char recv[30];  

    // Ethernet Interfacing
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    pc.printf("IP Address is %s\n\r", eth.getIPAddress());
 
    // Open a Websocket
    Websocket ws("ws://sockets.mbed.org:443/ws/sid/ro"); //This Websocket server is provided by MBED for prototyping
    ws.connect();
    
    // Wait to receive an order from websocket
    while (1) {
        
        if(ws.read(recv)) {
            pc.printf("%s\r\n", recv);
        } 
        
        wait(1.0);
    }
    
}

Solenoid Control

Once BarBot receives a message from the WebSocket, it checks it against its library of recipes. If it matches one of the known recipes, it begins a subroutine to pour the appropriate amount of liquid from the correct liquid reservoir (water bottle). This process starts by opening a solenoid valve. The solenoid valves used require above 6 Volts in order to open, and draw around 1 Amp of current. This high power draw could not be supplied by the MBED, but is supplied by the lab power supplies, and controlled by a SainSmart 2 Channel Relay. This was wired such that sending a DigitalOut value of 1 to the input of the relay caused the solenoid to open. The two solenoids are independent, and are always opened one at a time (in order to facilitate measurement of the liquid dispensed).

Paddle Wheel Flow Meter

Once BarBot has opened a solenoid, the liquid starts pouring. In order to measure the amount of liquid that has been dispensed, both outputs are routed through this Paddle Wheel Flow Meter. Nominally, the paddle wheel creates a pulse on the output line every time 2.25 milliliters have been dispensed. However, we discovered two issues with this nominal value. The first is that the Flow Meter does not necessarily send pulses, but instead represents more of a saw wave that flips every time the paddle wheel turns some distance. This was accounted for in code by checking for changes in the value, instead of simply counting for high values, as this would sometimes get stuck in a permanent increase. Second, due to the low flow volume and air bubbles inherent in our plumbing design, the paddle wheel frequently failed to turn as it should. We tested both sides of the BarBot, and formed empirical values for the amount of liquid dispensed. While some runs are less accurate than others, BarBot can usually dispense to within 10-20 milliliters, much less than the volume of a standard liquor pour at a bar. A code snippet below shows how BarBot measures a pour.

Part of the PourOne Function

//Input Pin for the Paddle Wheel Flow Meter
DigitalIn pulse(p8);

int pulses = 0;
bool lastPulse = pulse;
bool thisPulse;
float volume = 0;
      
while(volume < milliliters) {
    thisPulse = pulse;
      
    //check to see if pulse has changed since last time
    if(thisPulse != lastPulse) {
        pulses += 1;    
    }
        
    lastPulse = thisPulse;
        
    //increase the volume
    volume = pulses * PULSE_VOL;
        
    pc.printf("Poured %f \r\n", volume);    
}

Backend Server

The backend code used to control BarBot is relatively simple, and largely outside the scope of this notebook page. However, the most import details are as follows:

When a Text is sent to the number BarBot has registered on Twilio, a connection is made to the same WebSocket server that BarBot is connected to, and a message is sent to BarBot informing it which drink to pour.

Full BarBot Source Code

Import programBarBot

This is an MBED controlled liquid dispensing robot. With applications in bars.


Please log in to post comments.