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

Dependencies:   EthernetInterface WebSocketClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
sdhingra
Date:
Tue Dec 09 00:10:29 2014 +0000
Commit message:
Initial Commit - BarBot

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4dcc14de1899 EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Tue Dec 09 00:10:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#de796e2a5e98
diff -r 000000000000 -r 4dcc14de1899 WebSocketClient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Tue Dec 09 00:10:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/WebSocketClient/#466f90b7849a
diff -r 000000000000 -r 4dcc14de1899 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Dec 09 00:10:29 2014 +0000
@@ -0,0 +1,150 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "Websocket.h"
+#include "stdio.h"
+#include "string.h"
+
+//Used to Log to the PC
+Serial pc(USBTX,USBRX);
+
+//Input Pin for the Paddle Wheel Flow Meter
+DigitalIn pulse(p8);
+
+// Pin Outs for Solenoids
+DigitalOut Ctrl(p9);
+DigitalOut Ctrl2(p10);
+
+//
+#define PULSE_VOL 4.50 // More flow due to angle of paddle wheel Pour 1
+#define PULSE_VOL2 6.75 // Less flow due to angle of paddle wheel Pour 2
+
+//Function Declarations
+void pourOne(float milliliters);
+void pourTwo(float milliliters);
+
+/*
+    The main function opens a web socket client and listens for a preset series
+    of recipies. If one is found, it calls functions to pour liquid.
+*/
+int main() {
+    pc.printf("Starting BarBot!\r\n");
+    
+    // Close Both Solenoids
+    Ctrl = 0;
+    Ctrl2 = 0;
+    
+    // Receive Buffer
+    char recv[30];
+    char recipe[] = "Rum & Coke";
+    char recipe2[] = "Whiskey Ginger";
+    char recipe3[] = "Whiskey Neat";
+    
+    // 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);
+
+            // Recipe based process
+            if(strcmp(recv, recipe) == 0) {
+                pourOne(132);
+                pourTwo(44);    
+            }
+            else if(strcmp(recv, recipe2) == 0) {
+                pourOne(0);
+                pourTwo(88);   
+            }
+            else if(strcmp(recv, recipe3) == 0) {
+                pourOne(88);
+                pourTwo(0);
+            }
+        } 
+        
+        wait(1.0);
+    }
+    
+}
+
+void pourOne(float milliliters) {
+    
+    pc.printf("Pour One\r\n");
+    
+    //pouring an empty amount (neat drinks)
+    if(milliliters <= 0) {
+        return;    
+    } 
+    
+    int pulses = 0;
+    bool lastPulse = pulse;
+    bool thisPulse;
+    float volume = 0;
+    
+    //open solenoid one
+    Ctrl = 1;
+    
+    while(volume < milliliters) {
+        thisPulse = pulse;
+        
+        //check to see if pulse has changed since the last time
+        if(thisPulse != lastPulse) {
+            pulses += 1;    
+        }
+        lastPulse = thisPulse;
+        
+        //increase the volume
+        volume = pulses * PULSE_VOL;
+        
+        pc.printf("Poured %f From First Bottle\r\n", volume);    
+    }
+    
+    
+    //close solenoid one
+    Ctrl = 0;    
+}
+
+void pourTwo(float milliliters) {
+    
+    pc.printf("Pour Two\r\n");
+    
+    //pouring an empty amount (neat drinks)
+    if(milliliters <= 0) {
+        return;    
+    } 
+    
+    int pulses = 0;
+    bool lastPulse = pulse;
+    bool thisPulse;
+    float volume = 0;
+    
+    //open solenoid two
+    Ctrl2 = 1;
+    
+    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_VOL2;
+        
+        pc.printf("Poured %f From Second Bottle\r\n", volume);    
+    }
+    
+    //close solenoid two
+    Ctrl2 = 0;
+}
\ No newline at end of file
diff -r 000000000000 -r 4dcc14de1899 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Tue Dec 09 00:10:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
diff -r 000000000000 -r 4dcc14de1899 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Dec 09 00:10:29 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file