Wireless Controller and App Developement

If it plugs in, post it here.

Moderator: Site Moderator

Post Reply
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Wireless Controller and App Developement

Post by tjsc5f »

Over the past few weeks I've been working on a wireless (bluetooth) controller that uses an Android app as an interface.
What started off as a simple slider to drag around and control a voltage regulator quickly snowballed into a full blown controller with multiple modes, feedback and various (optional) PID controls.
The Software:
Android App developed with MIT App Inventor
3 modes of operation:
1) Pot Still Mode - Boiler, vapor and coolant temp measured with temp probes in thermowells. Boiler ABV and Product/Vapor ABV calculated based on measured temps and atmospheric pressure compensation (pressure measured with phone baro pressure sensor). Vapor rate calculated based on power input and column diameter. Product rate based on power input and boiler ABV.
Boiler power is a sider with a linear power output. This is a big improvement over the "SCR"s with knobs that are super sensitive and only work in the last ~20% of their range. The aux power switch controls a secondary element, on or off only.
Coolant SP (setpoint) is the target for a PID controlled cooling loop. In my case it varies the RPM of a cooling fan, but it could easily be configured to vary coolant flow as well.
Pot.jpg
2) Manual Reflux Mode - Same as Pot Mode, but Reflux control added. In my case, the slider controls a stepper motor that is attached to a gate valve. 0% is fully open, 100% is fully close (100% reflux). The coupler has a worm incorporated that rotates a gear with an indicator on it. This gives a visual representation of valve position, similar to the handle of a ball valve ( vertical = valve close, horizontal = valve open).
ManReflux.jpg
3) Auto Reflux Mode - In addition to above, an ABV SP is added, which assigns a target for a PID loop linked to the head temp/abv. The thumb on the reflux slider is deactivated, but the PID activity is still displayed on the bar.
AutoReflux.jpg
4) Settings - Most of this is self explanatory (set your modes, put your still info in). Est. Losses (W) is a value adjusts the power based calculations and is mostly dependent on how well your still is insulated. The Data Logger option will send all of the info to a Google Sheet if it is activated and you are on wifi. Boiler/Vapor offsets are essentially temp probe calibrations.
Settings.jpg
Controller Firmware developed with Arduino IDE:
I started off using 4th/5th order polynomial equations found on the parent site and here on the forums to calculate the ABV from temperatures, and then luckily stumbled on Edwin Croissant's RGB EParrot project. Using his library to do the conversions cleaned things up a lot and allowed for pressure compensation which is awesome. The temperature offsets were some other features that I added because of the influence of his project.

The Hardware:
ESP32 microcontroller, LSA-H3P90YB solid state voltage regulator, DS18B20 temp sensors, SSR, H-Bridge motor controller, 24V power supply, NEMA 17 stepper motor, TB6600 stepper driver.

At this point everything is bench tested and working. As soon as the crazy hot weather breaks I'll do my first true test run and update.
I am not a programmer or coder - my code is super dirty, inefficient and probably even down right disgusting, but it works. If anyone is interested I'd be more than happy to share the .ino (arduino ide) and .aia (my app inventor) files.
GrumpyOldITGuy
Novice
Posts: 16
Joined: Sat Nov 13, 2021 9:11 am
Location: Appalachian Foothills

Re: Wireless Controller and App Developement

Post by GrumpyOldITGuy »

I'll be curious to see how this works when you fire it up "in anger" for a run. I've been thinking along the same lines also using an ESP for control of reflux and/or condenser water. My though was to use an RTOS because I like to over-complicate things for some reason. :lol:

If you do a google search for "Raspberry Pi Still Control" you'll find an older thread on this forum from someone else who also looked at automating some of the processes.
Eagles may soar... but weasels don't get sucked into jet engines.
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

GrumpyOldITGuy wrote: Sat Jul 16, 2022 6:31 am If you do a google search for "Raspberry Pi Still Control" you'll find an older thread on this forum from someone else who also looked at automating some of the processes.
Thanks, I hadn't stumbled on that one yet.

I battled the heat and got most of the hardware wired up in the box today. I tried using an optocoupler as a logic level shifter to drive the PWM input to the voltage regulator but it didn't work out, so I ordered a new board that should be here in the morning. Planning on getting that hooked up and boiling some water tomorrow as an initial test(will still be waiting for some cooler weather to do the real deal).
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

Mostly successful testing day. I put approximately 8 gallons of water in the boiler and spent some time measuring and scaling the controller output to match the range of the voltage regulator. After that I let it rip at full power and turned the data logger on.
First_Run.png
I turned the 2kW element off at 15 minutes once a boil was reached.

Nice, linear temp rise from 1-6 minutes:
linear.png
When the slope is near zero, we've reached the initial boiling point of the liquid. If it were a mixture of water and ethanol, we could estimate the starting ABV, density and specific heat. From those values we could then calculate the initial volume. In this case, for water, the calculated initial volume was 8.7 gallons. On my next run I will do a better job of measuring the initial volume and ABV to get better comparisons.

Close up of 10-25 minute range where I was messing with calibrating the probes:
Calibration.png
Overshoot at 13 minutes. Calibrated within 0.5°F of 212 at 15-20 minutes. I don't actually own a high accuracy thermometer for comparison, so at the 21 minute mark I decided to set each probe to the calculated pressure compensated boiling point and call it good enough.

The one big issue I ran into was at voltages around and below 50%, the voltage regulator was generating enough noise to make the temp probes error out. I'm not sure how to remedy this yet, but it is now at the top of my priority list.
User avatar
elbono
Site Donor
Site Donor
Posts: 610
Joined: Thu Oct 07, 2021 1:05 pm
Location: Middle Tennessee, USA

Re: Wireless Controller and App Developement

Post by elbono »

tjsc5f wrote: Sun Jul 17, 2022 7:42 pm Mostly successful testing day.
Congrats, projects like this are always more complicated than originally thought. One step at a time...
tjsc5f wrote: Sun Jul 17, 2022 7:42 pm Calibrated within 0.5°F of 212 at 15-20 minutes. I don't actually own a high accuracy thermometer for comparison, so at the 21 minute mark I decided to set each probe to the calculated pressure compensated boiling point and call it good enough.
If you want better accuracy this guy claims to have calibrated DS18B20s to within 0.1C over 0-100C with distilled water and gallium. Since 12 bit resolution is about 0.05C that's pretty impressive.
tjsc5f wrote: Sun Jul 17, 2022 7:42 pm The one big issue I ran into was at voltages around and below 50%, the voltage regulator was generating enough noise to make the temp probes error out. I'm not sure how to remedy this yet, but it is now at the top of my priority list.
Ferrite chokes might help kill some noise. I would make sure noise is the real problem before heading down that road, I've solved many problems that turned out not to be THE PROBLEM. If you're running the electronics on mains power, using a cellphone battery charger will give isolation.
I don't suffer from insanity, I enjoy every minute of it!
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

elbono wrote: Mon Jul 18, 2022 8:18 am If you want better accuracy this guy claims to have calibrated DS18B20s to within 0.1C over 0-100C with distilled water and gallium. Since 12 bit resolution is about 0.05C that's pretty impressive.
I'm planning on putting a PT1000 RTD in the vapor path with a 16 bit ADC later down the road for higher accuracy there. I think the DS18B20s will be fine everywhere else for my use.
elbono wrote: Mon Jul 18, 2022 8:18 am Ferrite chokes might help kill some noise. I would make sure noise is the real problem before heading down that road, I've solved many problems that turned out not to be THE PROBLEM. If you're running the electronics on mains power, using a cellphone battery charger will give isolation.
I don't have a scope, not sure if there are easier methods to measure noise with minimal equipment. The controller itself is connected through a cellphone style USB charger, and doesn't seem to be having any issues other than losing the temp probe signals, so I don't think conducted noise is an issue. I went ahead and ordered a line noise suppressor anyway, figured even if it didn't help, it wouldn't hurt.
I did order some ferrite rings for the load side, thinking radiated noise may be the issue.
In addition to that, I've read that reducing the pull up resistor on the signal line, adding an inline resistor to the signal line and adding decoupling caps could all improve the signal quality, so more things to try.

I'll look into adding error detection/ignoring code in the firmware as well, that probably should have been in there from the get go, but I'm learning as I go!
User avatar
Stonecutter
Site Donor
Site Donor
Posts: 1902
Joined: Fri Apr 16, 2021 2:40 pm
Location: Somewhere within the Milkyway

Re: Wireless Controller and App Developement

Post by Stonecutter »

Fancy.
Definitely next level, smoke and mirrors stuff.
I would think that the silly scope is going to be a must for projects like this.
I wish you the best of luck getting this thing up and going…all HD members get to download for free right? :ebiggrin:
Freedom had been hunted round the globe; reason was considered as rebellion; and the slavery of fear had made men afraid to think. But such is the irresistible nature of truth, that all it asks, and all it wants, is the liberty of appearing.
-Thomas Paine
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

Stonecutter wrote: Tue Jul 19, 2022 6:22 pm I wish you the best of luck getting this thing up and going…all HD members get to download for free right? :ebiggrin:
Of course, free downloads. Customer support will be pretty hit and miss though 8)

Had a really good weekend. Ran a cleaning run on Saturday with feints diluted down to ~30% and my first real run through this setup today with a ~9% AG beer.
For the cleaning run, I had 2x 4" bubble cap plates over a 1/2 barrel thumper. Reflux was provided by a fully opened CCVM with a 2" tee.
cleaning_run.jpg
I was bouncing the power around during the run to see if I had fixed my noise issue with the added capacitors/ferrites, and I had not...
I updated the firmware to include some error detection and all is good now!

For the first real run, I dropped down to a single 4" bubble cap plate over the thumper.
first_run.jpg
The spike at ~74 minutes was me calibrating the ABV in the wrong direction~
After the calibration, I compared the ABV from the App with temp corrected hyrdometer readings at 80%, 65% and 50%. They were all within less than 1% ABV, which is close enough for me.

I'll be doing a few stripping runs soon using just the thumper without plates to compare with Haggy's calculator outputs.
After that I'll start testing out the reflux control and see where that takes me
quadra
Bootlegger
Posts: 139
Joined: Mon Oct 11, 2021 11:53 am

Re: Wireless Controller and App Developement

Post by quadra »

Any updates for us lurkers?
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

quadra wrote: Tue Jan 24, 2023 11:27 pm Any updates for us lurkers?
Sorry, missed that question apparently.
The controller works well. After some time using, there's a few things I'd like to do differently.
Mainly, I want to get it off of my phone and onto a larger, standalone screen. I picked up a super cheap Fire HD8 on Amazon. It was a previous gen and on sale for ~$50.00. I started laying out a new UI for this size screen, with the "most important" (to me anyway) info displayed in large font so I could easily see it from across the room.
This is currently in early development, but here's what the home screen is currently looking like:
Home.png
Each info area is basically a large button, so when you press it, it brings up the controls for the different parts of the still.
Pressing the bottom brings up the boiler power control panel:
Boiler.png
I switched from a slider in my current version to a text box, for whatever reason I just prefer punching in a number to moving a slider around.

Pressing the middle button brings up the reflux control panel:
Reflux.png
I rarely do neutrals, so I never really got around to tuning my PID for chasing a vapor ABV. On this round I'll be experimenting with using the reflux ratio as a setpoint. For a flavored spirit, I may set a high ratio early in the run for pulling heads and then reducing it for hearts, and then pushing it up again for tails, etc.

Finally the top button brings up the product rate control panel:
Product.png
This allows you to set a desired product rate. If you enter a value here, it will override your desired power from the boiler section. Likewise going back to the boiler section and entering a desired power would override the desired product rate.

A barometric pressure sensor is the only bit of hardware I have to add to the controller. That data was previously acquired from my phone, but the Fire HD8 does not have a baro sensor.

More to come this fall, as it's too hot in the garage to do much stilling this time of year.
Stags
Bootlegger
Posts: 149
Joined: Wed May 24, 2023 9:40 am

Re: Wireless Controller and App Developement

Post by Stags »

Very cool OP. Reminds me a little
bit of my Traeger and the app control there.

One thought/ idea- I’d love to have the ability to keep the still “warm” without it actually “running” if something happens to happen and I need to put a run on hold for a bit and thereby avoid heat time on the restart.
tjsc5f
Swill Maker
Posts: 192
Joined: Sun Nov 28, 2021 9:18 pm
Location: MO, USA

Re: Wireless Controller and App Developement

Post by tjsc5f »

Stags wrote: Sun Aug 06, 2023 5:04 pm One thought/ idea- I’d love to have the ability to keep the still “warm” without it actually “running” if something happens to happen and I need to put a run on hold for a bit and thereby avoid heat time on the restart.
I actually have that in the new 8" version, on the boiler control panel, if you switch "Distillation" to "Pre-Heat", you can set a desired temp and the PID will hold it there (as long as the desired temp is below boiling".
Pre-Heat.png
Post Reply