Huky Forum

HUKY 500 (T, J, SOLID, PERF) => Pictures => Topic started by: Agrajag on June 03, 2016, 06:17:05 PM

Title: My Fully Automated Huky!
Post by: Agrajag on June 03, 2016, 06:17:05 PM
After getting my DC fan controlled by artisan (https://www.hukyforum.com/index.php/topic,408.msg11378.html#msg11378) and logging stove pressure (https://www.hukyforum.com/index.php/topic,1059.msg11446.html#msg11446) I had a thought - what if I could control the gas as well? This was turning into more of a "could I" rather than "should I", but sounded like fun. Again, I didn't want to muck around with installing anything in the gas lines, so wondered if the knob could be controlled with a stepper motor? For those who don't know, a stepper motor is just a motor that can be accurately controlled. The torque required to turn the knob is very low, so I did some research and found you can get a small stepper motor for about $2. The knob on the gas can easily be taken off and adding a gear pulley to the shaft required no modifications. The gear pulleys + belt were found on ebay for about $15.

(http://i.imgur.com/5rNMlZv.jpg)

Hooked up to my arduino (lucky I got a mega, it now has 2 thermocouple interfaces, drives fan and motor) I wrote the program to control it that artisan could call. The result is this:



https://youtu.be/AjYLSC1JGC8 (https://youtu.be/AjYLSC1JGC8)

:D :D (yeah the control box is still in "prototype stage". And I'm no woodworker :-[)

I then had a poke around artisan (the documentation leaves a bit to be desired) and found that by using the Alarms functionality, I could set fan/stove at certain times during the roast. This is pretty powerful. This means I can have a Fully Automated Roast! For example, here's a set of alarms that are setup to follow Gregr's guide to achieving a Rao Curve (https://www.hukyforum.com/index.php?action=ezportal;sa=page;p=24):

(http://i.imgur.com/tT5hxb6.png)

Now all I have to do is load/drop the beans! Oh yeah.. and find that "god roast".
Title: Re: My Fully Automated Huky!
Post by: Crzyworm623 on June 04, 2016, 04:46:41 AM
that's pretty neat.  seems like it would be good for guys roasting for small scale sales.  Figure out a profile then automate it for repeatable roasts.
Title: Re: My Fully Automated Huky!
Post by: Agrajag on June 04, 2016, 04:58:45 AM
Yeah, it's also useful even just using it by pressing the buttons as artisan is then logging it accurately as well. It also opens up the doors of being able to automatically follow a given profile, adjusting power/fan as appropriate. That would require some smarter software though, would be an interesting project.
Title: Re: My Fully Automated Huky!
Post by: rawman on June 06, 2016, 03:06:21 PM
Nice.  I knew it could be done with an Arduino.  Now all you need to do is add the drum speed controller as well.  I have an external motor controller hooked to an arduino but haven't integrated it into Artisan yet
Title: Re: My Fully Automated Huky!
Post by: Seion on June 07, 2016, 09:56:38 AM
Very cool, thanks for posting this!
Title: Re: My Fully Automated Huky!
Post by: Agrajag on June 07, 2016, 03:49:34 PM
Now all you need to do is add the drum speed controller as well.
Hah. I'm still learning how to use the huky well, I don't want to introduce another variable.. yet!
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 07, 2016, 03:54:45 AM
Hi Agrajag,

great work 8)

I'm also playing aroung with an Arduino + stepper motor but am still at the very beginning ::)

Can you give some more information on how to adress the Arduino from within Artisan?

How do you pass variables (i.e. position of the stepper motor) to the appropriate Arduino sketch?

In your setup, it looks like you're using some kind of python-script, do you?


Best regards!

Philipp
Title: Re: My Fully Automated Huky!
Post by: Agrajag on July 07, 2016, 04:40:05 AM
G'day Philipp, I have just committed my scripts here:

https://github.com/phil-nelson/hukyroaster

Quick explanation:

artisanprog.py - This is the script that I have artisan configured to call for reading from the TCs as well as controlling the motor and fan. The arguments to this script tell it what to do, e.g. for the fan slider I have "Action" as "Call program" and the command is "artisanprog.py FAN {}" - telling artisanprog.py to set the fan to the slider value. This program sends the command to arduinoCommunicator.py

arduinoCommunicator.py - This is the program that actually communicates with the arduino. It uses FIFOs (named pipes) for IPC to receive commands from artisanprog.py. I did it this way because artisan may call the external program from different threads and it's nicer to just have the one serial connection permanently open to the arduino instead of a bunch of different connections which will have race conditions.

calibrateStoveMotor.py - This is for calibrating/saving the motor positions for each kPa value that I use. I ended up rewriting this as a small web app in the web/ directory because the interface is faster to use

web/ - php/js scripts to do the same as above.

Hopefully these scripts are fairly self explanatory but I'm happy to explain further if you have any questions.
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 07, 2016, 06:16:23 AM
Thank you very much! :)

That'll let me get a first idea of what to do. Anyway i think there's much to learn, but i'm looking forward to it  ;D

I'll take a closer look at those scripts at the weekend.


Regards

Philipp
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 08, 2016, 05:07:59 AM
One more thing :)

How did you implement the fan speed control? Did you replace the original fan by an DC fan and use PWM or what's your approach?


Regards

Philipp


*edit*

Just found this topic

https://www.hukyforum.com/index.php?action=bookmarks;sa=add;topic=408;b41986f6a6=e202e824f40142a0de146b5d07219d16

Thanks anyway ;D
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 10, 2016, 01:30:20 PM
@Agrajag

Wouldn't it also be possible to choose "serial command" in the events tab in Artisan and send a value directly to the Arduino? Just wondering... :)
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 12, 2016, 11:08:43 AM
Hi @Agrajag,

i did some scripting the last days inspired by your code.
This is the result:
Code: [Select]
#!/usr/bin/env python3

import sys
import time
import serial
 
PORT = '/dev/tty.usbmodemFA131'
 
with serial.Serial(PORT, 9600) as arduino:
    time.sleep(2)
    arduino.write(sys.argv[1].encode('ASCII'))
    print(arduino.readline())

The corresponding Arduino-Code sets a fan to the desired speed - just for testing purposes.
Works like a charm when called from within Terminal :)

Next a tried to call the script from within Artisan, but sadly nothing happens. Not even an error message :-\
I chmodded the script executable and made the call like shown in the attached screenshot.

What am i doing wrong? Have i missed something?

Thanks a lot for your help!

Philipp
Title: Re: My Fully Automated Huky!
Post by: Agrajag on July 12, 2016, 02:52:31 PM
@Agrajag

Wouldn't it also be possible to choose "serial command" in the events tab in Artisan and send a value directly to the Arduino? Just wondering... :)

Yeah you probably could, however I couldn't find documentation on how the serial command works. Also if you need to do any other conversion (like how I save the kPa values as motor positions) you'd need to do that on the arduino side which is harder.

Next a tried to call the script from within Artisan, but sadly nothing happens. Not even an error message :-\
Hard to say from just that - if you run artisan in a terminal window you'll probably see any errors there (your python code inherits its stdin/stdout) when it tries to run your script - give that a go?
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 12, 2016, 10:27:53 PM
Hey,

thanks for that hint!

I fired up Artisan using the executable in ./Artisan.app/Contents/MacOS/

When hit one of the defined buttons i get an error saying, Python crashed.

This is the message from the Terminal:

Code: [Select]
Last login: Wed Jul 13 07:21:46 on ttys000
Philipps-Air:~ philipp$ /Applications/Artisan.app/Contents/MacOS/Artisan ; exit;
Jul 13 07:22:20  Artisan[40170] <Notice>: /Applications/Artisan.app/Contents/Resources/lib/python2.7/site-packages.zip/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
Jul 13 07:22:57  Artisan[40170] <Notice>: Fatal Python error: Py_Initialize: unable to load the file system codec
Jul 13 07:22:57  Artisan[40170] <Notice>: ImportError: No module named 'encodings'
Jul 13 07:22:57  Artisan[40170] <Notice>:
Jul 13 07:22:57  Artisan[40170] <Notice>: Current thread 0x00007fff73660000 (most recent call first):

May there be a problem, because i'm using Python 3 and Artisan seems to still be using Python 2?
Title: Re: My Fully Automated Huky!
Post by: Agrajag on July 12, 2016, 10:49:11 PM
May there be a problem, because i'm using Python 3 and Artisan seems to still be using Python 2?

Yeah that's quite possible, strange though since your shebang uses python3. Perhaps try python2 and see how you go. I don't know how artisan is actually calling the external program. I once had a look at artisan's source code and was horrified to find it's all in one massive ~2MB .py file (what a mess!) and gave up.
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 13, 2016, 03:32:52 AM
Ok, the reason is, that Artisan has a built-in interpreter which only has the necessary libraries included.
External Python-Scripts will be parsed with this internal interpreter :-\
Guess, i'll have to find a workaround like starting my script in a separate shell...
Title: Re: My Fully Automated Huky!
Post by: SusanJoM on July 13, 2016, 10:08:28 AM
I think this post indicates that Python 3 is in use

http://www.home-barista.com/home-roasting/artisan-v0-9-9-t40496.html?hilit=artisan%20python#p459787
Title: Re: My Fully Automated Huky!
Post by: rawman on July 13, 2016, 02:17:26 PM
I think this post indicates that Python 3 is in use

http://www.home-barista.com/home-roasting/artisan-v0-9-9-t40496.html?hilit=artisan%20python#p459787

I think the version that uses python 3 is the specific beta version he mentions here:

Quote
Linux binaries will follow later this week. For Windows there is an experimental build, artisan-win-0.9.9-py3-installer.zip, based on an updated software platform (Python 3, Qt5, PyQt5). Please report on how that performs for you as we plan to move exclusively to this platform for future releases.

So my guess is the baseline version is using python 2.x

jon
Title: Re: My Fully Automated Huky!
Post by: SusanJoM on July 13, 2016, 03:40:55 PM
I think this post indicates that Python 3 is in use

http://www.home-barista.com/home-roasting/artisan-v0-9-9-t40496.html?hilit=artisan%20python#p459787

I think the version that uses python 3 is the specific beta version he mentions here:

Quote
Linux binaries will follow later this week. For Windows there is an experimental build, artisan-win-0.9.9-py3-installer.zip, based on an updated software platform (Python 3, Qt5, PyQt5). Please report on how that performs for you as we plan to move exclusively to this platform for future releases.

So my guess is the baseline version is using python 2.x

jon

You are absolutely right, my bad  :(

BUT, that new build is available:
https://github.com/artisan-roaster-scope/artisan/releases/tag/v0.9.9
and under the circumstances it seems like it might be a worth while download for someone who wants to use Python 3 ???
No????
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 14, 2016, 02:54:24 AM
Thanks for that hint, but as i'm on MacOS i have no possibilities to try :-\
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 16, 2016, 03:48:36 AM
Back again 8)
Though reading a lot on Stackoverflow i could'nt get rid of the described error. Nevertheless i solved my problem :)
I tried it the way Agrajag did and created a named pipe.
The first script is started from within Artisan and writes a value into a FIFO. The second script reads from that FIFO and passes the value to the Arduino.
Works just as it is supposed to!
Could have saved me from a lot of headache, if i'd tried this first... ::)
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 17, 2016, 01:46:09 PM
Accidentally i figured out, the described error reduces to a missing, corrupted, incomplete or obsolete (in fact i have no idea  ::)) io-module in the integrated Python-Interpreter of Artisan.
I placed _io.os from my systems Python2 dynload-directory in my scripts root-path and the error-message disappeared :)
Nevertheless calling Python3-Scripts is still not possible.

Furthermore i'm now using JSON to write my parameters to a file-like object and also pass this JSON-String through serial to my Arduino. Next step is to extend and refine code on the Arduino-side  8)
Title: Re: My Fully Automated Huky!
Post by: monkey_lever on July 20, 2016, 07:31:57 PM
Nice application.

Can you share the link to the motor and pulleys that you use please?.

I have a TC4 board. Can I control the motor driver board with a TC4?.

Have you tried to use the PID function inside artisan?.

Rgds.
Title: Re: My Fully Automated Huky!
Post by: phischmi on July 26, 2016, 01:45:56 AM
Marko from Artisan told me, that there will be a fix in the upcoming version 1.0 of Artisan.
He also yet sent me a beta of Artisan 1.0. Now i'm also able to call Python 3 directly from inside Artisan :)

My code is now virtually done and i'm waiting for some 3d printed parts in order to assemble everything.

Unlike Agrajag i'm using no pulleys but a "Doppelschlaufenkupplung" (no idea, how to call this in english  - maybe sth. like "double-loop-coupling" ;D ), to directly link the motor to the valve. The motor is the same as from Agrajag - a 28BYJ-48 stepper motor.

As the TC4 comes with stacking headers, it should be no problem, to attach a motor driver shield on top. I#m using the Adafruit motor shield for controlling the stepper and fan.

I'll post some pics and vids, when everything's done! Can't wait for it ::)
Title: Re: My Fully Automated Huky!
Post by: monkey_lever on July 26, 2016, 03:29:51 PM
Thanks for your infor phischmi.

Looking forward to see your Doppelschlaufenkupplung and your setup at work.

Rgds.
Title: Re: My Fully Automated Huky!
Post by: phischmi on August 13, 2016, 04:44:56 AM
Hi all,
the work is done  8)
I just made some changes inside the code but basically the setup works just fine!
The fan is now controlled via a separate pwm-wire which makes it very easy to finetune.

I also did my first roast using the automated setup and especially the fan seems to fit perfectly in terms of airflow (it was @ 60% during the whole roast).
The Noctua NF A14 iPPC 3000 PWM is rated 158cfm.

So, here're some pics :)
If you have any questions, just let me know!

(http://up.picr.de/26432256ej.jpg)

(http://up.picr.de/26432254eu.jpg)

(http://up.picr.de/26432253ih.jpg)

(http://up.picr.de/26432251mo.jpg)

(http://up.picr.de/26454638qj.png)



https://youtu.be/f3nSmdGeank
Title: Re: My Fully Automated Huky!
Post by: Crzyworm623 on April 17, 2017, 11:22:28 PM
This is awesome.  Now that you have had it up and running for sometime, can you give a decent write up of the project.  Parts / How To.  Arduino is a new to me, but sounds like a fun project.  I'd love to start designing profiles and having them run automatically.