View previous topic :: View next topic |
Author |
Message |
gs
Joined: 22 Aug 2005 Posts: 30 Location: Ioannina - Greece
|
PID algorithm questions |
Posted: Sat Jul 25, 2009 6:02 am |
|
|
Hello I am trying to implement a PID controller to control temperature.
I have a question to make. The integral term is the sum of the past errors. ok but what happens when the error becomes small? (the temperature is about to reach the set value?) The integral term is always bigger and bigger.
I think that the integral term should *somehow* decrease and become zero when the the error becomes zero. What am I missing here?
Best regards from Greece
John _________________ www.hlektronika.gr |
|
![](templates/subSilver/images/spacer.gif) |
sirius
Joined: 27 Jun 2009 Posts: 16 Location: Bulgaria
|
|
Posted: Sat Jul 25, 2009 9:15 am |
|
|
Summing the instantaneous error over time (integrating the error):
I = Ki * Sum e(t)dT
where
I: Integral term of output
Ki: Integral gain, a tuning parameter
e: Error = SP − PV
SP: setpoint value
PV: present value
t: Time or instantaneous time (the present)
τ: a dummy integration variable
From the equation is seen,that when the error / e=SP-PV / becomes smaller,Integral term decreases.When SP/set point/ is reached/overshot/, e /error/ = 0 or negative and Sum e(t)dT and I are getting smaller,and after a given time I=0.So,when equilibrium is reached in your system /SP=PV/ ,I=0,and Integral term is eliminated!You've made a mistake somewhere in your algorithm.
Basically,you should do this:
e: error
sum_e: accumulated error over time
1 step: e=SP-PV
2 step: sum_e = sum_e + e
3 step: I = Ki * sum_e
4 step: wait xx time of Integral_cycle
5 step: repeat 1,2,3,4 and so on.
And one more thing - you should limit the accumulated error:
if sum_e>sum_e_limit - sum_e=sum_e_limit
That's because the integral term is responding to accumulated errors from the past and it can cause the present value to overshoot the setpoint value. |
|
![](templates/subSilver/images/spacer.gif) |
ariel.vollmann
Joined: 23 Jul 2009 Posts: 7 Location: Córdoba - Argentina
|
|
Posted: Sat Jul 25, 2009 9:23 am |
|
|
Hi John,
Under normal circumstances the integral part of the PID should help the equation to converge to an "zero error" situation when the error is small ("when the tempereture is about to reach the set value").
If the integral part is growing continuously I think that maybe is somehow not taking part of the equation.
Try revising the operations you make with that integral term, maybe the factor you are multiplying to this term to create the complete equation and all the mathematical operations.
Isn't that factor too small? Tunning an PID equation is not always an easy task...
If you can't solve it it would be helpful if you post some of the code.
Greetings from Argentina |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sat Jul 25, 2009 10:44 am |
|
|
Assume a heater controller. During warm-up phase, e is always positive, thus the integral is increasing up to it's allowed limit. Usually, the integration is stopped when the controller output (manipulated value) reaches it's limit, e.g. 100 % power for a temperature controller.
You're asking, how the integrator output can be cut back to near zero in equilibrum?. Typically, a small overshoot of the process value is required to achieve this. |
|
![](templates/subSilver/images/spacer.gif) |
gs
Joined: 22 Aug 2005 Posts: 30 Location: Ioannina - Greece
|
|
Posted: Sat Jul 25, 2009 12:05 pm |
|
|
FvM wrote: | ...
You're asking, how the integrator output can be cut back to near zero in equilibrum?. Typically, a small overshoot of the process value is required to achieve this. |
Yes, I see this in my test program. I read a pot with ADC to emulate the feedback. If I set the pot over the threshold (overshoot) for a while, the I term decreases, but I don't want overshoot in my design.
I will do some more research and then I will post my code for further discussion. _________________ www.hlektronika.gr |
|
![](templates/subSilver/images/spacer.gif) |
sirius
Joined: 27 Jun 2009 Posts: 16 Location: Bulgaria
|
|
Posted: Sat Jul 25, 2009 12:46 pm |
|
|
Quote: | Usually, the integration is stopped when the controller output (manipulated value) reaches it's limit, e.g. 100 % power for a temperature controller. |
I think this is what you need,or put a limit of the accumulated error,as I previously mentioned. |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Jul 25, 2009 12:58 pm |
|
|
PID loops are usually set for "critical damping" which gives the smallest absolute error * time integral, but this inherently gives some overshoot. If you can not have any overshoot you need an over-damped solution, which will be slow, or use something smarter than a PID algorythm.
In fact with no overshoot the integral term will never decrease. Try just using P & D. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Jul 26, 2009 11:56 am |
|
|
Quote: | In fact with no overshoot the integral term will never decrease. Try just using P & D. | A PD controller implies a static temperature error, which is most likely worse than some overshoot. Basically, a different controller type, e.g. a dead beat controller should be used for optimal control without overshoot. |
|
![](templates/subSilver/images/spacer.gif) |
jma_1
Joined: 08 Feb 2005 Posts: 147 Location: Wisconsin
|
|
Posted: Sun Jul 26, 2009 1:49 pm |
|
|
Greetings,
Adding extra logic to your control might assist in your application.
Suggestions:
Temperatures change very slowly (relatively slow compared to a uProc). Updating your PID algorithm at a different rate may help your application.
The classic PID problem is integrator windup. Searching the internet for possible suggestions is warranted. In a slow moving system such as temperature control, integrator windup might be an issue.
How about adding logic if the application is closing on the target, don't do anything else. This would prevent having to remove the integrator term contribution and perhaps help limit your overshoot. More logic would be required, but this might get you going in the direction.
Cheers,
JMA |
|
![](templates/subSilver/images/spacer.gif) |
sirius
Joined: 27 Jun 2009 Posts: 16 Location: Bulgaria
|
|
Posted: Sun Jul 26, 2009 5:04 pm |
|
|
How about using Fuzzy Logic? |
|
![](templates/subSilver/images/spacer.gif) |
Facu__ Guest
|
|
Posted: Mon Jul 27, 2009 6:19 pm |
|
|
It looks for in the forum todopic, there there is a control example PID with anti-windup with PIC.
Greetings |
|
![](templates/subSilver/images/spacer.gif) |
s_mack
Joined: 04 Jun 2009 Posts: 107
|
|
Posted: Sat Sep 05, 2009 3:43 pm |
|
|
can someone translate that last post for me It sounds like he's trying to say there is sample code somewhere showing an example PID with anti-windup. I searched... no find. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 05, 2009 4:49 pm |
|
|
Google for this, and select the translate page option to view each link:
Quote: | site:todopic.com.ar/foros/ PID anti-windup |
|
|
![](templates/subSilver/images/spacer.gif) |
|