Author Topic: PID controlled cave questions  (Read 10442 times)

BobE102330

  • Guest
PID controlled cave questions
« on: August 15, 2012, 02:07:18 PM »
I received my PID controller yesterday and have questions for the control gurus.  My controller is a very basic Mypin TA4-SNR.http://www.mypinchina.com/en/Product.asp?ClassID=178&ParentID=149&Child=0&Depth=1.  Available documentation is pretty sparse with a poor translation to English. 

Current settings: P=2%, I=2, D=off, Hysteresis=10 output SSR.  I am using a solid state relay to switch the power and a bare type K thermocouple.  With a 52 deg. set point temperature ranges from 55 to 49.

What parameter controls the time of the cooling cycle?  As the temperature approaches the set point the controller set point the controller cycles the compressor on and off rapidly, causing the compressor to run at a slower speed (at 1 degree off set point the fridge visibly vibrates).  Having no knowledge of control theory, I experimented a bit.  Setting I=off seems to make the cycling much more frequent.  Reducing P from 3 to 2 seemed to reduce cycling but increased temperature variations.  (I remember someone saying that putting the thermocouple in a small quantity of water could help slow cycling, will try that if I can't make it work with controller programming.)

How long should Autotuning take?  I've run it a couple of times, not completing within an hour or two.  If the current temperature is above set point it just stays off and warms to ambient.  If current temperature is below the set point it cools to 30 degrees or so.   I expect the controller will want to characterize the system but this seems overboard.  I tried reducing the range of possible set points from factory 0-1000F to 40-60 and restarted auto tune.  We'll see how that runs and see where it is when I get back from work.

I have a homebrew analog electronic controller I can use if this doesn't work out, but being a gadget junkie I'd like to have everything PID controlled.  Eventually I'd like to make a PID controlled cooker that I can program to ramp up the temperature at the appropriate rate.  A ramp/soak RS-485 programmable controller is just the ticket.  Load the cheddar profile and away we go...

Thanks in advance for any advice. 


Update - even with the set points limited to 40-60F, autotune still drives the fridge to maximum cold.  I'll let it run all day and see what happens, but in this case it seems like autotune works as well in PIDs as it does in audio (oh I despise the sound of that "fix")
« Last Edit: August 15, 2012, 02:41:16 PM by BobE102330 »

BobE102330

  • Guest
Re: PID controlled cave questions
« Reply #1 on: August 16, 2012, 12:12:49 PM »
Either my controller doesn't work properly or I don't understand how to run autotune.  I left it running all day and it managed to get the fridge to 10 F.  Went back to run mode and it's holding temperature, but still cycling rapidly when approaching the set point. I need to calibrate my thermometer and the thermocouple, since they disagree by a couple of degrees. 

Can anyone offer a simplified version of control theory for a brain better suited to tweak and see what happens than measure and calculate?

mjr522

  • Guest
Re: PID controlled cave questions
« Reply #2 on: August 17, 2012, 03:00:03 AM »
It's been a number of years since I took design of feedback control systems.  I barely remember most of it...we used Matlab a lot...

I haven't really thought about the use of a PID for temperature control.

The basics of a PID controller, from what I recall, are in the letters P, I, and D.  Each stands for a mathematical idea.  The P is the first and easiest to understand--Proportional.  It takes the difference between your set point and the measured point and multiplies it by some proportionality (the value you put in for P).  I think about these controllers best in terms of a step motor (a motor than knows how many times it has turned).  If I want the motor to hold a position that corresponds to 12 o'clock, and the motor is currently at 6 o'clock, there is a difference of "6" whatevers.  If I set my controller's P value to "1", I get 1 x 6 = 6 units of output to my motor, if I set it to 2, I get 2 x 6 = 12 units of output to my motor, etc.  Make sense?  That output from the controller to the motor causes the motor to rotate towards 12 o'clock.  The speed of rotation is based on the value of the output--greater output --> greater speed.  Once the motor begins to rotate towards 12 o'clock, the output of the controller gets smaller.  Consider  P = 1, at 6, the output is 6, as the motor rotates to 5, the output drops to 5, and so on.  If the rotation back towards 12 is slow, then when the motor gets to 12:01, the output from the controller will only be .01, which might not be enough to bring the motor all the way to 12.  If the rotation was fast (and the motor has mass), the motor will overshoot 12 o'clock, and the controller will start giving a negative output, trying to bring the motor back to 12.  If the P value is high enough, this can create an enormous oscillation with the motor swinging back and forth past 12 o'clock.  Because of these two issues--too low P and you never reach your target, too high P and you swing back and forth past it--we include D's and I's.

I stands for integrative.  The integrator takes the time-accumulated difference between the set target and the actual value and adds that to the output of the controller.  If you are just using I, no P = 0 and D = 0, then the output of the controller follows an equation like, output = sum [(actual value - set point) * time] * I.  So, for example, if you're at 6 o'clock, and are only using I, then at first nothing will happen.  After some amount of time, the motor will slowly begin to rotate up towards 12.  It will continue to rotate, speeding up as it goes, until it (maybe) passes 12 o'clock at which point it will slowly begin to slow down and eventually will try to return to 12, passing it again.  Now, recall that a small P will get me close to 12, but might not ever actually get me there, because there's not enough output.  If I add a little I to that P, then, the P will get me close to 12 and then, over time, that small difference between the motor's actual position and 12 o'clock will add up, because of the I and the controller will eventually bring it up to 12.

This might sound like a good solution for what your looking for.  In many applications, this takes too long, so they use a big P, which causes it to overshoot, but they add some D (which adjusts the controller output based on a differentiation of the difference--essentially watching the rate of change) to control the rate at which the motor moves.  This reduces the degree of overshoot and, thus, the swinging.

When you use all 3, your basically using the P to get you where you want to be quickly, the D to stop you from oscillating, and the I to bring you right on target (because the P and D have too small of an output close to the target).  Does that help?  Does anyone remember this stuff better than me and have corrections to make?

Now, with all the said, I don't really understand how you use a PID controller for a refrigeration system--I typically think of them as on/off.  I suppose you could directly control the compressor motor with the controller.  I'll have to think about how that would actually work...
« Last Edit: August 17, 2012, 05:35:24 PM by Mike Richards »

Offline Boofer

  • Old Cheese
  • *****
  • Location: Lakewood, Washington
  • Posts: 5,015
  • Cheeses: 344
  • Contemplating cheese
Re: PID controlled cave questions
« Reply #3 on: August 17, 2012, 05:24:51 AM »
Before everyone writes this off as TMI  ;), I think it's important to recognize that there may have been a few souls out there pining away with a thirst for the knowledge given here...and that deserves a cheese. Here you go, Mike.

This tidbit should probably go into the library as a reference.

-Boofer-
Let's ferment something!
Bread, beer, wine, cheese...it's all good.

mjr522

  • Guest
Re: PID controlled cave questions
« Reply #4 on: August 18, 2012, 05:02:39 AM »
Thanks, Boofer.  It's the teacher coming out.  I always let my kids out on time, but I always wish I had longer with them to help them "really" understand.  Here are some more "long-winded instructor" thoughts on temperature control, if anyone is interested:

I've contemplated the use of PID controllers in refrigeration today.  I talked with our thermo-fluids curriculum chair, and neither of us can see how the use of PID control makes sense in a hobby-level refrigeration scheme (or even a small commercial setup).  There are, it turns out, really high-dollar compressor units with variable stator vanes that could be controlled using PID, but all I know about those is that they exist and that normal people don't use them.

In general, a refrigerator maintains temperature control by kicking on when the temperature reaches a set "high temp" and stays on until the temperature reaches a set "low temp".  Units that cycle on and off too quickly have too tight set temperatures (the high and low are too close) for the system. 

What determines too tight?  Well, there are a couple of things: how well the system is insulated and the thermal mass contained within the system.  If the system were perfectly insulated, you could dial in a temperature, pull it down to that temperature and turn the unit off.  The temperature will stay the same indefinitely (unless you take into account the heat produced within the system by living things).  There is, however, no such thing as a perfectly insulated system.  We do the best we can on that front by insulating well.

The second item, thermal mass, is really all about how much stuff you have in the system.  Given two identical cheese caves, one full of cheese, the other mostly empty with only a few cheeses, the cave full of cheese will experience fewer swings of temperature between the high and low than the one with only a few cheeses.  This should make sense to most people (almost intuitively), but if it doesn't, consider that for the temperature to rise in the room full of cheese, all of the cheeses' temperatures need to rise too.  Since the two caves are identical, they both experience the same rate of heat transfer, and so the cheese with less thermal mass (stuff), takes less time to warm up.  Personally, because I can only make cheese every other weekend, I keep a lot of bottled water in my cheese cave  to fulfill the role of thermal mass. 

If you're not satisfied with your cheese cave's temperature control, consider improving the insulation of the system or adding more thermal mass. 

If your compressor cycles on and off too often, your set temps are too tight for your system (ignoring problems with electrical stuff and poorly located thermocouples/thermistors/dtc).  Improve your system, loosen your set temperatures.

If you're still reading and you successfully use a PID controller for refrigeration, I'd be interested in hearing what you are actually doing.  I'd be particularly interested if you know you are actually using PID control and not just establishing "switch on" and "switch off" temperatures.

BobE102330

  • Guest
Re: PID controlled cave questions
« Reply #5 on: August 18, 2012, 01:10:59 PM »
Thanks Mike.  That was exactly what I was looking for.  Articles I had found defined PID, but didn't offer such a clear explanation of how each term would affect the system performance. For some people the math may be clear, but not me this far out from college. Now I can feel a little more comfortable adjusting values. My values are currently P=2, I=2, D=off, Hysteresis=5.  That gets me +/-3 degrees.  I'm sure that is close enough, generally maintaining 49-55 degrees, but being an inveterate tweaker...  I have my sensor in a 2 oz. bottle of water on the middle shelf.  That seemed to cure the rapid cycling, but also seems to be contributing to wider swings.  I was seeing +/- 2 degrees before that. 

Thinking about it, the analog controller I made is a PI control.  I used this circuit: http://sound.westhost.com/project42.htm  Throws in a bit of positive feedback to establish the hysteresis. 

I like your suggestion to add thermal mass.  I am also an every other weekend cheese maker, at this point the PID cave holds 5 ~2 pound cheeses. Hoping it will have a couple more by next weekend. 

Boofer:  Mike's explanation of PID controllers is about as succinct as possible. He definitely deserved the cheese. There are several folks using PID controlled cheese cookers, and I am pretty sure that I am not the first to use it to control my cave.  As inexpensive as PID control is ($35 for components, add an enclosure), it makes sense to buy rather than build your own.  For a little less than a Johnson or similar controller you get external temperature monitor.  You need to be comfortable and competent with mains wiring is the only down side I see.

More expensive PID controllers can be programed to ramp up temperature over time, perfect for repeatable cheesemaking.  That's next month's project.  :)

klschnepp

  • Guest
Re: PID controlled cave questions---now how about heat??
« Reply #6 on: August 30, 2012, 07:16:02 AM »
Mike, you are a genius!  I was looking for the information you so kindly provided.  THANK YOU.  I am now somewhat better able to consume the technical detail I am finding out on the web.   However, I readily admit to really only understanding it in concept.

So, now the tuning begins.  Greetings team geek! ;D  I have hooked my PID to my bain marie/heating table and the tests are showing a large overshoot to set point.  Auto-tune has not helped, but no surprise there based on the information provided.  I am playing with the settings, but interested if anyone has a settings protocol they are happy with??  I did a search of the boards (including the seminal post that kicked this whole thing off - "digital cheese vat with 5 gallon capacity..." at http://cheeseforum.org/forum/index.php/topic,7495.0.html) and am not finding anything specific.  Any info would be appreciated.

UPDATE-- I just realised that this question is really a hijack of the post and does not belong on this particular topic -- apologies  :-[.  I started a new topic here: http://cheeseforum.org/forum/index.php/topic,10135.0.html.   Again, any help would be appreciated.
« Last Edit: August 30, 2012, 07:37:57 AM by klschnepp »

BobE102330

  • Guest
Re: PID controlled cave questions
« Reply #7 on: August 30, 2012, 10:50:11 AM »
No worries. Anything that furthers my understanding of PID control is fine by me. I will be following your new thread.