Electronic – How to implement a self tuning PID-like Controller

control systemconvolutionmicrocontrollerpid controller

I am trying to write a micro-controller program for controlling temperature in a system with the following characteristics:

  • output can only be On or Off, with fixed cycle frequencies (~2-10 per hour)
  • The plant is slow to respond (measurable changes in temperature take a long time > 10 minutes).
  • The plant loses temperature based on environmental conditions.
  • the set-point can vary in large steps based on user demand.

I am writing a controller that aims to minimize error, as well as adhering to the cycle-rate provided as an input.

This could easily be done with a PI controller and it's output converted to the duty-cycle. The problem is that the program needs to auto-tune and choose correct Kp, Ki constants and adapt to varying environmental conditions and changes in heating capacity. Therefore, tuning the PI controller in advance is not too useful.

Using an actual PI or PID is not a requirement. I'm open to use of Fuzzy-Logic if it helps, also have a machine-learning algorithm on the chip that models the system response and heat-loss (linear approx.) which suggests information about measured step response. Just don't know what to do with that information.

A couple of posts suggest I could use the modelling data to tune the PI on-line, as well the lab-view manual that suggests I could use Fuzzy-Logic to tune the PI.

My question is, what is the best approach for this kind of scenario (e.g. PID, fuzzy-pid, convolution, etc) and how would I go about actually implementing it in software/practice.

I'm not a EE so any input would be greatly appreciated.

Best Answer

I wouldn't go so far as to call PID outdated. But there certainly is room for improvement. One way in which I have auto-tuned PID control loops is to use the Nelder-Mead method which is a form of hill climbing simplex algorithm. It has the benefit of being able to converge and reconverge on a target parameter that moves over time.

Nelder-Mead method hill climbing

From this paper:

For example in our case of PID parameters tuning {KP, KI, KD} a simplex is tetrahedron. Nelder–Mead generates a new test position of simplex by extrapolating the behavior of the objective function measured at each test point arranged as the simplex. The algorithm then chooses to replace one of these test points with the new test point and so the technique progresses.

My particular application was for motor control. We had two loops, a PID current control loop and a PI velocity control loop. We set our vertices to P, I, and D respectively and ran statistics on the output of the loop. We then ran the reflection, expansion, contraction, and reduction over and over again until the current or velocity control targets generated were within a few standard deviations.

With our product, the VP was very concerned with how the motor "sounded". And as it turned out, it "sounded" better when the current target bounced a bit more than was mathematically optimal. So, our tuning was done "live" in that we let the algorithm seek while the motor was running so that user's perception of the motor sound was also taken into account. After we found parameters that we liked, they were hard-coded and not changed.

This probably would not be ideal for you since you state, "putting the system in oscillation even as a part of auto-tuning is not acceptable to the users". Our system would most certainly oscillate and do other horrible things while it was auto-tuning.

However, you could run two copies of the PID controller. One that was "live" and actually controlling the process. And a second that was constantly being auto-tuned while being fed the same inputs as the "live" controller. When the output of the auto-tuned controller became "better" or more stable, you could swap the coefficients into the "live" controller. The controller would then perform corrections to the process until the desired performance was achieved. This would prevent oscillations that can be perceived by the user during auto-tuning. But if the inputs change drastically and the PID controller is no longer optimal, the auto-tuning can swap in new coefficients as they become available.