1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

BarMixVah Plus

Discussion in 'Projects' started by mark tomlinson, Aug 21, 2014.

  1. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    So, another project that we have been working on off-and-on is a Barmixvah.
    However, we decided hooking it up to a PC/Laptop was wrong. Just wrong. So we decided to use a Raspberry Pi with an Arduberry adapter board for all of the programmartic I/O. Rather than use his NodeJS routines (which were lame) and the non-program-program on the Arduino side (lame squared) we just tossed all of that and are writing it new (in python, for the Pi).

    Not completed yet, but getting there. All that is waiting now is the time to program it (more so since some of the other projects got to a better state of 'done')



    20140821_172333[1].jpg 20140821_172319[1].jpg 20140821_172310[1].jpg
     
  2. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    All of the code will be available for this in case anyone else wants to tackle this. I'll post it here.
     
    Greg Howard likes this.
  3. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    So, just to sort of document the process.
    You need to have the Pi configured for development and some libraries installed and rather than document this (rather tedious) process I will simply clone the SD card we are doing all this on when it is finished and make that image available to anyone who wants to do this.

    Once we had everything installed at the OS level then we could start the GUI work (I did all of this via Cygwin on my PC rather than bothering to have a monitor attached to the Pi). First step was to install the Arduberry libraries (from github) and then the Arduino GUI for the PI. Then you can start writing the ArduBerry code (screw it, I am calling it the 'Arduino' from this point on). In reality the Arduino code will be rather simplistic. There are 5 motors it can run (on/off). So the recipe for the drinks will essentially be a string of commands which specify the motor to run and how long (i.e. M1S5 or something similar which we can then translate into "run motor 1 for 5 seconds, etc.) We will concatenate these together to form the entire recipe, pass that to the Arduino and let it do the mixing. The Pi will handle the GUI and the 'database' of drink recipes. All it will need to have stored configuration wise is which ingredient is attached to which pump motor. The the db stores the recipe. Given that we will have a configuration table that holds the current ingredients attached and then the base drink ingredients table along with the recipe table (not sure we will get too fancy here, it is a Pi and something simple like Mongo for the db, not a E5000 running Oracle).

    Attached screen grab just for reference of what this fun looks like :)

    Will be doing the schematic for this in TinyCad (same for the falloout gun). It is a great free schematic cad.

    Initial testing with 5 LEDs tied to the arduberry (to simulate the 5 motors) works fine.
    Will use that for the duration of the code creation and testing since that is easy enough to check (just count how long the LED is on for and which one).

    Edit: Coding moving along well, painful having to swap to/from PC for debugging, but that is embedded for you. Video of LED testing for Pi + Arduberry. The LEDS will be replaced with drink pump motors.

    https://plus.google.com/u/0/106716362712432040361/posts/HgXbu6P4uMg
     

    Attached Files:

    #3 mark tomlinson, Aug 24, 2014
    Last edited by a moderator: Aug 24, 2014
  4. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Arduberry code done.
    Testing done.

    Handed off to my son to write a Python GUI for the Raspberry... All that will be left then is hooking up the ingredients and having a drink.

    It was interesting working with the embedded 'arduberry' (essentially an Arduino shield for the Pi). Running the Arduino programming tools on the Pi worked surprisingly well.
     
  5. Technidyne

    Technidyne Active Member

    Joined:
    Apr 18, 2014
    Messages:
    229
    Likes Received:
    229
    Mark
    Thanks for the big kick in the butt to get started! ;)
    I always wanted to work with Arduino but kept putting it off. After seeing this, it gave me the inspiration to start. Just ordered this kit and I should be off to a good start.
     
    2 people like this.
  6. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Nice. That is a great starter/start-up kit.

    It took some getting used to, but in hindsight the development tools for the arduino on the Pi are actually pretty sweet. It is really much the same as what is available on the PC (a wee bit different it how it connects to the controller and use of the serial port is different).

    I had done a few projects on the PC with the 'duino, but this was my first attempt at using one embedded in with a Raspberry.

    The only things weird about the Arduino (code wise) are timers and the threading model. You can't get it too busy doing any one thing or it will sort of hang up other things :confused: It is perfect for process control. If you needed more horse power then you would use a megaduino or something similar to what drives the Robo.

    Still, a lot of fun to play with.

    I will be posting all of the code (the Pi code and Arduino code) for this here as soon as it is completed.
     
  7. Technidyne

    Technidyne Active Member

    Joined:
    Apr 18, 2014
    Messages:
    229
    Likes Received:
    229
  8. Steve73

    Steve73 New Member

    Joined:
    Aug 22, 2014
    Messages:
    27
    Likes Received:
    4
    MARK thanks to you and all your help..... I got my first success story...... its the logo for my uncles MS team.... TEAM HAMMER this is very small but im gonna be making a lot of them.... not bad for 2 days in..... few more tweeks to make and ill have it nailed down now
     

    Attached Files:

    • H1.jpg
      H1.jpg
      File size:
      42.4 KB
      Views:
      24
    2 people like this.
  9. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Awesome. Glad to see you are off and printing! It is a constant cycle of print, learn, tweak and print more :)
     
  10. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Arduino code attached (the Arduberry in this case, but it is generic arduino code).
    I am not certain if this was the final rev I tested or not, will update it once the entire unit is functional, but if anyone is interested here it is.

    There were some interesting 'gotchas'. For example the Pi version of the Arduino programmer uses the I/O pins 10-13 to 'talk'/program the Arduberry (not the 'serial port' since that is the USB cable the Pi is attached to) so you need to avoid using these if possible (would have been nice to know up front). Debugging it is 'interesting' (in the Chinese sense of that word) hence the debug flag for spitting out a diagnostic stream.

    I invented my own 'barman' protocol for the encoded data the Pi passes to the Arduberry. It looks like this:

    "![M1]5000[M2]4500[M4]1900!*"

    which reads as motor 1 run for 5 seconds, motor 2 run for 4.5 seconds, motor 4 run for 1.9 seconds, etc.
    This comprises the recipe for a given drink. Easy to parse apart and use.
     

    Attached Files:

  11. Dbeal

    Dbeal Active Member

    Joined:
    Jul 10, 2014
    Messages:
    110
    Likes Received:
    84
    I want to make this even though I dont drink!
     
  12. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Nothing says you can't use non-alcoholic ingredients :cool:
    When finished we will have a UI across the DB where you can add ingredients, recipes and configurations.
    Perfect for a touch-screen (although the touchscreens for the Pi are a tad more than I am going to invest initially).
    Eventually.


    Will be using SQLITE3 for the database.
     
    #12 mark tomlinson, Aug 26, 2014
    Last edited by a moderator: Aug 26, 2014
  13. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,275
    Great stuff mark. Definitely watching this.
     
  14. Mippen

    Mippen New Member

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Really love this. Whats the status?
    Would it be possible to get an Pi Image to test with?
    Or do you have a "tutorial" for the Pi setup?
     
  15. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Will be happy to post a Pi SD card image. Let me make a current copy and let me know how you want to get it (8 gb sd card, not sure that they want me to zip and post that here).

    At present my son is still writing the GUI (in Python) and it is taking a bit of time since school and work interfere :cool:
    Well, and he is new to Python (like myself he is more of a C++ fan). He has some basic stuff done (the database routines are started). So the code for the Arduino is complete (see above posts) and the UI/db code is still being written. I have been reluctant to jump in and take over since he really needs the 'experience'.

    The UI will handle the db and user interactions (i.e. here is a list of recipes that I have ingredients loaded for). The database will maintain a master list of recipes, ingredients and the current 'config' (what ingredients are loaded for mixing). It will be fairly simplistic since ultimately the idea was that it would be targeted for a smaller touch screen.

    I can post what is done with a list of instructions and what is not yet done at any point. (quite honestly the 3D printing part was the simple and quick stuff).
     
  16. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    P.S. a Python 'guy' could probably knock this out tout de suite. Since this is a Python guy in training it may take a bit longer.
     
  17. Mippen

    Mippen New Member

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Is the "original" gui from Barmixwah running in the background?
    Or is it a complete new implementation of the gui?

    How does the PI communicate with the Arduino? Serial port?
     
  18. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Technicalese alert : The original GUI from barmixvah was a set of NodeJS pages that would really only work on desktop linux. I tried (like heck!) to get NodeJS and Mongo all running on the Pi, but the support for the serial port just doesn't work in that environment. The serial port drivers are bjorked (as far as NodeJS and the like are concerned at any rate). For a PC this was really chump-change stuff, but for a Pi you needed to be able to get some heavy-weight layers running. I guess when all you have is a hammer... (everything looks like a nail).

    So it was much more light-weight to just write the UI* in something Pi friendly (Python, C, C++) and so we went with Python for more general compatibility. I figured we would just start from scratch and go with a new UI. Work In Progress :)

    The Pi and the Arduino... now that is an interesting question. We went with an Arduino embedded INTO the Pi :) Yep. Recursive embedding.
    We used this: An Arduberry (click the link). It is an Arduino that mounts as a shield onto the Raspberry Pi (neat, huh?) and provides TTL output via the Arduino I/O. It talks to the Raspberry via the serial port for normal 'stuff' and you run the arduino IDE on the Raspberry to program it (via some of the GPIO pins, not the serial port like you would from a PC). Cool as crap really.

    So I completed all of the Arduino code and now the UI is getting built for the Pi (to talk to the Arduino, to talk to the Barmixvah--TahDah!) and hopefully will be done soon.

    *For the new UI I was anticipating screens to let you add/edit data in the database for recipes and configuration (which ingredients are mounted on which motor/IO port for the Arduino). Then screens to present the available recipes. You pick a drink, the recipe is pulled from the db, a string built using the configuration data as a guideline and this is tossed over to the Ardunio to act on (something like the above example: "![M1]5000[M2]4500[M4]1900!*" as I explained there...) The Arduino takes that, parses it and then drives the appropriate motors for the appropriate time. (really, IMHO, the Arduino code is simple, stupid and straight-forward). The only thing that might change is that we may run the motors for the recipe in parallel (current code runs them sequentially) but that will happen after the UI is up and done. I guess if you make a Long Island Iced Tea having all the motors running at once would be *cool*

    If you have any ideas, toss 'em over it is not done yet. If you want it as it currently is, I can post what is there. Hopefully another week of code will get him wrapped up to where it is usable, but I can't promise--school and work come first.

    (I can probably share the Pi Image via DropBox or Google Drive, if you want to try that, let me know)
     
    #18 mark tomlinson, Sep 3, 2014
    Last edited by a moderator: Sep 3, 2014
    OutsourcedGuru likes this.
  19. Mippen

    Mippen New Member

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Nice work!
    As I have a couple of Arduino boards laying around I hope to be able to use one of those.
    The Arduberry looks nice.. Will take a closer look at it but for this project I hope to be able to reuse a "normal" arduino.

    I guess it would be possible to program the Arduino from a PC as "normal" and then hook it up to the Pi?
    The String looks nice and clean.. To "optimize" the Arduino, just as you mention, each motor data could be loaded in the arduino,
    a timer starts from the highest number (most liquid) and then adds more and more motors as the timer counts down.

    But.... as it minimize the time to get a drink, one also might like an "override" to be able to set the order of ingredients.
    Some drinks does not like to be "brutal" mixed.. and can look cool if they are sequentially added.
     
  20. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    21,544
    Likes Received:
    7,062
    Sure, that would work as well, you just have to work out the interface. With the Arduberry you get the GPIO pins used for the programming and the serial port for programmatic/data/output stuff. You could hook them up manually the same way as the Arduberry, but you would want to use their drivers then (all open source if memory serves). Trying to use strictly the serial port for everything would likely not be very effective. As long as the communication between the Arduino and the Pi is purely through GPIO pins then there is no reason this would not work. The Arduino would not be able to serially communicate with Pi, but that might not matter.

    At the end of the day it is a 23 dollar shield (effectively) and works nice for this type of layout. Could you just do it all with the Pi? Sure, but the I/O is different and would be a bit more work to interface. For the price I just went that way.

    Either way, all the code will be available (as you can see the Arduino code already is) just as soon as it is done :)

    I guess I need to consider an easy way to host the sd card image as well.
     

Share This Page