Get your HBT Growlers, Shirts and Membership before the Rush!


Home Brew Forums > Home Brewing Beer > DIY Projects > Fermenters > DIY PID controller - beginner Arduino project
Reply
 
LinkBack Thread Tools
Old 09-15-2012, 11:11 PM   #21
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Well, this time it gave me:

kp: 102.89 ki: 0.06 kd: 0.00

I can't even begin to guess what kind of overshoot that's going to bring on.
I think 102.89 is the local Spanish radio station.

__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-16-2012, 12:36 AM   #22
Bonj
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2007
Location: Ipswich, QLD, AU
Posts: 10
Default

hehehe

I think the autotune library is pretty rubbish. It gave me similarly ridiculous results on my test system. I don't question the suitability of PID control, but I think even a moderately well tuned system tuned manually will easily outperform the garbage results from the autotune lib. I suspect that the window size and sample interval may also need to be tuned for a temperature control system like we're dealing with here. I suspect that as the mass of the water being heated increases, an increase of the sample interval will be beneficial.

__________________
Mediocrity - It takes a lot less time, and most people won't notice the difference until it's too late.

Hit and Miss Brewery - Ipswich Queensland

On Tap: null
Conditioning: null
In no-chill: null
In Primary: null
In Planning: Vienna / Helles lagery type thing with tettnanger
Bonj is offline
 
Reply With Quote Quick reply to this message
Old 09-16-2012, 12:54 AM   #23
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Yeah, I'm NOT QUITE ready to give on PID without overshoot. I've got an Auber PID & RTD that I can use with this very system that does precisely that. I just don't seem to have the skills yet to duplicate it with Arduino.

I am ready, however, to give up on the autotune library. Today was my last shot at it. Tomorrow (I hope), I'm going to start this thing up, let it run at 5% until is stabilizes where ever that may be, and collect some numbers to attempt to manually tune using the Lamba tuning method I've seen elsewhere on the 'net.

__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-16-2012, 05:57 AM   #24
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Instead of sleeping, or doing the dishes or whatever I *should* be doing, I went back out to the garage. I wrote a crude, quick few lines of code. Here's the result:

I had the kettle at 132, then turned on Processing to run the PID front end so I could capture this 20 degree ramp up for you guys:

And here it is a few minutes later, hovering 0.3 degrees under.


So, that's a 20 degree ramp in about 4 minutes, with less than half a degree overshoot.

The code is too unpolished to share yet. No PID library, just a pretty primitive set of ifs.

If I'm over the Setpoint, Output is 0
If I'm more than 10 degrees under, I'm at 100%
If it's between, then the Output is just: (50+(Setpoint-Input)/10)

What is that, control guys? Just a "P" controller?

I gave it an extra 50 milliseconds so that when the input dropped back below the setpoint, the controller would go ahead and start back up at 5% instead of something smaller, because I know that's kinda-sorta-close to where I need to be to maintain a temp. I watched for a few more minutes after that second screen, and I never came back up to my setpoint. I'm going to have to change that offset, but not by much, or I'll increase my overshoot. I'm going to increase it to 6% tomorrow and see how it goes.

Still, less than a degree of overshoot & less than a degree of undershoot is nothing to sneeze at. I'm encouraged!

__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-16-2012, 11:09 AM   #25
guindilla
Feedback Score: 0 reviews
Recipes 
 
Join Date: Feb 2010
Location: Madrid, Spain
Posts: 20
Default

Sometimes simple solutions are better suited to simple problems... I am sure the PID library must be well suited to complicated processes, but it looks like in this case your if's are a far better solution.

How did you interface the Arduino with the Processing? Did you program the PID frontend?

Thanks.

Edit: Funny this, I've been tens of times reading the PID library reference, and I've just now realized there is a front-end included!
http://www.arduino.cc/playground/Code/PIDLibrary
http://arduino-pid-library.googlecod...ontEnd_v03.zip
Sorry about the basic question.

__________________
guindilla is offline
 
Reply With Quote Quick reply to this message
Old 09-16-2012, 04:03 PM   #26
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default



I'm at it again this morning. That's a 15 minute window. I'm still overshooting 0.5, and then hovering under 0.2-0.3. I'm going to try to work that out, and keep you posted.
__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Old 09-17-2012, 12:36 AM   #27
Bonj
Feedback Score: 0 reviews
Recipes 
 
Join Date: Jul 2007
Location: Ipswich, QLD, AU
Posts: 10
Default

interesting graphs... thanks for posting them

__________________
Mediocrity - It takes a lot less time, and most people won't notice the difference until it's too late.

Hit and Miss Brewery - Ipswich Queensland

On Tap: null
Conditioning: null
In no-chill: null
In Primary: null
In Planning: Vienna / Helles lagery type thing with tettnanger
Bonj is offline
 
Reply With Quote Quick reply to this message
Old 09-17-2012, 05:09 PM   #28
FastTalker
Member
HBT_SUPPORTER.png
Feedback Score: 0 reviews
 
FastTalker's Avatar
Recipes 
 
Join Date: Sep 2011
Location: Nashville, TN
Posts: 130
Liked 4 Times on 4 Posts
Likes Given: 4

Default

Quote:
Originally Posted by chuckjaxfl View Post
The code is too unpolished to share yet. No PID library, just a pretty primitive set of ifs.

If I'm over the Setpoint, Output is 0
If I'm more than 10 degrees under, I'm at 100%
If it's between, then the Output is just: (50+(Setpoint-Input)/10)

What is that, control guys? Just a "P" controller?
Your response looks great. You have a good starting point with the conditional logic for the output value. Even with PID control it is not uncommon to use a software manual mode as a type of feed-forward control to preemptively set your output to 100% as you are doing here.

Quote:
Originally Posted by chuckjaxfl View Post
I gave it an extra 50 milliseconds so that when the input dropped back below the setpoint, the controller would go ahead and start back up at 5% instead of something smaller, because I know that's kinda-sorta-close to where I need to be to maintain a temp. I watched for a few more minutes after that second screen, and I never came back up to my setpoint. I'm going to have to change that offset, but not by much, or I'll increase my overshoot. I'm going to increase it to 6% tomorrow and see how it goes.

Still, less than a degree of overshoot & less than a degree of undershoot is nothing to sneeze at. I'm encouraged!
You can eliminate that small amount of error at steady-state with a little integral gain using a PID controller. The problem with only using proportional is never getting to setpoint at steady-state. There are lots of factors that will govern where the controller will settle out: the volume you are heating, the temperature setpoint, the ambient air temperature, a breeze, etc. You might frequently find yourself adjusting that 5% or 6% output "offset".

I think this a great example to show how to set PID gains for water/liquid heating applications like this where you are accumulating heat. A good amount of proportional, a little integral (just enough to eliminate the steady-state error), and optional derivative (if you want to reduce overshoot).
__________________
FastTalker is offline
 
Reply With Quote Quick reply to this message
Old 09-17-2012, 09:31 PM   #29
bblack7489
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2009
Location: Austin
Posts: 123
Liked 3 Times on 3 Posts

Default

Out of curiosity, what type of sensor are you using? Is the accuracy of the sensor really better than 0.2 deg? If not, I'd suggest that you call it good enough and move on to brewing beer instead of tuning PIDs. However, if you're like me then that's probably not an option since you'll know in the back of your mind that it could be controlled a little tighter.

What you've essentially set up is a PID algorithm where you're only using the P control. You have your "P" gain set high enough that the controller output saturates when the temp is more than 10deg from the setpoint. If you want to get rid of the overshoot, you could reduce your gain. You could also use a quadratic or cubic function instead of the linear gain that you currently have. As FastTalker posted above, the I and D gains can help you take care of the steady-state error and overshoot respectively as well.

All of that said, I use On-Off control and really happy with it. I get about 0.5 deg overshoot and virtually zero steady-state error. Even better, there's no tuning and it will always represent the fastest ramp time to get up to temperature. In controls-speak a resistive heater in a well-stirred liquid is about as close as you'll ever get to an ideal integrator, so it's a pretty perfect candidate for On-Off.

__________________
bblack7489 is offline
 
Reply With Quote Quick reply to this message
Old 09-18-2012, 02:58 AM   #30
chuckjaxfl
Feedback Score: 1 reviews
Recipes 
 
Join Date: Feb 2010
Location: Jacksonville, FL
Posts: 327
Liked 19 Times on 12 Posts
Likes Given: 23

Default

Quote:
Originally Posted by Bonj View Post
hehehe

I think the autotune library is pretty rubbish. It gave me similarly ridiculous results on my test system. I don't question the suitability of PID control, but I think even a moderately well tuned system tuned manually will easily outperform the garbage results from the autotune lib. I suspect that the window size and sample interval may also need to be tuned for a temperature control system like we're dealing with here. I suspect that as the mass of the water being heated increases, an increase of the sample interval will be beneficial.

You know, I guess we're also not taking into account WHICH formula the autotune library is written for, either. I'm guessing that this uses the ZN formula, which, by design, *does* overshoot.


Quote:
Originally Posted by FastTalker View Post
Your response looks great.
Thanks!

Quote:
Originally Posted by FastTalker View Post
You can eliminate that small amount of error at steady-state with a little integral gain using a PID controller. The problem with only using proportional is never getting to setpoint at steady-state. There are lots of factors that will govern where the controller will settle out: the volume you are heating, the temperature setpoint, the ambient air temperature, a breeze, etc. You might frequently find yourself adjusting that 5% or 6% output "offset".
Which is exactly what I'm going to try next. I intend the define a "course" band of temperature below the setpoint that uses my control and creates my curve, above. And then a "fine" band around the Setpoint, maybe plus or minus 1.5 or 2 degrees in which the PID library is in charge.

My big gripe has always been the overshoot. The kP, kI & kD may very well be correct for my system; I'll bet they are on a long enough timeline. I'm hoping that if I turn control over to the PID when the slope of the line is closer to horizontal, that it will give me the result I'm looking for.

Quote:
Originally Posted by bblack7489 View Post
Out of curiosity, what type of sensor are you using? Is the accuracy of the sensor really better than 0.2 deg? If not, I'd suggest that you call it good enough and move on to brewing beer instead of tuning PIDs.
I'm using a DS18B20. It jumps in 0.11 degree increments. If anyone knows how to get more granularity, let me know! This doesn't keep my from brewing at all, by the way. I can unscrew that thermowell and have my RTD and Auber PID hooked up in minutes. This whole project is just to indulge my inner geek.

Quote:
Originally Posted by bblack7489 View Post
However, if you're like me then that's probably not an option since you'll know in the back of your mind that it could be controlled a little tighter.
Precisely that. I'm fully conscious that there's NO WAY my palette is ever going to detect the difference between beer mashed at 151.0 and another 151.5. This is just one of those things I've decided to chase.
__________________
chuckjaxfl is offline
 
Reply With Quote Quick reply to this message
Reply



Quick Reply
Message:
Options
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arduino Kegerator Temperature Controller luke_l Kegerators and Keezers 9 07-30-2013 01:39 PM
New Open Source Arduino Based PID Controller Released bendiy Brew Stands 9 02-11-2013 09:33 AM
Arduino questions (mash temp controller) Beezer94 Brew Stands 3 06-12-2012 03:53 PM
Arduino+XBee Dual-stage Temp Controller Chuginator Fermenters 65 12-18-2011 09:44 AM
Project Box for Arduino BulldogBrewer Brew Stands 0 09-30-2010 09:27 PM



Newest Threads

LATEST SPONSOR DEALS