1
$\begingroup$

I'm trying to control temperature with PID(Kp,Ki, Kd). During the rise time the system use one PID and when target is reached the system switch to another PID with other parameter in order to eliminate the oscillation. I know that I can remove oscillations increasing Kd but in this case it does not work.

Results of real time system

Control temperature with constant PID:

enter image description here

Control temperature using PID1 during rise time (blue color) and when temperature reach the target, the controller is changed to PID2 (Steady state error: black color):

void setTarget(...)
{
    mPid = pid1;
}

void steadyStateError()
{
    float e =  fabs( temperature - target);
    if(e<=0)
       mPID = pid2;
}

enter image description here

$\endgroup$
  • 1
    $\begingroup$ How would you handle the transition? $\endgroup$ – A_A Jul 2 at 16:26
  • 1
    $\begingroup$ If implemented correctly I think this would be equivalent to gain scheduling (this can also be used on linear systems to improve performance). $\endgroup$ – fibonatic Jul 2 at 17:19
  • $\begingroup$ @A_A the question was updated. $\endgroup$ – sergio campo Jul 3 at 10:35
  • $\begingroup$ @fibonatic could you please recommend me some article or book that show me how to implement correctly this implementation in real time? $\endgroup$ – sergio campo Jul 3 at 10:41
  • $\begingroup$ If you're trying to control temperature, your biggest problem is usually wind-up. $\endgroup$ – Ben Jul 3 at 23:32
1
$\begingroup$

Switching between 2 PID controller is called gain-scheduling. There are various ways to implement gain scheduling. But basically, the idea is that the gain should change smoothly. You should not change suddenly. You could have one set of gains if T < T1, another set if T > T2 and use interpolation between the 2 sets if T1 < T < T2.

You can also use 2 PID controller with the unused PID set in tracking mode while the other controls the actuator also. However, it will be harder to have a smooth transition between the 2 controllers.

Secondly, before implementing gain scheduling, make sure your issue is really due to non-optimal gains. Typically, there are 2 problems with control loop for temperatures

1 - Actuator saturation which causes integrator windup. This happens often in temperature control when the difference between the setpoint and the measured temperature is significant. This can be fixed with an appropriate anti-windup scheme.

2 - Asymetry between heating and cooling. Typically, if you have a heater, you can only "heat" you cannot cool your system. This makes the choice of gain a bit tricky as the cooldown rate is not controllable by your controller. If you have some kind of Peltier cooler, you can both cool down and heat up, but the cooling rate is usually slower.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.