Author Topic: Algorithms column temperature stabilization.  (Read 6302 times)

0 Members and 1 Guest are viewing this topic.

Offline Hooch

  • Posts: 97
Algorithms column temperature stabilization.
« on: December 11, 2018, 12:34:43 AM »
Refluxed distillation allows you to distill product at a far greater purity than by a simple pot still.   Once you have extracted the foreshots and the heads its time for the good stuff.  At this point in time you put the column in total reflux and wait for a "black magic" period of time.  I normally use 30 minutes.  If you don't reflux long enough, the ABV drops rather quickly when you start to take off product.

 It doesn't matter what type of still you have, after reflux you begin distilling out product at some ratio of what the still produces with no reflux.  At 1500 watts, I take off about 15 ml /minute about 5 drops per second.  I can collect azeo at that rate until the ABV coming from the boiler drops below 20 percent.

It is a physical fact that the lowest temp of a mixture of ethanol water occurs at the azeotropic point.  In a good column under total reflux,a significant portion of the column will eventually become azeotropic.

Now when dabbling in ABV's near the azeotropic point, the native resolution of the DS18's of 1 / 16 degree celcius represents a change of ABV of 1.2 %

       965, 953, 942, 938, 933, 930, 924, 921, 918, 915, 911, 909, 906, 904

Does it matter ? no.  As a mathematical model we are dealing with an asymntotic value.  It just matters that the value does not change over time.

 I was in the internet rabbit hole surfing for higher resolution temp sensors, when I came across some papers where they were calculating the internal temp from the outside temp and formulas based on the thermodynamics of the pipe and material.  The takeaway here is that the outside and inside temps do track each other.

         So I propose a slot machine algorithm.

Use 3 DS18 sensors. The first is at the top of the packed column, the bottom is above d20 point (d is diameter of column), and the middle is between those two points.

The distance between the sensors needs to be at least one HETP Height Equivalent to Theoretical Plate distance, my packing is multiple segments of 8 feet rolled knitted copper 5" wide which conveniently works out conservatively as a plate.  Models show this type of packing has an HETP of 10 - 14 cm.

The sensors are mounted outside, I use gear clamps and a bit of foam to hold the DS18's to the column, then use pipe insulation over the region.  It always amazes me how a little draft can greatly impact the output of a still.

  I use 1/8 phono jacks wired black = gnd, red = vcc, white = Dout. Then you can use headphone splitters to build a onewire bus, and dollar store cables to use as leads if you use bare TO92 packages. Yes you have to be picky, the trend is to use enamal insulation which makes for nice skinny cables but are terrible for soldering and after a bit of flexing develop shorts. So pick thick ones even if they are twice the price becaue they insulate each of the wires.

The algorithm:

Constants:
Holdtime = length of time in ms that the temp has remained constant before deciding its not going to change I use 5 minutes

Variables
tshigh,tsmid, tslow = current readings.
tshighold, tsmidold,tsoldlow = last readings.
tshightick , tsmidtick, tslowtick = mstimestamp when this change occured long int, watch for rollover.
azeofp = boolean variable indicating first pass set true in setup set to false after init

output global
isazeo = boolean true if azeo is reached false if not,

needs

millis() = currents elapsed processor time in ms.

if not azeofp
   if tshigh <> tshighold
      isazeo = false;
      tshighold = tshigh;
      tshightick = millis();
    else
       if tshightick + holdtime < millis();
          isazeo = true;
     endif
   if tsmid <> tsmidold
      isazeo = false;
      tsmidold = tsmid;
      tsmidtick = millis();
    else
       if tsmidtick + holdtime < millis();
          isazeo = true;
     endif         
   if tslow <> tslowold
      isazeo = false;
      tslowold = tslow;
      tslowtick = millis();
    else
       if tslowtick + holdtime < millis();
          isazeo = true;
     endif         
else
   tshighold = tshigh;
   tshightick = millis();
   tsmidold = tsmid;
   tsmidtick = millis();
   tslowold = tslow;
   tslowtick = millis();
   isazeo = false;
   isazeofp = false;
endif


Comments thoughts?

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: Algorithms column temperature stabilization.
« Reply #1 on: December 13, 2018, 11:39:53 AM »
Hi Hooch,
That's quite an outline, what programming language are you planning to use? 
Stay calm and follow the screaming people.

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #2 on: December 17, 2018, 12:28:51 AM »
Ah yes, what to program in...

At the moment, I split it.  My development laptop runs Python, and interfaces to an Arduino via serial.  So right now it just read the DS temp sensors, and sends them off to the serial port.

The nebulous thoughts I have on this is that I implement an AT command set on the Arduino so it can do the detailed control, while the Python side does the fancy display.

I started using Python to get access to the OpenCV library.  I have a module about 80% complete which uses a webcam to look at a hydrometer and then report the ABV at a far greater accuracy than any temp based sensor can provide.  This means I can plop a Raspi with a touch screen in there for not tooo much $$$ cause I think my still deserves it rather than an LCD display (no offense meant) however I have a bunch of old laptops that would be more than happy to do the job gladly for free.

This allows me to split the transport truck of code needed because the pickup truck Arduino can't do it all, I'm starting to think an ESP32 might be better as the embedded processor. I did ask for one for Xmas.

The logic works regardless of who is going to process it.

I do have to dump all the pressure compensation and tables to do this in the Arduino, since all I need it to do is read the DS18 array, run three steppers, (cooling, fores/heads/hearts/tails separation,hearts portioning), and few irq lines for a drop sensor and flow sensor,

 
The AT commands I think I need to implement right now are:

ATLn n=0,1 starts stops sending log data.

ATRn n= 0,1 stops/starts total reflux
Gives 3 responses, OK, +++ATR1 when stepper movement finished, +++AZEO when temp stable.

ATOn n = drops per second output, adjust reflux cooling to provide n output.
Gives OK.

ATMn=[+,-,""]ssss, moves Stepper n ssss steps +/- or to position ssss where ssss/2048 = 360 degrees.
Gives OK, then +++ATMn1 when movement complete.

ATBn=ssss , sets backlash for stepper n to ssss steps.

ATPnn Purge column move reflux control to purge position, then wait till high column temp changes by nn DS18 units, then move reflux back to obtain total reflux by ATR1 command.
Gives OK, then +++ ATP0 when reflux at purge position, +++ATP1 when desired delta t has occurred, then +++ATR1 when reflux achieved, then +++AZEO when column temp has stabilized.

ATVnnnn  Start counting how many drops have been output, when at nnnn execute ATR1 command.

While I don't have the bits yet,

ATWn 0,1 open solenoid for cooling water.
ATHn  n = 0 power off boiler heater, n+ PWM value for element control.

I'm getting the stink eye from the Mrs, I have three batches ready now that need to be run before Xmas, and I need a really good day to code all that to the Arduino,

I attached the template image for the OpenCV parrot, and the log file from a run in the summer.

Enjoy!run graphs.pngAlgorithms column temperature stabilization.
* run graphs.png (68.02 kB. 350x189 - viewed 934 times.)


edit no log file >6.5 mb pic instead
run graphs.pngAlgorithms column temperature stabilization.
* run graphs.png (68.02 kB. 350x189 - viewed 934 times.)

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #3 on: December 17, 2018, 12:44:24 AM »
There are days when I realize what I don't know, exceeds what I do know, but you learn something new every day.

This is the reference image of the hydrometer i use.  Using OpenCV I can capture an image of the hydrometer stem in the parrot, and find where it belongs in this image. based on the realtime images position, I can read the ABV value from the three pixels from the right margin of the image. one being the percent value and the second the decimal value of the percent.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #4 on: December 31, 2018, 02:53:14 PM »
Can you give a hint were the sensors are located on your column ,EDIT FOUND IT.

I cant believe messuaring the column outside is working  and be accurate  to control a still
The heat of the copper column  will be eaual over a large area of the column or not ? and it wilp be slow to react on changes ,but maybe I'am wrong as I did not do a test like you.
So How precise is it ?

Did Santa bring you the desired esp 32 ?

I would like to see more the use of very cheap android tablets.
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #5 on: January 01, 2019, 01:53:38 AM »
Next best thing an amazon gift card.

Here is how the ds sensors were  implemented.

Yes because of the amount of energy that passes through that point that temp is stable but trends.

Have a log on the laptop which is tucked away which shows it.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #6 on: January 01, 2019, 02:17:40 AM »
Ok I see the sensors are quit near to each other, and I'am supprised about your readings.
There must be a delay in reading according to this system or not ?

I even do not want my thermowells into contact with the metal of the column,as I want to measure the vapor directly.

But let see how you go on with it.
As I see you column I miss a needle valve ? how is it working ? or is it a vm ?

Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #7 on: January 01, 2019, 05:00:03 AM »
Here it is strutting its stuff.

This is version 0.1 so..

No  changes aren't immediate.  I borrowed the chapter from keeping power electronics cool section thermal resistances to calculate that the outside temp will track the inside temp by some %.  As a value you can use to lookup in a book useless.  But to compare between different heights on the column all the special modifiers to the actual temp cancel out leaving the delta t's which is what I want.

When I run a column purge and drop the flow to 0 it takes about 25 seconds to go to full output  flow due to the thermal mass of the still head.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #8 on: January 01, 2019, 01:43:20 PM »
Nothing is so fine to do as a new way , so let see.
You said nothing about the column itself ?
Is the arduino making adjustments on the power only ? to control the still.
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #9 on: January 02, 2019, 01:35:59 AM »
K3.

Az is as simple as it can get.  6ft of 2" copper packed with 11 rolls of copper stuffit packing.  She is short 2 rolls, went through 100 ft of it since it is a repack of the chore boy copper scrubbers that disintegrated after 200 batches.

The cold finger is 3" shorter than it should be because I grabbed the wrong piece at the scrapyard because for a cold finger the condenser effective length is from the tip of the cold finger to the output port.  So her cold finger is short the half T and the dwv slip reducer.  It still works but unless you overcool the cold finger which cools the outer part of the column as well you get a drop every 10 - 15 seconds escaping.

The final ds18 is in that mess of ss  fittings. 

It is hard to get an accurate vapour temp when it is surrounded by so much colder metal.

I have a short segment that I am going to put a thermowell in to add to the top of the column for that reason maybe use a high precision platinum rtd.20190101_011635.jpgAlgorithms column temperature stabilization.
* 20190101_011635.jpg (1830.53 kB. 350x1255 - viewed 866 times.)




Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #10 on: January 02, 2019, 01:46:04 AM »
OK but why not take a smt172 sensor ? instead of a rtd

Do I miss one hose ? or do I overlook something ?
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #11 on: January 02, 2019, 02:30:13 AM »
Because I can push a higher accuracy using the 18/24 bit dac used in scales to measure the rtd.

Ah that pic was before the tweak.  Now the controlled water goes into the product condenser then into the cold finger the drain.  What was missing was the t that metered the water to the cold finger and provided water to the PC.

Here is the top shot.20190101_011718-1450x2981.jpgAlgorithms column temperature stabilization.
* 20190101_011718-1450x2981.jpg (723.89 kB. 350x719 - viewed 634 times.)

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #12 on: January 02, 2019, 03:17:57 AM »
Aha that was a better photo  :)

What accuracy are you aiming at ? as I cant believe it beats a smt 172

But it is just what you want from it even a ds18b20 is good for proces controlling.
But if you want to measure abv it becomes another story,I used both for the eparrot and know the benefit of a smt172.

What is also importand calibration , we do not need a sensor over his complete range ,it should be accurate within the small range we need.

Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #13 on: January 02, 2019, 09:38:21 AM »
Yes DS's are ok, they are cheap, do need calibration offset but are slow to read which buggers up PID algorithms. 

99.99% of distilling is a slow process, that .01 happens when it comes to a boil, and you happen to be making a drink time... so speed is really not an issue.

My desire for higher accuracy comes from noticing that the fores and heads do come out fractionated,  so when I collect enough heads I can run a just heads batch on a short path condensor and get some interesting compounds.

It also might help in the problem I am wrestling with is how the arduino will determine when to switch from heads to hearts since it can't do the eye aldehyde test.  The initial version will likely be just be a number of reflux/purge cycles. This last batch I ran 3 cycles for the foreshots, and 16 cycles for the heads and it came out super fine.  Will see if it is same for next batch.
 

I haven't played with an  SMT 172 yet, looked at the data sheet looks good.  Apparently the LM34 is also good if you hook it up to a big enough DAC. 

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #14 on: January 02, 2019, 01:56:57 PM »
Complete automatic , say let the arduino decide when to switch between fores heads heart tail is not a option, but that is my opinion ,too many parameters involved I think.

But a acceptable system like below could be a option?

You could make a input menu :
input barrel  ltrs
input barrel abv
output ltrs abv to 100%

Followed by:
Calculation like every one uses in the beginning.
3%fores
17% heads
57% hearts
23% tails
All recalculated based on the ammount off output by 100% abv
And let the arduino do a calculation and make the cuts,by measuring the ammount of take off,recalcullated to 100% abv with a flow meter rather than on temp.

Is this a fine situation NO as my column can do better and yours maybe too , but someone else maybe worse.
I'am not shure if for different washes  parameters change ?

Or do you have other plans ?

I personaly do not need a so far automated system,I could do with the system of Edwin with the peristaltic pumps,and the digital display shows the output rate and total product take off , so easy to decide when to switch jars,maybe with a little extra tye system could switch jars also.

If you not force into wanting the very first drop and sqeeze out the very last drop you can be succefull I think ......and collect the leftovers for resuse later.

But maybe I did not understand excactly your goals ?  ::)

Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #15 on: January 02, 2019, 07:09:24 PM »
We both use refluxed column stills, so the normal cut table does not really apply.  Where for me it is different is:

Fores : still about 3%
Heads: about 15% (ever since I learned about the eye aldehyde test, it is a bit larger but the product sooo much better.
Hearts : about 75+%
Tails : about 5%

So yes I can make cuts based on user adjustable "just 'cause" points.

Although I do wonder if those mpq? gas sensors might work in detecting aldehydes.

I did a bit of work with a transconductance meter way way back.  Essentially you put a two RF waves through a sample, one you drive, and one that you measure.  At what frequencies you get good conduction tells you the makeup of the sample in question. 

But maybe I am making a mountain out of a molehill.

The nice thing is that Edwin has created a beautiful table with abv.  So the only thing we really need is the volume of the charge in the boiler.  If we know the energy we are putting into the boiler, we can calculate based on temp rise the abv of the contents of the boiler.

I'm thinking that might be a nice run screen.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #16 on: January 02, 2019, 10:26:33 PM »
You wrote:

[quote we can calculate based on temp rise the abv of the contents of the boiler.[/quote]

Ok why ? the eparrot already gives the abv of the boiler ?
Better bad weather than no weather

Offline Hooch

  • Posts: 97
Re: Algorithms column temperature stabilization.
« Reply #17 on: January 03, 2019, 01:07:00 AM »
I haven't run the eparrot code so I am not sure if it does that. I'll write the code to show it and post it.  Bottom line is we assume it is a binary mixture of water and ethanol then a unique solution exists for the function of volume v and energy input P and a delta t.

Here is another past run log with the outside sensor, boiler and two on the outside of the column about 8" apart.

Offline ketel3

  • Admin
  • Posts: 1377
  • Eparrot.org
Re: Algorithms column temperature stabilization.
« Reply #18 on: January 03, 2019, 01:24:19 AM »
I have a look at it.

Yes the aparrot does that it gives info about boiler temp/abv.

Even the heatup time is displayed  so if you say 70 dgrs as alarm for turn on the cooling water it tells you how long the heat up time is and keeps the time updating during the heatup you are free to choose the set temp,Mine is set to 80 dgrs.

Better bad weather than no weather