Electronic – Temperature stabilization with PWM , PID controller with delay system

optimizationpid controllerprogrammingpwmtemperature

I am doing a project to control the temperature with PWM. I use peltier, thermistor,mcu and h-bridge mosfet.

I want to reach a temperature with an error less than 0.05 and stay at that temperature without much (at most 0.05 C) oscillation. My first aim is to reach that temperatures in room temperature (no other effects than room temperature). Lets consider cooling mechanism, in room temperature, for example 14'C requires .285 PWM (out of 1) ,13'C requires .330PWM, and 20'C requires .180PWM. There is no linearity between them, and also changing PWM does not provide linear current change, ex: 1.0 PWM provides 2.15A, 0.5PWM provides 0.6A, and 0.2 PWM provides 0.16A across the peltier in room temperature.
My first cooling algoritm:Initially constant=0 Keep PWM 1.0 until temperature is close to set temperature (t_set) by 2, then lowering the PWM with, PWM=constant+ (temperature-t_set)/2, after temperature is set to a temperature constant=PWM, and then PWM=constant+ (temperature-t_set)/5 and so on. And the system reaches steady temperature after 10-15 seconds after the PWM is changed, when PWM change >0.1

First question: How the mcu can can learn the PWM value that keeps the temperature constant? ( ex: 13'C requires .330PWM)

Second question: Is it possible to use PID algorithm to stabilize PWM value at set temperature without knowing the constants at first question?

Third question: If I find a good way that mcu to learn PWM values to keep temperature constant at different environments, and If I use good PID coefficients, do the PWM coefficients works for any environment, or are the PWM coefficients environment specific, ie: heat sink medium and differnt temperatures.

Thanks in advance.

–After 6 hours, from the answers

Q1- Learning that coefficient (I think) requires some algorithm when there is no PID.

Q2-Yes, with good PID coefficients it perfectly stabilizes, error term will be 0 and the only integrator term keeps the system stable, in noiseless environment.

Q3- If good PID coefficients are used and with educated (??) guess some level of stabilization can be accomplished.

To achieve good results in different environments (I think) it is needed to develop a auto tuning PID. My design criteria are keeping the temperature error minumum and keeping the reaching time for stabilization low (if possible).

From the result if it is approprite to ask here
my fourth question is: Q4: Which methods do you suggest me to find Ki, Kp and Kd coefficients in different environments (auto tuning PID coefficients when the mcu starts or restarts).

Best Answer

Q1: The controller will find the PWM value to keep the temperature at the setpoint if the PID is reasonably well tuned. If it not tuned well, it may oscillate around the setpoint or be very sluggish in approaching the setpoint, and also slow to respond to demand changes (such as a change in ambient temperature).

Q2: Yes, if you make an educated guess as to the values it is possible to get stable control with a try or two. Or use a self-tuning algorithm. And/or a manual method such as Ziegler-Nichols.

Q3: They will work reasonably well for some range where things stay more-or-less linear. If you triple the wattage of the Peltier, for example, you'll probably get a lot of overshoot. In most applications (not all) the tuning parameters are fixed numbers for a given range of setpoints (perhaps all valid setpoints).

It's not always possible to get the control you need with a single control loop, sometimes nested loops are required. I've gotten control down to the \$\mu K/\sqrt {Hz}\$ level but it's not easy. Your 0.05°C may be difficult or not so bad, depending on what the system looks like.