The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

## Help tuning the PID algorithm for my oven. Moderators: adafruit_support_bill, adafruit

Help tuning the PID algorithm for my oven.

Hello, this is my first post here. I have been very impressed with the knowledge and experience that the posters have on this forum, so hopefully someone will be able to help me out.

I have built a reflow oven and I am having trouble tuning my PID algorithm. In all of the documents I have found on the subject, they all say to increase the proportional until you get slight oscillation, then increase the derivative. However, my oven has no way of cooling so if you totally cut the power to the heating elements, the temperature will continue to climb about another 20º, then it will stay there for a long time so I have no oscillation. I have overshoot, but no corresponding droop.

For a few hours I was trying to tune by running an actual reflow profile, I was actually able to get some oscillation that way because of the incline of the temperature rise, since the target temperature was always climbing, once I overshot, the target temperature would overtake the actual temperature resulting in a droop, and that would repeat a couple of times. I had huge overshoot once my profile went from phase 1 where I needed around .9º of temperature rise a second, to phase 2 where it switched to about .5º a second.

I realized that instead of trying to tune using an actual reflow profile, I should setup a "tuning" profile, where for the first 10 seconds, the targetTemp = currentTemp, and then the targetTemp would suddenly increase to 110º. That way I could get a better idea of what was happening when I changed my PID gains.

Here are my results at various amounts of pGain using my "tuning" profile.
pGain = 2 = no overshoot
pGain = 3 = 5º of overshoot
pGain = 6 = 11º of overshoot
pGain = 20 = 16º of overshoot
pGain = 120 = 20º of overshoot

I am still experimenting with different pGain values but I can't judge the correct value by oscillation, only by overshoot.

I am thinking that if I had about 2º of overshoot, that when I switched to phase 2, I would get very little or no overshoot. But once I start tuning the derative, it would act to dampen the effect of proportional, so ideally I should maybe shoot for around 4º of overshoot using only the proportional? These are the assumptions I am going on right now, but maybe someone can offer some insight into the best way of tuning this thing. But once I start running an actual reflow profile, my overshoot is going to change quite a bit, so I am really pretty confused about how I should be tuning this.

I am running my PID calculations 4x a second. If needed I can post images of my current tuning results that are in a graph. I am sending the data to my laptop where I am graphing it using c# and saving the results of each.

Ideally once I get this tuned, connecting my laptop will just be an extra option, otherwise I will be able to just press a button to start the oven.

Thanks
James.
jdraughn

Posts: 2
Joined: Sat Feb 04, 2012 7:41 am

Re: Help tuning the PID algorithm for my oven.

the temperature will continue to climb about another 20º, then it will stay there for a long time so I have no oscillation.

That is just the beginning of an oscillation with a very long period.

Posts: 27943
Joined: Sat Feb 07, 2009 9:11 am

Re: Help tuning the PID algorithm for my oven.

the temperature will continue to climb about another 20º, then it will stay there for a long time so I have no oscillation.

That is just the beginning of an oscillation with a very long period.

In my previous post I stated that instead of trying to tune using my actual reflow profile, I created a false one that would suddently rise to 110º and stay there. This was working at first, I had it all tuned pretty well, but once I switched to a real reflow profile, it was suddenly obvious that the tunings from the "fake" profile would not work in a real situation. I didn't have enough pGain so I was always about 10º under, the actual temp could not ever reach the desiredTemp.

I went back to using an actual reflow profile and I got it tuned about as good as I can, however my pGain is set at around 200, and my dGain is over 10k, which makes my precision drop to basically 2 bits. Watching my LED flash on and off, it's corrosponding duty cycle is either 0, 50%, or 100% because my gains are saturating my duty cycle.
jdraughn

Posts: 2
Joined: Sat Feb 04, 2012 7:41 am

Re: Help tuning the PID algorithm for my oven.

I didn't have enough pGain so I was always about 10º under

The integral term is typically used to eliminate the offset. (or at least bring it within tolerance)

Posts: 27943
Joined: Sat Feb 07, 2009 9:11 am

Re: Help tuning the PID algorithm for my oven.

Try the tuning section of this widely used article:
http://www.eetimes.com/design/embedded/ ... hout-a-PhD

As adafruit says, the integral term may well be your key to success here.
philipm

Posts: 29
Joined: Tue Dec 27, 2011 9:50 am