if (actualTemperature < wishedTemperature) ... activate relay pin to rise temperature...if(actualTemperature > wishedTemperature) ... activate relay pin to lower temperature...
For me PID control is quite interesting and have heard many times. But the technique is too complicated, so I'm not able to learn and apply for even in a simple app. Can anyone describe a short overview of PID control? Does the technique really use in many fields?
In an ideal world PID output should be an 'analogue' rather than a simple binary condition. Because the controller does not output analogue you can use PWM as a pseudo-analogue. However PWM cannot be effectively implemented using a simple driver relay since the relay would be chattering constantly. You can however use an SSR which will quite happily operate with PWM. Alternatively, rather than 'normal' PWM you could use "burst mode" on the output which is effectively a very low frequency form of PWM. In this case ON for so many seconds, then OFF for so many seconds, depending on heat demand. This method is frequently used in mains type heating systems.Note also that PID control requires an analogue input sensor, rather than a simple digital switched input since you need to sense both the value of offset and rate of change of offset
PID is easy to understand. The hard part is tuning the constants.Your "burst mode" is not a low-frequency form of PWM, it is PWM. There is literally no theoretical difference at all whether the frequency is 50 kHz or 50 mHz.My previous job had big thermal chambers that used PID controllers to modulate the temperature inside them according to a specific thermal profile, example:1) ramp to 85C in 10 minutes2) Hold for 1 hour3) Ramp to -40C in 30 minutes4) hold for 1 hour5) Ramp to 25C in 20 minutes Repeat 100 timesThe multi-kilowatt heaters and cooling compressors were controlled by relays with a PWM period of about 10 or 15 seconds. The time constant for most things in Newton's Law of Cooling is YUUUGE!!, probably many many minutes long for a good pot of water. A PWM cycle lasting several seconds should be more than good enough for controlling temperature on most things with a large thermal mass.
Sorry to disappoint, but burst mode definitely isn't PWM. You are not Modulating the Width of a Pulse, you are controlling On and Off times of a power feed. In PWM you generally have a fixed frequency drive and you then control the On period within each and every cycle, whilst in burst mode you switch On for several (or many) cycles and then switch Off for several (or many) cycles - quite different from PWM. That's why I described it as a "form" of PWM, I was using a metaphor to explain the difference to someone who is learning about temperature control via PID.
you are controlling On and Off times of a power feed
the thing is how to obtain the constants (kp, ki, kd),