PID temperature control algorithm

This page contains information regarding the PID control algorithm.

The parameters P (proportional band), I (integration) and D (differentiation) will be explained.

Also an advice will be given on how to correctly adjust these P, I and D parameters for a proper control response.

PID control can be considered as the intelligence or “brain” of the controller. The same is when you are driving a car on the highway and wish to control the speed at 100 km/hr.

Because of varying road conditions (different tarmac, driving up- or downhill) it is necessary to increase and decrease throttle to hold the desired speed. You will also notice that your foot automatically does this.

Try to concentrate more on what you are actually doing, and you will notice that it is actually quite impressive on how the brain executes this apparently easy task. Your brain is now acting as some kind of very high level adaptive PID controller.

Quick page-shortcuts to:

A bit of history

In the past centuries, when automation became more and more important in industry, mathematicians and engineers tried to find a way to integrate the expert knowledge of an experienced human operator, that controlled a process manually, into an automated system.

Centrifugal governors were invented in the 17th century by Dutch scientist Christiaan Huygens.  They were used to regulate the distance and pressure between millstones in windmills.

James Watt applied the same technology to steam engines. He designed his first governor (or ‘centrifugal speed regulator’) in 1788, following a suggestion from his business partner Matthew Boulton. It was a conical pendulum governor and one of the final series of innovations Watt had employed for steam engines.

As engine speeds increased, the basic Watt-type governor became less reliable as it would tend to over-compensate, oscillating between opening and closing the steam valve and preventing the engine from running smoothly. This led to many modifications and variations over time, including the addition of a dead weight around the spindle, and the application of springs as part of the design.

A number of different firms of engineers patented their own variation on the concept, which they would apply to their own engines, and more modern governors were sometimes retrofitted to engines already in service.

millstone governor at Sluis in the Netherlands
A millstone governor at Sluis in the Netherlands
Boulton & Watt engine of 1788 with governor
Boulton & Watt engine of 1788

PID controllers date back to the 1890s centrifugal governor design for regulating pressure in steam engines.

steam engine speed governor.
The spring-loaded Whitehead governor, patented in 1895

Automatic ship steering

PID controllers were subsequently developed in automatic ship steering

  • One of the earliest examples of a PID-type controller was developed by Elmer Sperry in 1911
  • The first published theoretical analysis of a PID controller was by Russian American engineer Nicolas Minorsky in 1922 while he was designing automatic steering systems for the US Navy, based on analysis of helmsman observations.
  • Observing that the helmsman controlled the ship not only based on the current error, but also on past error and current rate of change. This was then made mathematical by Minorsky. His goal was stability, not general control, which significantly simplified the problem.
Human PID controller: the helmsman
Human PID controller: helmsman
  • While proportional control (=looking at deviation only) provides stability against small disturbances, it was insufficient for dealing with a steady disturbance, notably a stiff gale (due to droop), which required adding the integral term (=taking knowledge from the past into account). Finally, the derivative term was added to improve control. This was a refinement for correcting small short-lived deviations.
  • Trials were carried out on the USS New Mexico, with the controller controlling the angular velocity (not angle) of the rudder. PI control yielded sustained yaw (angular error) of ±2°, while adding D yielded yaw of ±1/6°, better than most helmsmen could achieve.
USS New Mexico (BB-40) in 1921

The U.S. Navy ultimately did not adopt the system, due to resistance by personnel. Similar work was carried out and published by several others in the 1930s.

Early automatic PID control: pneumatic

  • In 1930 Clesson E Mason of the Foxboro Company invented a wide-band pneumatic controller by combining the nozzle and flapper high-gain pneumatic amplifier, which had been invented in 1914, with negative feedback from the controller output.
  • This dramatically increased the linear range of operation of the nozzle and flapper amplifier, and integral control could also be added by the use of a precision bleed valve and a bellows generating the integral term. The result was the “Stabilog” controller which gave both proportional and integral functions using feedback bellows. The integral term was called Reset.
  • Later the derivative term was added by a further bellows and adjustable orifice.
Pneumatic PID (three term) controller
Pneumatic PID (three term) controller

First electronic PID controllers with tube amplifiers

Later on the first electronic analog PID controllers were made with tube-amplifiers.

One of the first companies were:

  • Swartwout in 1951 with its Autronic
  • RKC Instrument with its PV-1 temperature controller in 1952
Swartwout Autronic PID controller with tube amplifiers
Swartwout Autronic

First electronic PID controllers with solid state (transistor) technology

After the invention of the solid-state transistor in 1947 things were progressing into analog solid state technology PID controllers.

RKC Instrument was one of the first companies to develop these kind of controllers.

RKC Instrument RE-96 temperature controller with discrete electronics
discrete electronics in RKC Instument RE-96 temperature controller
RKC Instrument RE-96 temperature controller
RKC Instrument RE-96 temperature controller

First digital PID controllers with integrated circuit technology

later, with digital IC technology, the first truly digital controllers were invented that make very advanced adaptable PID controllers possible under quickly varying process conditions.

RKC Instrument was one of the first to introduce a truly digital PID controller with its REX-C1000 in 1982.

RKC Instrument REX-C1000 digital controller
RKC Instument REX-C1000 digital temperature controller
Digital operating panel RKC Instrument REX-C1000
Digital operating panel REX-C1000

Turn of the century: advanced very large scale IC (VLSI) digital circuit integration: more advanced controllers

As electronic integration advanced further and further, more powerful PID controllers were developed for the most demanding processes in the plastics and semiconductor industry.

See the RKC Instrument GZ series advanced PID controller with 100 PID calculations per second.

RKC Instrument GZ series advanced PID controller

From theory to practice: P, I and D parameters

In order to fully understand a PID controller, an extensive and thorough mathematical knowledge of Laplace and Z-domain transformations is necessary. That goes too far for this manual.

We therefore take a more practical approach and try to describe a PID controller in common language that almost everybody can understand.

To make things easier we will start out with a very simple on/off controller, think of the old thermostat that was used in the past to control the temperature in a room (the modern types used nowadays are almost all PID controlled).

ON/OFF control algorithm

ON/OFF temperature control is the simplest and least expensive form of control available. The output signal from a controller is either FULLY ON or FULLY OFF depending on the direction of the deviation between the set value and process value.

The figure below shows the characteristics of an ON/OFF control action:

The ON/OFF control action takes place if any deviation from the set value occurs.

This action responds quickly, but is sensitive to input noise which causes chattering (ON/OFF switching at short intervals). Therefore, in actual use,  the ON/OFF temperature control action has some hysteresis which is named dead band or control sensitivity. This prevents the quick chattering around the set value when the process value is very near.

Proportional action

P stands for proportional action and is a multiplication factor of the deviation between actual set value and process value.

Proportional action control is also referred to as P or gain in some control systems.

With the proportional action, the controlled process no longer switches as a direct result of the deviation between set value and process value but controls this proportional to the deviation.

The proportional action control is active within a user-definable zone around the set value, called the proportional band (Pb). When the process value (PV) enters the proportional band, the output becomes gradually smaller and the process value stabilizes somewhere within the proportional band.

With RKC Instrument temperature controllers you set the proportional band in degrees, but beware that there are other brands of systems that set this value in a percentage of the measurement span.

Proper adjustment of the proportional band will result in smooth control. However, it is very seldom, that the actual process value stabilizes exactly on the set value, and it usually becomes stable with some deviation from the set value, called offset.

A high P value gives the control system a large band of modulation, the major disadvantage is that the reaction to the deviation can be quite slow.

A too low P value, however gives an oscillating system where the process value continuously over- and undershoots the set value. We call that “hunting”, the controller hunts to reach the set value.

Visualize this by thinking of the gas pedal in a car (with automatic transmission): a high P value is a gas pedal where you can push it very far in so you can control in an accurate way, but need to push it far in and out to reach the speed that you want.

A low P value however is a gas pedal that has a very small travel, but controls the speed of the motor from idle to maximum rev with only a small push on the pedal. It is clear that this situation makes it also difficult to reach the speed you want: you over- and undershoot the speed all the time: more like a classic on/off control.

The “trick” is to reach the correct value where the oscillation is very low, but with a quick enough responsiveness to deviations. Large slow systems that react slowly to deviations generally need a higher P action than small quick systems.

With a control system that only uses a proportional band, there will always remain a small deviation (called: offset) between the process value (PV) and the set value (SV).

Proportional band temperature controller

Note: setting the P action to 0 will result in on/off control action. This will result in relatively large over- and undershoots.

Integral action

I stands for integral action. It takes a summation of the deviations between set value and process value from the past into account. This action is necessary for removing the small offset error that remains between set value and process value when only a P action would be used.

The integral control action is also referred to as reset. The degree of integral action is expressed as an integral time in seconds. The purpose of the integral action is to automatically compensate for any steady state offset that is inherent with a controller that only works with a proportional action.

The integral action moves or resets the proportional band up or down depending on the offset. The integral time of the controller is adjustable and determines how fast the proportional band is moved.

The integral action removes the offset between process value (PV) and setvalue (SV) that would remain when only a proportional action is used.

Integral action of a PI temperature controller

A too high setting of the integral action will result in a very slowly reacting process with big over- and undershoots.

A too low setting of the integral action will result in a control system that can never reach the set value exactly. There will remain a small offset error and the desired set value is not reached.

The trick here is also to reach the setting that more or less corresponds to the actual inertia of the system under control.

Now we go back to the speed control of our car with the gas pedal. When you push in the gas pedal fully it takes some time to rev up the engine and speed up. Also when you let go of the pedal it takes some time to let the engine rev down. This is mainly because of mechanical inertia inside the engine. The weight of the car itself is also very important: a big heavy truck takes much more time to speed up then a small compact car.

In a laboratory, on rollers, we determine the speed of the car as a function of the gas pedal position: this can now be considered as the P-action.

This situation does not correspond to a real road situation where you have wind and different kinds of tarmac.

To compensate for this the gas pedal needs to be pushed in a bit more (or less) depending on the situation. This last action can be considered as the integral action: it fine tunes the actual gas pedal setting, but in a very slow way, otherwise we overshoot the desired speed.

Differential action/derivative action

The D stands for differential (or sometimes called: derivative) action. This takes the rate of change per time unit of a deviation between set value and process value into account.

Differential action temperature control is also referred to as rate. The degree of differential action is expressed by the differential time in seconds.

The controller measures the rate of the temperature increase per time unit and moves the proportional band to minimize overshoot. The output change is directly proportional to the rate of change in the process value (PV) per time unit.

Theoretically speaking a heating process is a pure integrator and can be controlled by using only a P and I action (most slow processes are). Practice however shows that a small amount of D action can improve accuracy and especially responsiveness to changing external circumstances just a bit further.

A D-action is often used in positioning systems (servo applications) where quick movements are performed. A D-action is also important in a tunnel furnace where the product load differs from time to time (sometimes no product feed), here the D-action is used to prevent over- or undershoot under various process load conditions that change more quickly than the integral time of the process itself.

A too high D action will result in a very unstable process with large over- and undershoots.

A too low D action will result in a system that does not respond quick enough (too late) to varying process conditions. This will also result in an unstable system with over- and undershoots.

Cycle time

Another important setting in a PID controller is its cycle time. This time is the time span used by the controller to calculate how long a relay should be on or off. Remark: this setting is not used when the control output is an analog signal (i.e. 4-20mA).

Here is an example: we have a mechanical relay that is driving a heating element and the cycle time is set to 15 seconds. When the controller output is 100% the relay will be continuously activated. When the process value goes a bit over the set value the controller starts to react to this by modulating the controller output back to a lower value, e.g. 50%.

When the output is 50%, and the cycle time is 15 seconds, the relay will be on for 7.5 seconds, then switch off for 7.5 seconds, switch back on for 7.5 seconds, etc. etc. etc.

When the controller output is only 10% the relay will be switched on for 0.1 x 15 = 1.5 seconds and then remain off for 15 – 1.5 = 13.5 seconds.

The problem is that we introduce some kind of lag time into the system.  Of course it would be a good idea to set this cycle time as low as possible, because then the controller can react more quickly to varying process conditions. The major disadvantage is then, that the mechanical relay has to switch very quickly on and off. This will damage the contacts of the mechanical relay too quickly and wear them out too fast.

As a compromise the cycle time has been set to 15 seconds for this purpose.

When you make use of thyristor modules or solid state relays the cycle time can be set at the lowest possible value (0.1s) since these modules don’t have mechanical contacts. The controller output can directly drive the modules proportionally which will result in a quick response to varying process conditions and a more stable and accurate process control.

P, I and D parameters & cycle time explained with car speed control

In the parts above the separate P, I and D parameters as well as the cycle time are explained with examples in car speed control. Lets discuss them again.

Remark: this example is only valid for a car with automatic gear control, so not for manually gearshift cars.

Proportional

The actual difference between the desired car speed and the actual speed (viewed from speedometer) results in your foot pushing on the gas pedal. This is the correction for the error: setvalue (SV) – process value (PV). The more difference: the deeper you push the pedal, so you push in the pedal proportional to the error between SV and PV. This can be compared to the proportional factor in a PID controller.

Integral

After a while you see that you almost reached the desired speed of 80 kph but it is still 75 kph, a slight error still is present between the desired and actual speed. You slowly push the pedal a little bit further to reach the desired speed. The engine of the car needs to rev up before the speed will actually increase. This reaction time can be compared to the integral time of a PID controller.

Differential/Derivative

When you are driving the car sometimes you need to go up a hill and push the pedal in just a little bit further for only a short time to remain at the desired speed. This type of short-lived difference between the actual and desired speed, so actually the rate of change of the speed error, can be compared to the differential time of a PID controller.

PID parameters in car speed control
Cycle time

While you are driving a car you cannot continuously view at the speedometer because you need to watch the road for safety.

Only now and then, lets say every 10 seconds, you briefly view the speedometer and correct the gas pedal with your foot to remain at the desired speed. This only now and then looking at the speedometer can be compared to the cycle time of a PID controller.

Combining P, I and D into a control output for the process

The picture above shows the PID controller in a graphical form. A desired new control output u(t), also called manipulated value (MV), is sent to the process under control. 

The process is fitted with a sensor (i.e. a temperature sensor) y(t). This is also called the process value (PV).

The desired setpoint for the process: r(t) is also called setvalue (SV).

The difference between setvalue (SV), r(t) and the process value (PV) y(t) is calculated into e(t): the error. So e(t)=r(t)-y(t).
This is the error, or deviation, between the setvalue (SV) and the process value (PV).

Now a new output percentage u(t) will be calculated from this error. There are 3 parts that are used for this calculation:

  • Proportional action: the error is multiplicated by the proportional band (Pb), also called Kp. 
  • Integral action: the new calculated error e(t) is summated to the the previously summated errors, multiplicated by the integral time, also called Ki.
  • Differential action: the change of error e(t) over a short time interval is multiplied by the differential time, also called Kd.

These 3 parts are now combined into a new control percentage for driving the process. 

Please note, that setting one of the P, I or D parameters to 0, results in disabling that part of the calculation. For some heating processes you could use only the P and I parameters for example.

Tuning of PID settings: work step-by-step and write down what you change

When you adjust a PID controller by hand, a lot of experience and, as the Germans say: “fingerspitzen gefuehl” is necessary. We consider this manual adjustment procedure more like an art than a science.

Better measurement leads to better control

It is always very important, that a sensor in process gives a fast and representative signal that corresponds accurately to the actual state of the process. Here some important advice:

  • do not use sensors with too much mass or that are too thick, this will result in too slow reaction to process variations.
  • install the position of the sensor in the most important and representative position of the process. Remember that heat will always go up. 2/3 from the bottom is a good compromise in many cases. Never install sensors in a bend of a tube because of possible over/underpressures.
  • when tuning an empty oven: it is very difficult to measure “air” since it is an insulator. Install a proper and representative (dummy load) mass inside the kiln that must be tuned. Otherwise tuning is impossible.

General rule of thumb: the better, faster and more accurate you measure the actual conditions of the process, the better the PID controller can be tuned and the quicker the reaction of the process will be. So, always try to improve the measurement of the process, that is often the best way to improve process conditions.

Tuning the process by hand

It is very important that you have a graphic real-time overview of the process values so you can see if your modifications give improvements (or not, then you need to move in the other direction). For this, registration equipment is used, like temperature recorders.

  • It is always best to first start by setting the I and D factors to 0 and only use the P-action.
  • When you roughly “feel” how the process reacts to a step like change of the set value, you can try the addition of the I action to get the process value exactly on the set value.
  • Later on you add the D action to improve responsiveness to sudden short process disturbances.

After that, you start changing the P, I or D values one by one. Try doubling them, or halving them, and see how the process reacts to it. This procedure must be re-done until you are satisfied with the new settings.

When you see a process value that is slowly oscillating with a small amplitude and long period towards the desired set value you are on the right track with these settings.

We know from practice that the D action should be roughly 25% of the I action. Certainly not more.

Auto tuning

It is also possible to make use of the auto tuning (AT) feature in RKC Instrument temperature controllers.

This is only possible when the controller is in a soak/dwell segment and the set value does not change over time. So the process must be in a kind of stable state and not ramping up or down.

After enabling the autotuning (AT) feature the controller will perform a few test-cycles where it automatically tries to determine the PID settings based on so-called step-wise changes of the set value.

After changing the controller output (MV) to maximum (or minimum), the controller monitors the physical behavior of the process value (PV) and determines the settings based on oscillation amplitude and period.

After performing many tests with various control systems, Ziegler and Nichols, derived around 1942 formulas on how to convert the results of these tests into PID settings as a starting-point before actual fine tuning can take place. This is documented in their paper from 1942: “Optimum Settings for Automatic Controllers”.  The RKC Instrument temperature controller will calculate the new P, I and D settings automatically for you.

It sometimes takes a while before the system actually determines the new values during this auto tuning cycle. Please be patient and wait until you see the newly determined values appear. This can take some minutes and depends on how quickly the process reacts to the controller.

If the controller was not able to determine the new values it will leave the PID settings on the values before the start of the auto tuning procedure.

Important warning: the autotuning procedure will set the controller output (MV) a few times for a certain time to either 100.0% or 0.0% and during that it observes the process value (PV) change. Be sure that your process is not damaged if it is set for longer times to either 100.0% or 0.0%. In the engineering parameters it is possible to limit these maximum/minimum control percentages).

Watch out: these calculated PID values are only a rough indication of the actual perfect PID settings and –can- result in an unstable process, so keep in mind that manual finetuning is often necessary after performing an autotune operation.

Important: only perform auto tuning when the process reached a stable state (controller output MV and process value PV more or less stable). The set value SV must also be stable, so this is only possible in a soak segment and not in a ramp up/down segment.

Warning: Never execute an auto tuning procedure when the process conditions are not stable. The software algorithm assumes that all external factors with regard to the process are not changing while performing this operation.

Please remember, that a manually tuned controller almost always outperforms a controller that was set with auto tuning. Auto tuning is more or less a rough indication if you need some “direction” on where to start for a manual tuning.

Write down the newly determined PID values!

It is very important, that you write down the newly determined PID values so you don’t lose these painstakingly difficult to determine values.

A software upgrade, re-init procedure or controller module re-init (necessary after a replacement) will restore the PID values back to their default values as programmed in the software.

So write the determined PID values down and store them somewhere near the controller in case of replacements are needed in the future.

Common pitfalls

  • A system that is oscillating around its set value, or reacting too slow to process variations, is almost always caused by a PID controller that needs fine-tuning.
  • Beware when it takes many minutes of time for a process value to change after step-wise change of the set value. This is caused by a so-called dead-time in the process and is very difficult to overcome with PID settings in 1 PID loop alone. The most common solutions for these kind of process issues are:
    • Measure more directly the actual product process value (bring sensor nearer to product).
    • Make use of a so-called cascaded control system where we make use of a master-slave PID loop where the slave loop controls the heating to the process (with its separate sensor near the heater as process value input). The set value for the slave comes from output of the master PID controller that measures the actual desired process value of the product.
Cascaded PID temperature control system with master and slave controller
Cascaded control system with master and slave controller
  • When you change a P-action, you also influence the I and D action responses in some kind of way.
  • The same goes when you change the I or D action, everything is connected together more or less. Don’t start to move down in spiraling circles and change only 1 parameter at a time and verify very well if this improves the situation or not.

A good idea is to always write down carefully what you are doing, so you begin to see a “pattern” in your workflow and take a few steps back, if desired.

  • Don’t set the D action too high, since this very easily results in an unstable process control. Use the D only for fine tuning after you set the P and I factors correctly.
  • When you change an action you need to wait for the process to respond to the new situation. This can take many minutes and depends on the inertia of the process. Watch the recorder output of the process value to determine if it stabilizes or not.

Generally speaking it is important to keep the ratio between heating power versus mass of the system the same, after determining the correct PID settings for your system. You can then use the same settings for different situations.

More information?

If you need more information on temperature controllers, click on the link below.

PID temperature controllers

Sources