Author Topic: Using an ESP32 as the CPU for a still.  (Read 7617 times)

0 Members and 1 Guest are viewing this topic.

Offline Hooch

  • Posts: 97
Using an ESP32 as the CPU for a still.
« on: January 17, 2019, 01:36:58 AM »
So I had a bit of a chance to play with it and  ;D.

I think it would be a very easy port to put eParrot on to this platform and gain access to all the other goodies it has to offer.

First it takes about as much effort to add the ESP modules to the arduino IDE as it is to install the arduino IDE in the first place.

The big hurdle is that onewire driver which reads the DS temp sensors has been implemented as a bit banger protocol which is extremely processor exclusive and doesn't play well at all in the multi core ESP universe.

The good news is I found a onewire drivers C code for ESP32 that uses the RMT subsystem which are are normally used to send/receive IR remote signals, to drive the bus in time slots.

Bad news is I have to repackage it as an arduino library and that has been a big learning experience so far, not done yet hopefully by the weekend I can upload something working.

One question I ask the audience is:

There are a number of "meshed" protocols out there which I can add the library to the ESP32 and use.  This allows me to add display and control functions in the program that is wirelessly connected to use whatever internet device phone,tablet, computer that can run the display app sort of like the nextion display.  There are lots of them out there like LUA Nodered... Any preferences on this.?

Time to change that driver into an object class. :o

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #1 on: January 17, 2019, 02:29:32 AM »
Well let see how it developes.
I have a new nextion never used a gift from a fellow distiller.
I have no idea how to use it ever,no energy to find out also,maybe as I have more time middle of the year.

What I would like a system with the use of a android tablet.
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #2 on: January 18, 2019, 12:32:18 AM »
It's getting there.  I'm at a fork due to the difference in fundamental concepts.

On the ESP32 the OneWire Class Open module requests 2 of the RMT  instances one for transmit and one for receive, then configures them to handle the OneWire bus timing.

The GPIO pin is just checked to see if it can be reassigned by this application.

All the OneWire I/O functions have a GPIO input variable so ANY GPIO pin can then be used to talk to a OneWire bus.

However having to put a port number in the function call will break most programs relying on the library.

So I'm just figuring out to code those extra functions so it will appear like a standard OpenWire function.

On the Nextion Display download the editor and play..

Have to run!



Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #3 on: January 18, 2019, 12:44:57 AM »
Nobody said its gone be easy,you have to find out all by yourself at least you know more or less how to proceed.

Nextion yep I know they have a nice editor ,and easy to follow projects @ you tube,but I doint have the energy to pick it up.
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #4 on: January 24, 2019, 08:36:03 PM »
Sadly there seems to be an issue my dev board.  Apparently turning on the radio draws so much current it overwhelms the 3.3v reg. 

Trying to get into the gestalt of the esp32.  It appears that once you activate all the goodies like wifi and bluetooth a lot of resources get used which is why there are 2 CPUs.

The last bit is whether I have a display or not and rely on serial/bluetooth or web/mqqt. 

I love graphs so that would be nice.

But that leads to either a nextion display or I think I can hang an spi display off the flash bus. 

But then I have to add a graphics library.  So perhaps going to python is more appropriate.

Now to finish Shifus code and then I can port it over because I need to run a batch or two have a boys weekend next weekend can't go dry.  8)

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #5 on: January 24, 2019, 08:44:29 PM »
Oeps,
Maybe let your mind come to rest,happy stilling .
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #6 on: January 24, 2019, 08:57:24 PM »
Lmao..  no rest because the code is in my head and not on my hard drive yet.  So I wait impatiently for our visitors to leave so I can get back on the dev machine.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #7 on: January 24, 2019, 09:01:18 PM »
If they are not coders to assist you  then may be drinkers to assist you /thumbsUp /cocktail

Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #8 on: January 24, 2019, 11:23:25 PM »
No, no... more like cats.  Just when you start something interesting, they get all up in your grill. Then they waste your time until you need to do something else and you get nothing done.

This project can't be "beer straight or level", so no pain no gain.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #9 on: January 24, 2019, 11:29:33 PM »
Ha ha life is all about consessions,giving and taking,now it is your time of giving!!!!!!!!
It is what it is ......you like to see football BUT your better halve wants to see a romantic movie.
Just deal with it.

I just filled,my glass with rum ,and follow mrs k3 @ the movie that is not my piece of cake ,but it was a hard week so I sit down and relax  :o





Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #10 on: February 14, 2019, 11:07:27 PM »
So much fun here! :o

It will work quite nicely...  I finally got the basic skeleton built, so now I can flesh it out.  I can read DS sensors via hardware very robustly, and now on to the motion control routines. 

After much reading, I found out a few things:

First:

The arduino version does allow you to do all the things with the ESP32 that the real toolkit allows you to do, if you attach the appropriate libraries.  However, they are not libraries in the arduino sense of the word, more like code snippets, easiest way to deal with it is just to copy the .h and .c* files to the sketch directory.

Because it is a dual processor, and the point of it is to attach to the internets, there is a lot of background processes that take CPU time.  Luckily, they give us a library to do this RTOS.  But this means writing the application in event driven style task specific routines.

Next post... some code!

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #11 on: February 14, 2019, 11:55:41 PM »
You know what,I'm impresed you use a langua I doint understand,coding is for me like looking into a book with code only.
I can not make anything out of it I'm not a coder but a duplicator.
If it is something for me what you are building I doint know ,but even if it is not my piece of cake I LOVE to follow your build.
I would like something like the Russians have it is called  hello distiller supported by arduino suported by hardware , and supported with windows based software and now it come also supported by android,they have a app available into google play store,and have a look at you tube under hello distiller.
There is a existing website of hello distiller too.

I have send them some mails and gues what unexpected they answhered ,but they have not planned a
 Englisch version yet.

See forward how your project developes.
Cheers k3
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #12 on: February 16, 2019, 12:26:10 AM »
K3. That is some nice stuff!  Haven't had the time to go through it all, can't follow some of the logic it's in Russian like why he needs to have mechanical (electrical) feedback for output position when he is using a servo, but I love some of the ideas.

Me, I can code, but to do that I need to have a visual on what the program has to do.  Dirty secret about coding... about 90% is duplicated from something else, 10% is original being built on someone elses work.   My goal is to automate the "whole" process as much as possible.  It is a big evolutionary leap in the process to go from what is really a very fancy thermometer that tells you what to do now, to something that will run the process for us. 

So part of that is the motor (stepper/servo) operated valves to control reflux and takeoff, and a  servo/stepper to switch the still output to different bottles as required, and a way to control the power to the boiler.   The most important point in all of this is when to switch from heads to hearts.  That can be done by recipe or more importantly by pausing output until you think its good enuf to continue. 

Everybody except me is going shopping... I get to CODE now...  ;D

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #13 on: February 16, 2019, 01:52:31 AM »
Yep it is all about what you want and what you need.
My LM system does not need much tuning as the colomn lenght is tall.
Edwin was very supprised as we did the peristaltic pump test how little adjustment was needed during the run,he said why make it automaticly.

Heresome toughts I had
What I would do to switch between heads and hearts , use a smt172 to detect the right moment on temp.
After a few runs you will be able to set the right moment , but it never will be 100% as the  wash is not always the same , so make the moment of switching a little into the hearts you loose some hearts .

Or program at the system to collect a amount before switching to the heart jar.
So you needs a system that measures  take off volume.
It could be done in 2 ways .
First way program how much is heads and let the system switch to the heart jar after that amount was past the measure system,you have to calculate it manualy before each run and put it into the program.
Second way make a program that you feed  for each run with the following input ... boiler volme ,% alc of the wash and let it calculate on the known figures 3% fores 17%heads 57%hearts 23% tails and do the take off by volume so you need a measuaring system for takemoff and some solenoids.

Both system will not100% but the best way is by smell and taste after all.


One system does it all the Istill, 50  now only the Polisch version is available it is called de170 ,have a look,
You can programm pure distillation  run or potstill run see the movie.






and the de 50

Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #14 on: February 17, 2019, 01:48:30 AM »
LMAO... 

First video at the end... and the reason why I am doing this... "So we missed the...."

Yes I know there is so very little to do during a batch once everything is stabilized.  Perfect for a processor to give it the old stink eye every 750ms instead of me.  Yes I like to walk by and hear the little trickle of product into the collecting jar, have a peek and hope it is not overflowing, or looking at a milky bottle and going "So I missed tails switch"...

That is exactly the kind of software I am trying to create, and not hardware specific.  I want to use a stepper to switch output like the russian, and not use all sorts of ss solenoid valves.  I do think it is really pretty in a Bauhaus sort of way..


I is nice to know he is using the same process as I do to run a batch, except i have started running purges to clean the product condenser rather than the slow drip drip.  The same volume is taken out either way, I found that when you are making the decision to go to hearts and it's too good for heads, but just that indescribable not quite right for hearts either sample, it was due to smearing because the product condensor is very large, and at low production the active condensation zone is very small, but  due to randomness, it does happen to a small degree on other places in the condenser, which take time to collect enough to make a drop big enough to slide.  Purging gives the whole condenser a rinse, and we can do that because these long columns are so very stable.  Purging doesn't take long, less than two minutes from reflux shutoff to time to turn it back on again.   

Fun news... I got multitasking part sort of working, needs a bit of fine tuning maybe... So it reads DS sensors, and moves the steppers via command line. 

Found out the hard way that setting the stepper rpm to 0 causes a processor panic "divide by 0" exception and restart. 

 Next up the flow meter needs to be attached and coded.  After that need to build the nonvolatile constants code to save which DS sensor does what, the offset and flesh out what other variables I need to keep between power cycles.  That means I have to expand the AT command section to include saving values to "eeprom".

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #15 on: February 17, 2019, 09:53:33 PM »
Fine hope you liked the movie's this way I can contribute just a litlle,try to give idea's ,and maybe here and there it helps ,or not.
Ok one thing I know the Istill also uses a temp sensor located far below the product abv sensor,you need some distance and make the measure adjustment lower into the column to make the output stabile that way.
Let see how you proceed :)
Better bad weather than no weather

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: Using an ESP32 as the CPU for a still.
« Reply #16 on: February 19, 2019, 09:07:50 AM »
I love this thread!
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #17 on: February 19, 2019, 08:35:03 PM »
Thanks... k3 keep that stuff coming. 

I know everybody is excited about the idea about using web pages to work with.

However we need to run javascript sourced by the esp32 to truly have an interactive display which updates the operating values like temperature and pressure. 

That is feature creep and will suck many hours away from getting it done

Now while wrestling with the problem of assigning DS18B20 sensors to function, I had the brain fart of just doing it in an ansi terminal window.  This allows us to do it in a telnet session. 

Gotta go...

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Using an ESP32 as the CPU for a still.
« Reply #18 on: February 19, 2019, 09:49:00 PM »
If updating is a problem question .... is it not possible to do that by means of ftp ?
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Using an ESP32 as the CPU for a still.
« Reply #19 on: February 20, 2019, 02:26:08 AM »
Short answer no. FTP sends files.

Web pages started way back when to see information in a pretty way.  It has since mutated to the monster we have today, but the core is still the same.  The browser just requests files, and the web server sends them.  The browser creates the image that is the web page and waits for you. There is no function in html to listen to the web server.  All that is done by extensions the one that we need is Java.

Now if I use terminal program to listen to esp32 usb port, I can treat it just like one of those LCD displays, but a full color 80x24 or 132 x 80 display.

Now the beauty part I just found out.. There is a native library to create a telnet server for the console port on the esp32.

So done and done :) /thumbsUp

So if you tell your router that the IP address associated with your esp32 is hosting a telnet party then you can connect from anywhere on the internet to your public ip address via telnet and get TADA the display.

Just need to make sure you configure a static ip address for the esp32 to get rid of a lot of future headaches.

Just remember that having a telnet port open on the internet is like having a sweet drink outside late in the summer it attracts all sorts of undesirables but they can't do anything anyways.