Author Topic: OpenStill: A modular distillation controller based on the ESP32 devboard.  (Read 9779 times)

0 Members and 1 Guest are viewing this topic.

Offline Hooch

  • Posts: 97
Ok folks!

This will be the start of this project.  I'm going to put files up here and all the bits you need to play along.

I will try to do this so i is just a bit of wiring and some code downloads.  All the parts are modular maker bits, I don't have the facilities to work with surface mount devices, and in this day and age I can create a design and send it to a fab house for some insanely low price, and save a boatload of time. 

As I mentioned in other posts, the goal is to make and Automatic Breadmaker version of a still. You fill the boiler, verify the settings, place your bottles,  turn on the water, press start.  Many hours later, you pick up the full bottles, and clean up.

So I have been wrestling with the concept from the viewpoint of running with a single processor board.  In the big picture, it does need to be modular in the viewpoint of how most people run their stills, and to automate some of the larger processes like making a batch of low wines.

I am envisioning three ESP32's running the show:

OpenStill:Boiler -> Runs and monitors the boiler heater and safety controls, can control Reflux.
OpenStill:Reflux -> Runs the condensor flow control valves and monitors flow rates and temps.
OpenStill:Master -> Runs the product cut, monitors temps, and controls Boiler and Reflux OpenStill controllers.

Now the cheezy part is that they will all run the same code, and will talk via ANSI terminal connections via telnet or serial and communicate to each other wirelessly.  Because of the single code base, each processor will handle whatever functions you have supplied the hardware for or it can detect.

Is it overly complicated?  A bit.  But it resolves a number of issues (controlling high power circuitry, and water don't mix),  and provides additional functions without being complex.

So time to put my systems analyst hat back on and get to work.

Offline Hooch

  • Posts: 97
A bit of progress made!

So have the SSR working with the ESP32.  Have it working on PWM but that doesn't work well.  Needs  tweaking to fix, a whole can of worms opened up with this.  Either zero crossing or phase controlled works, but phase controlled requires an input to synchronize the power to the ac cycles.  Batch is still a bit sketchy since it also does require syncing to the ac waveform.

Made a rudimentary tone library for a speaker for alarms.

Tested out the analog inputs for use in jar alarms.   That works! Going to test it with an LM35 to compare the accuracy vs a DS .

Up next working with a a4998 driver and a BY stepper that I made bipolar.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Fine Hooch nice there is some progress ,question do you need complete control on the power ?
or is 100% power for heatup and say 50% for the run not ok ?

Like the Istill has only two choisess max power to be exact 2 heaters and during the run 1 heater, each heater has 2200 watts,and the one for the run has no adjustment during the run so the complete run is done on 2200 watt.

The rest of  controlling the run is by adjusting  the opening of the output , so if needed the micro controller adjust opening the valve only ,and no power adjustment is present.
This way there is only one variable to adjust.
With power control and opening control you have 2 ,and maybe more as they interact to each other.

Or do I understand it wrong ?

Better bad weather than no weather

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984

.... As I mentioned in other posts, the goal is to make and Automatic Breadmaker version of a still. You fill the boiler, verify the settings, place your bottles,  turn on the water, press start.  Many hours later, you pick up the full bottles, and clean up. ...


I want one of those!!
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97

Quote
Fine Hooch nice there is some progress ,question do you need complete control on the power ?

It's "What do home distillers want?"

I want and think other would like:

A fast boiler preheat.
This means:
1. Multiple primary heaters / oversized primary heater.

It's about 100 lines of code to add multiple heater control circuits, although the cost to implement extras is minimal (extra SSR + wiring + bigger heatsink) = $12.  I have my eye on one of these 5500 watt beauties to upgrade Betsy's 1500 watt element to:
5500w element.jpg
* 5500w element.jpg (4.74 kB. 225x225 - viewed 917 times.)

Truth be known for most distillers who live in a split phase 120/240v world, it is easy to heat at 240 and distill at 120 since it will only produce 25% of the power during active distillation which I find is just about right.   However this is a global forum, and your personal electricity source may likely be different.

OS optimizes the distilling solution.  Since OS has access to the column pressure, amongst other things, we can tweak the power until the equilibrium fails, the fall back a bit.  For you LM guys it the vent temp spiking that shows the fail (condenser can't handle vapour speed), for VM it is blowby output.  Of course if the pressure starts to spike then you need to throttle back.

I also have to give a nod to those propane powered folks.  Remember I have a way to control needle valves, gas valves are needle valves.  A flame sensor is $10-20, same for making the gas valve motor controlled, and they get to play, it will have auto off, so if the flame goes out it shuts the valve, shuts the valve if anything is f#$d up.  That is about 500 lines of code.


Ah the foray into the power control swamp.  The cheap SSR's like the one I got are zero cross switching so they can only switch one 1/2 cycle fully and not just turn on at any point in the cycle when the input is high enough.  I really hate it when companies use the same datasheet for products that look the same but are completely different internally.

Not a big deal breaker, just have to use Brahmann? algorithm to control, which is just dropping supplying power to the element in half cycles and the algorithm considers time.

This means that 120 step resolution for power control 120 half cycles in one second at 60hz, 100 step resolution at 50hz.

Just have to get a h11aa and some 100k resistors for zero crossing at the local hacker shop.

Any suggestions on best schematics programs?  It really is just a point to point job.




Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Where I live, 240V on one wire (vs 2 each 120V lines in USA to power a 220-240V device) and 10 amp power points (breakers) are the norm.
2000 watt appliances are common here and 2200 watts is the suggested maximum load.

I envy people that can power a 5500 watt heating element.

I just have live with a long boil up time, other than that I should be able to follow along.
Stay calm and follow the screaming people.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Were I live 230 volt is commmon ,and the most have 16 amps a little more than 3600 watt , we used to have 220 volts in the past.
You can have more amps/watts  but you have to pay for a new powermeter extra powerbox  and extra wiring.
The new houses all have 380 volts ,and NO gas for heatingn/cooking.

Distilling is more or less spiritual  :) experiance.....  more and more distillers enjoy the time @ the still and halve an hour more or less heatup so what.


Better bad weather than no weather

Offline Hooch

  • Posts: 97
It is a wish list item.  In Canada, family dwellings are required to have a stove and a dryer outlet.  So there is access to higher amperage circuits in an easy way.
A dryer outlet will support that element, but for me to implement that would cost about $250 for all the bits, got other stuff to buy first. 

It usually doesn't bother me to have a long heat up time.   I use that time to clean and sanitize the primary fermentation container and set up the column and cooling, and have lots of time leftover to watch the temperature creep up degree by degree.

So trying to test servos get this now...

Code: [Select]
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:10088
load:0x40080400,len:6380
entry 0x400806a4
OpenStill Initializing Serial Task...
OpenStill Initializing Alarm Task...
Speaker Tick
OpenStill Initializing Motor Controls...
OpenStill Initializing A/D subsystem...
OpenStill Initialization Complete!
cnote 100663552 Tone 1536 Hz, Duration: 256 ms

Raw: 76 Voltage: 76mV
/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/tasks.c:3121 (xTaskRemoveFromEventList)- assert failed!
abort() was called at PC 0x40088ab6 on core 1

Time to have fun!

Offline Hooch

  • Posts: 97
Those errors are when you don't match up the arguments in a printf format statement. 

I had a joke about more ... than number of "Letters to Santa arriving on Christmas Eve" but I forgot.
Went through the eparrot code,  seeing if I am missing some functionality but all is good.

Now I spent some time on the hardware design side. 

I listed what I think are all the major doodads and how you connect them and the pinout of the ESP32.  I don't know if this is a complete list comments appreciated. 

Before you ask... No you can't define everything, there is just a limit on the number of pins you have to work with.  But I have some great concepts on implementing the modular aspect, but I only have one ESP32 devboard to play with.

See attachment.

Time for that drink!

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Hi Hooch, please upload the attachment again.
But don't click on "insert attachment". Then your app will be listed as something that can be downloaded.

I tried to fix your post but I screwed it up, sorry.
So please post again by uploading your attachment without selecting "insert attachment".
I hope that makes sense. If it does not then contact me.
As a rule: insert is for pictures; all else (especially apps, are for programs)... 

Pictures display inline.
Apps screw everything if you try to display them inline on a forum post.
Yet apps as an attachment (but not inserted into a line post) does work very well.

Post pictures inline, post apps without selecting attachment. Then apps will default as being able to download.
Something like that.

Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
It's amazing how much of the code is just for displaying and entering data.  Fascinating how Edwin implemented a crude rtos as the heart of eparrot.   Looking at the SMT172 code, it should be implementable using an RMT channel since it can read pwm waveforms with 15 bit accuracy.

Sadly, it is to the point where I have to do the same thing allowing the user to edit the configuration.  So off to see if I can find a prebuilt library to do the heavy lifting.

 

Let's try again!


Offline Hooch

  • Posts: 97
Today I have a brief time to post..

Shifu, I'm no stranger to big machines making massive noise.   ;D  I just get used to the weird tones that just aren't there.  What I found is far worse is driving with the window down something I love doing.  Turns out the constant pressure fluctuations at a frequency below what we can hear really wear out the hearing bones.  I keep a set of ear plugs in the car for when I go on long drives on nice days.   

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Your Excel file downloads just fine now, Hooch.
I don't understand much of it but it certainly contains a lot of information.
I really like how you have defined every IO pin. That is something that I'll borrow for my own projects.
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
Ah yes... it is very confusing at first.  The first spreadsheet comes directly from Espressif on how they work with the I/O pins.  There are way more controllers available in the chip than pins to assign them to, and specific controllers inside the chip interface to specific pins, like the analog inputs and touch sensors. 

The second spreadsheet is how I'm defining the inputs to the OpenStill program.   Because the chip don't care if I use a variable instead of a constant in defining the gpio pin number,  you can configure it on the fly! 

How I envision it working is:

Shifu needs a DME fermentation heater.

Flash a ESP32 dev board with OpenStill.
Open an Ansi terminal connected to the devboard.
You do the normal configuration to connect this device to your wireless network and save it.

At this point, you can connect to it via a telnet session using an ansi terminal emulator on your phone.
Power it down.
Plug the dev board into the Power Control PCB.
Plug some DS sensors into the Power Control PCB.
Plug in the heater.

Power it up and telnet in.

Because there is no active configuration you need to build one.   This is simple so I save my typing for coding.
Because there is no configuration, the telnet session will give you a list of high level functions you can implement.
A PID heater will be an option, so pick that.
That option expects several inputs:
An SSR output pin
A   ZeroCross input pin
Temperature label for: Tsense, [Theatsink], [THeater]
Tsense = temp we are trying to control.
Theatsink = temp of SSR
Theater = temp of heater itself.

Then you would define the OneWire buses, by adding the OneWire module now. 
You enter the GPIO pin you used to connect to the DS(s). 
Then hopefully you are presented with a rom list of the DS18B20s on that pin and the temp.  You then assign the specific DS to the desired temp label.
Continue adding pins to the one wire bus and assigning each new DS to a unique temp label.
You can also add other temp sensors like the smt172 or lm34 (now with 12 bit resolution like a DS) to a label as well.

Select the save option, give it a name, and you have a new button on your terminal window.  Click that you get a first time configuration screen for the PID controller values, tweak values to your hearts content, save the settings.

Finally, so it took five minutes, you get the setpoint screen.  Enter the desired warmth of the malt vinegar you are creating and press RUN.   If you get a power failure and as long as there are no missing critical sensors, it will restart running.  Then you can check on it anywhere you like and stop running the heater.

Here is some light reading... :o

Sorry the ESP Technical Refernence is too big!





Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Congratulations Hooch, you made my eyes glaze over in under 5 minutes.
That is a Lot to take in.

Looks like I'll need to setup a Linux box to follow along?
At least to follow Pradeep's NCURSES tutorial...
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
I know how you feel  ;D .  Kinda like watering a really dry plant.  First time most spills off but some soaks in, second time less spills off and more soaks in, third time...

No you don't need a unix system to play along.  When you install the ESP32 compiler and toolchain it installs python, and that has a terminal emulator module that will work.

It would help you to just think of the NCURSES library as being just like the LCD display driver, but instead of an LCD display connected to the i2c bus, an ansi terminal is connected to the uart0.   In fact there are a few projects FABgl for one which for $50 all in for parts including the ESP32 devboard, using a surplus VGA monitor and DIN (serial not USB) PC keyboard you  can find buckets of at the ewaste sites will implement a colour ansi terminal.

Since it is the "old school retro" standard for user interaction with a  CPU with limited resources, it fits the bill, and as an added bonus there are years of libraries to do all sorts of fancy things including graphing. 

There is a ceiling with regards to memory available, but I am not even close to hitting it yet, but we will see.

Next code binge I might have something releaseable!!!!

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Do you have a link for the Windows version of the ESP32 compiler and toolchain to use?
Stay calm and follow the screaming people.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Hooch, I repurposed my NodeMCU last night from the garden to the fermenter.
Should have thought to do it sooner.

You may remember this project from here.

Or direct link to the Node.

2L ferment.PNGOpenStill: A modular distillation controller based on the ESP32 devboard.
* 2L ferment.PNG (48.7 kB. 350x385 - viewed 1713 times.)

It records the temperature cycling in the range of 27.62 to 29.94C.
I figure several factors are at play here:
1) The water is not moving. A simple servo-driven paddle-wheel or propeller would solve that. 
2) The sensor is placed as far away as possible from the heater. Sensor inside the fermenter jug would be much better but more complex to deal with.
3) The aquarium heater is doing its best but it only cost $3 so it is not precision hardware.
4) The fermenter enclosure is not completely or properly insulated.

After 3 days, this 2L ferment is still bubbling - Very Slowly now, instead of shutting down as the previous 2L ferment did after just one day without temperature control.
I'm satisfied with the roughly 2 degree temperature range.

What makes this project cool is it can be monitored from anywhere in the world, and it has a nice data graphic that helps to make that data useful.
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
Whew... Thought I was kicked out of eParrot, but just that I had to change userid's for the computer since my old userid "Mom&Dad" completely freaks out the internal string handling of the mini linux you need to install to make it all work!  It's the & character, 4 hours of my life spent chasing that problem, in the end it was just easier to create a new windows userid, then reinstall all the packages again!

I like that NodeMCU, have to look into it in a bit.

Toolchain... Follow these instructions:

 https://www.instructables.com/id/ESP32-With-Eclipse-IDE/

gets you started.

i have created a file structure like this
c:\+ msys32  ; virtual linux box to compile
     |
     + esp32projects  +; directory where all esp32 stuff goes
             + esp32 // directory to github espresiff files
              + eclipse-workspace ; eclipse wants this
             + Workspace
                     + project ; must put in a template. github projects to here

I'm still trying to wrap my head around github, both to re-install driver code as a fork, and as a way to post the beast of the week!

Then of course i'm now using eclipse which is way way better than the arduino ide for cranking out code but it needs a bit of configuration first.  There is a cheezy way of configuring it to build for the esp32 just have to find it.

Gotta run!


Offline Hooch

  • Posts: 97
Arghhhh.....  >:(

Forget all that crap.

The link was to an older version of the toolchain.  Go to espressif and get the CURRENT version which does it all. 

For whatever reason, keep your workspace INSIDE the msys32 directory in your home/{username} directory.  Speeds things up, and more importantly, doesn't get involved with your other hidden python package (my opencv project).

Got Eclipse up and running and compiling and flashing.

But now I have to fix my fingers.. All the typing has flared up my carpal tunnel.  So as the day progresses, starting at the pinky my fingers slowly get numb one by one. 

Next up... github.  So those who want to play can join in with:

Code: [Select]
git clone --recursive https://github.com/Doctor-Hooch/OpenStill.git

from your workspaces folder in your mingw32 window.

It is blank at the moment.

So time to take eclipse for a spin and import the menuconfig c program and make it run on the esp32.