PID regulators of heat load. All about pid-regulators

In systems with this control method, because of the presence of hysteresis and the limited control signal, the actual value of the parameter will always oscillate periodically with respect to a given value, that is, a mismatch will always be observed. The accuracy of the control can be increased somewhat by reducing the switching hysteresis, but this leads to an increase in the switching frequency of the output relay and a decrease in its life cycle. Thus, regulators of this type are not suitable for tasks where the control parameter is characterized by high dynamics and where it is required to maintain the value of the regulated parameter precisely. Possible application of limit regulators are objects with large inertia and low requirements to the accuracy of regulation.

PID control

Significantly improve the accuracy of regulation can be the application of the PID-Law (Proportional-Integral-Differential Regulation Law).
   For the implementation of the PID-Law, three main variables are used:
  P - zone of proportionality,%;
  I is the integration time, s;
  D is the time of differentiation, s.
   Manual tuning of the PID controller (determining the values ​​of the parameters P, I, D), which provides the required quality of regulation, is rather complicated and is rarely used in practice. PID controllers of the UT / UP series provide automatic adjustment of PID parameters for a specific control process, while retaining the possibility of manual adjustment.

Proportional component
   In the zone of proportionality determined by the coefficient P, the control signal will vary in proportion to the difference between the setpoint and the actual value of the parameter (mismatch):

control signal = 100 / P E,

where E is the discrepancy.
   The coefficient of proportionality (gain) K is the inverse of P:

The proportional band is defined with respect to the set control setpoint, and within this zone the control signal changes from 0 to 100%, i.e. when the actual value and the set point are equal, the output signal will have a value of 50%.

where P is the zone of proportionality;
   ST - control set point.
For example:
  measuring range 0 ... 1000 ° C;
  control setpoint ST = 500 ° C;
  zone of proportionality P = 5%, which is 50 ° C (5% of 1000 ° C);
at a temperature of 475 ° C and below, the control signal will be 100%; at 525 ° C and above - 0%. In the range 475 ... 525 ° С (in the proportional band), the control signal will vary in proportion to the magnitude of the error with the gain K = 100 / Р = 20.
   Decreasing the value of the proportional band P increases the controller's response to the error, ie, a larger value of the control signal will correspond to a small discrepancy. But at the same time, due to the high gain, the process takes an oscillatory character near the value of the setpoint, and precise regulation can not be achieved. If the proportional band becomes too large, the controller will react too slowly to the resulting mismatch and will not be able to keep track of the dynamics of the process. In order to compensate for these shortcomings of proportional regulation, an additional time characteristic is introduced-the integral component.

Integral component
   It is determined by the integration time constant I, is a function of time and provides a change in the gain (shift of the proportional band) for a given time interval.

control signal = 100 / P E + 1 / I ∫ E dt.

As can be seen from the figure, if the proportional component of the control law does not ensure a reduction in the error, then the integral component begins to increase the gain gradually over a period of time t. After a period of time t this process is repeated. If the discrepancy is small (or decreases rapidly), then the gain does not increase and, if the parameter value is equal to the setpoint, a minimum value is assumed. In this regard, the integral component is spoken of as a function of automatic regulation shutdown. In the case of PID control, the transient response of the process will be oscillations gradually attenuating to the set point.

Differential component
Many control objects are inertial enough, i.e., have a delay in response to the applied action (dead time) and continue to react after removal of the control action (delay time). PID controllers on such objects will always be delayed with the control signal on / off. To eliminate this effect, a differential component is introduced, determined by the time constant of differentiation D, and a complete implementation of the PID control law is provided. The differential component is the time derivative of the error, that is, it is a function of the rate of change of the control parameter. In the event that the mismatch becomes a constant, the differential component ceases to affect the control signal.

control signal. = 100 / P E + 1 / I ≤ E dt + D d / dt E.

With the introduction of the differential component, the controller starts taking into account the dead time and the delay time, changing the control signal beforehand. This makes it possible to significantly reduce the process fluctuations near the setpoint value and to achieve a faster completion of the transient process.
   Thus, PID regulators, generating a control signal, take into account the characteristics of the control object itself, i.e. analyze the mismatch by the magnitude, duration and rate of change. In other words, the PID controller "anticipates" the response of the control object to the control signal and begins to change the control action not in advance of the setpoint value, but in advance.

Significantly improve the accuracy of regulation can be the application of the PID-Law (Proportional-Integral-Differential Regulation Law).
  For the implementation of the PID-Law, three main variables are used:
  P - zone of proportionality,%;
  I is the integration time, s;
  D is the time of differentiation, s.
  Manual tuning of the PID controller (determining the values ​​of the parameters P, I, D), which provides the required quality of regulation, is rather complicated and is rarely used in practice. PID controllers of the UT / UP series provide automatic adjustment of PID parameters for a specific control process, while retaining the possibility of manual adjustment.

Proportional component
  In the zone of proportionality determined by the coefficient P, the control signal will vary in proportion to the difference between the setpoint and the actual value of the parameter (mismatch):

control signal = 100 / P E,

where E is the discrepancy.
  The coefficient of proportionality (gain) K is the inverse of P:

The proportional band is defined with respect to the set control setpoint, and within this zone the control signal changes from 0 to 100%, i.e. when the actual value and the set point are equal, the output signal will have a value of 50%.

where P is the zone of proportionality;
  ST - control set point.
For example:
  measuring range 0 ... 1000 ° C;
  control setpoint ST = 500 ° C;
  zone of proportionality P = 5%, which is 50 ° C (5% of 1000 ° C);
at a temperature of 475 ° C and below, the control signal will be 100%; at 525 ° C and above - 0%. In the range 475 ... 525 ° С (in the proportional band), the control signal will vary in proportion to the magnitude of the error with the gain K = 100 / Р = 20.
Decreasing the value of the proportional band P increases the controller's response to the error, ie, a larger value of the control signal will correspond to a small discrepancy. But at the same time, due to the high gain, the process takes an oscillatory character near the value of the setpoint, and precise regulation can not be achieved. If the proportional band becomes too large, the controller will react too slowly to the resulting mismatch and will not be able to keep track of the dynamics of the process. In order to compensate for these shortcomings of proportional regulation, an additional time characteristic is introduced-the integral component.

Integral component
  It is determined by the integration time constant I, is a function of time and provides a change in the gain (shift of the proportional band) for a given time interval.


control signal = 100 / P E + 1 / I ∫ E dt.

As can be seen from the figure, if the proportional component of the control law does not ensure a reduction in the error, then the integral component begins to increase the gain gradually over a period of time t. After a period of time t this process is repeated. If the discrepancy is small (or decreases rapidly), then the gain does not increase and, if the parameter value is equal to the setpoint, a minimum value is assumed. In this regard, the integral component is spoken of as a function of automatic regulation shutdown. In the case of PID control, the transient response of the process will be oscillations gradually attenuating to the set point.

Differential component
  Many control objects are inertial enough, i.e., have a delay in response to the applied action (dead time) and continue to react after removal of the control action (delay time). PID controllers on such objects will always be delayed with the control signal on / off. To eliminate this effect, a differential component is introduced, determined by the time constant of differentiation D, and a complete implementation of the PID control law is provided. The differential component is the time derivative of the error, that is, it is a function of the rate of change of the control parameter. In the event that the mismatch becomes a constant, the differential component ceases to affect the control signal.

control signal. = 100 / P E + 1 / I ≤ E dt + D d / dt E.

With the introduction of the differential component, the controller starts taking into account the dead time and the delay time, changing the control signal beforehand. This makes it possible to significantly reduce the process fluctuations near the setpoint value and to achieve a faster completion of the transient process.
  Thus, PID regulators, generating a control signal, take into account the characteristics of the control object itself, i.e. analyze the mismatch by the magnitude, duration and rate of change. In other words, the PID controller "anticipates" the response of the control object to the control signal and begins to change the control action not in advance of the setpoint value, but in advance.

5. The transfer function of which link is represented by: K (p) = K / Tp

When creating various automation devices, it is often necessary to provide a given speed of rotation of the motor shaft, independent of the current load.

It is not difficult to see that the speed of rotation of the motor shaft depends not only on the voltage on the motor, but also on the external unknown effects on the motor, such as variable frictional force, changing load, temperature, lubrication quality, and other factors. Therefore, the task of providing a given speed of rotation of the motor shaft is reduced to the task of forming such a voltage on the motor that would ensure a given engine speed independent of the influence of external random factors.

The solution of this problem without the theory of automatic control is impossible. The solution of the problem consists in calculating and realizing Speed ​​PID controller. Specialists of "Din-Soft" have experience in solving similar problems.


The PID controller provides a predetermined speed on the actuator (motor) independent of the constant or slowly varying load acting on it.


PID controller is a proportional-intergal-differential controller. The PID controller consists, respectively, of the proportional ( To n ), integral ( K and / s ) and differential ( K d s ) link, each of them has its own gain factor (Figure 1).

Fig. 1. Structural diagram of a control system with a PID controller.

Here: s   Laplace operator (sometimes it is denoted as p ). If one abstracts from the Laplace transforms, then the records K n, K and / s and K d s should be taken only as a designation of the corresponding link, and not as a mathematical expression. And certainly not worth looking for value s , because, as already mentioned, this is an operator, not a variable.


In a system with a PID controller, the actual speed V (t)engine is measured by   sensor.

On the input of the system  the set speed value V back(t)in the same units as the real speed.

Feedback feedback  subtracts from the speed reference signal V backside (t)real-time signal V (t)  and generates an error signal e (t) at the output:

An error signal is sent to proportional, integral  and differential  PID regulator links.

Proportional link  multiplies the error signal e by a factor K n  and generates an output signal y n.

Integral link  integrates the signal e (t) in time, multiplies by a factor K and  and generates an output signal y and.

Differential link  produces differentiation of the time error signal e (t), multiplying the result by the number K d  and generating an output signal y d.


PID Adder Totalizer  summarizes signals y n(t), y and(t)and y d(t) and generates an output signal y (t):

PWM and power switch  are designed to transmit to the engine the calculated output signal y (t).

Calculation of the PID regulator coefficients

It is not difficult to see that the PID controller is characterized by three coefficients K n, K and  and K d. To calculate these coefficients, it is necessary to know the parameters of the control object, in this case the motor.


Structure and parameters of the control object

From the point of view of the theory of automatic control, the DC motor is approximately described: by two aperiodic links with an electrical time constant T E  and the mechanical time constant T m. Total engine gain K two  (Figure 2). In fact, the structural diagram of the engine is much more complicated, but this is not so important in this case.





Fig. 2. Structural diagram of the engine from the point of view of the theory of automatic control.

Transfer function of the motor, written in terms of the Laplace operator s, the following:

Gain of the engineK two   determines the proportionality between the rotational speed of the engine shaft at idle and the input voltage applied to the input. Simply put, the ratio is equal to the ratio of idle speed V xx  and rated motor voltage U n.

The voltage on the motor in microprocessor technology is given in conventional voltage units, and the speed is removed in conventional speed units.

If a 7-bit PWM is used to generate a voltage on the motor (see below), then K two  the value of the rated voltage is 128 arbitrary voltage units.

No-load speed w xx, specified in the engine's passport data, should be re-read to the conventional speed units V  xx, determined by the way the speed sensor is implemented.


For example, let an incremental sensor located on the motor shaft be used to measure speed, and having 512 marks per revolution. Let the velocity in conventional units be measured as the number of labels per cycle of calculation D t. Let the calculation cycle obtained by evaluating the performance of the algorithm be 0.001 seconds. Let the engine idle speed w xx= 5000 rpm.

Let's turn the engine speed into the sensor marks, we get: 5000x512 = 2560000 marks / min. Let's translate minutes into the calculation cycles:

If the engine parameters are unknown, the idle speed is determined experimentally. For this purpose, the maximum voltage is applied to the engine at idle speed and the readings from the speed sensor V xx.


Mechanical time constant T m depends on the moment of inertia of the motor shaft, reducer, inertia of the actuator. To calculate its value in an analytical way is usually not possible. Therefore, it is measured experimentally.

For this purpose, the motor with its rated load is jerked with a maximum voltage and a transient change in the speed V (t).


Speed ​​is removed from the speed sensor at discrete times, it is recorded in the RAM of the microprocessor and then transmitted to the personal computer. The personal computer restores the schedule of change of speed V (t)(Figure 3).




Fig. 3. Transient process in the DC motor.

According to the schedule of the transient process, it is possible to determine, first, the idle speed V xx, and secondly, the regulation time t p. The control time is determined by the end time of the transient process (the time when the transient curve is less than 1% of the steady-state value).


If we neglect the small influence of the electric time constant T E, usually an order of magnitude smaller than the mechanical time constant T m, then the transient process in the DC motor can be considered aperiodic with a constant T m.


It is known that the time of the aperiodic transient is five times longer than its time constant. Those.:

Hence for our case we obtain:

In our case, the regulation time t p, judging by the schedule, is 1.5 seconds. Then the mechanical time constant T m  = 1.5 / 5 = 0.3 seconds.

Thus, by plotting the transition process, we find the mechanical time constant T m.


Electrical Time ConstantT E   determines the inertia of the magnetization of the motor armature and is equal to the ratio of the inductance of the motor armature to the resistance of its winding:

In practice, the inductance parameters of the armature are difficult to measure, and then the electric time constant is an order of magnitude smaller than the mechanical time constant:

For most engines, this is true.

Calculation of the PID regulator coefficients.

In order to calculate the PID regulator coefficients, it is necessary to solve the inverse problem of dynamics. For this we abstract from the PID regulator. We will assume that the structure of the regulator, i.e. its transfer function W r(s), is unknown to us. For then the transfer function of the control object is known W  dv(s)(Figure 4).


Fig. 4. The initial scheme for calculating the regulator for a DC motor.

Let us write the transfer function of a closed system W з ((s):


Let's define, what transient process in system would arrange us? We are quite satisfied with an aperiodic transient process in the system. This is how the system should react to changes in speed and load.

Let the desired time constant of the transient process T f  will be approximately equal to T m. Those. transfer function of the desired system W f(s) is equal to:

We equate the transfer function of the closed system to the transfer function of the desired system:

By simple mathematical transformations, we express here the expression for the transfer function of the regulator W r(s):

We substitute value W dv(s):




We introduce the coefficients:

We get:

It's not hard to see that we just got a coefficient C  1, the coefficient before the integral link FROM  2 and the coefficient before the differentiating link C  3. Those. we obtained the classical structure of a PID controller with parameters K n=FROM 1 , K and=C  2 and K d=C 3 :

Implementation of the PID controller on a digital microprocessor

Systems with PID controllers are currently implemented only digital, and the calculation of control laws is carried out by cheap microprocessors of the AVR or MCS -51 series. Note that microprocessors are integer and do not support floating-point operations. This requires the programmer to adapt the algorithms accordingly.


In a system with a PID controller, the motor speed is measured with a sensor. The real speed is measured in integral conditional velocity units. Usually the conventional velocity units are selected in such a way that the speed in cu changed in the range from -127 to 127 (one byte), at the extreme from -15 to 15 (the speed is taken with a margin). But in any case, the number of speed discrepancies should not be less than the required number of speeds.


The speed can be measured by the following sensors:

The input of the system receives a given speed  in the same conventional units as the real speed. The specified speed is usually transmitted from the top-level control processor or personal computer, and stored in the corresponding microprocessor memory cells.


Feedback feedback  subtracts from the given speed V back  actual speed V  and receives, so-called, an error signal e:

Given that the speed V back  and Vare integers in the range of -127 to 127, on an integer microprocessor this operation is realized quite simply. Care should be taken to ensure that the result. If e<-127 , то e =127, а если e >12 7, then e = 127.


Error signal eenters the PID controller input, i.e. on a proportional link, integral and differential.


Proportional link  generates an output signal y n by multiplying the instantaneous error signal by a factor K n.

Coefficient K n  usually represents a non-integer value in the range from 0.5 to 2. Therefore, to multiply an integer one-byte number ethis coefficient is used by the table K P,  i, which is calculated in advance:

   for i =-127...127

Moreover, the numbers in the table take into account the restriction on the result, which should also be one-byte, not exceeding the value 127. That is, if the multiplication result is greater than 127, then take it equal to 127, and if less than -127, then take it equal to -127 .

Programmers should understand that the processor considers a signed number ias an unsigned index of the table, so the elements of the table with indexes from -128 to -1 will actually be in the range of indexes from 128 to 255.

Then, multiplying by a coefficient K n  is replaced by selecting a table item K P,  iwith an index e:

The table is usually calculated on a personal computer and stitched into the memory of the microprocessor.


Integral link  generates an output signal y and  by integrating the error signal eby time and multiplying by the coefficient K and.

Here: T  - time from the beginning of work.

The digital microprocessor calculates the integral by step-by-step integration with a step equal to that of the timer D t. Thus, for a discrete case the formula is replaced by:

Here k is the number of calculation cycles passed from the beginning of work.

Consider the sum of all e  k. In fact, this is simply the sum of all values e,received at each bar. This sum is called the integral sum S   (not to be confused with s   operator of Laplace). The integral sum is realized as a global variable and at each clock cycle is increased by the current value of the error signal e:

When calculating the PID controller, the ratio K and  usually ranges from 0.05 to 2. The calculation cycle for D tis from 0.0001 to 0.002 seconds. Thus, the coefficient K andD tis from 5 · 10 -6 to 4 · 10 -3. Because this coefficient is much less than 1, then the problem of an integer multiplication on it arises, since after multiplication, zero will always be obtained.

To solve this problem, let's try to multiply the coefficient K andD tto a large number A , and we divide the integral sum by the same number:

We denote the product K andD t · A through a factor B :

We choose such a number A , multiple of 256   x  , to the coefficient B was in the range from 0.05 to 5.


In order to calculate the ratio S / A , extend the sign of the number S :

    we realize 16-bit calculation S, if A =256;

    we realize 24-bit calculation S, if A =256 2 ;

    we realize 32-bit calculation S, if A =256 3 .

It is not difficult to implement an addition to a 16, 24 or 32-bit signed number S signed 8-bit number e. Do not forget that if e  positive, then when the sign is expanded, the high-order bits are filled with zeros, and if negative, the high-order bits are filled with ones. To limit the accumulation of the integral sum, we realize the upper and lower limit. Usually this is done as follows: if the highest (signed) bit is not equal to the penultimate bit, then the growth of the integral sum should be suspended.


Recall that dividing any number by 256   x  equivalent to the right shift to xbyte right. We use this rule. We take only the high byte of the integral sum S : in the case of a 16-bit account, this is equivalent to a one-byte shift, in the case of a 24-bit account, by two bytes, in the case of a 32-bit account, by three bytes.

In this way:

Where: S   older  - high byte of the number S .

Multiplication by a factor B   we implement in the form of a table B   i, similar to the calculation of the coefficient of proportional link:


Differential link

Differential link calculates the output signal y d - e 0 is implemented in the form of a table C   i, as in the calculation of the proportional link:

PID Adder Totalizer

The totalizer after the PID controller adds the instantaneous values ​​of the signals y n, y and  and y d  and generates an output signal y:

When summing, you should ensure that the result is in the range from -127 to +127, implementing, for example, 16-bit summation. If the result is greater than 127, it should be assumed equal to 127, and if less than -127, then equal -127.

The PWM signal is generated automatically by the AVR microprocessors. One microprocessor is able to generate up to 3 hardware PWM signals. In addition, the PWM signal can be programmed by timer.

It is convenient to configure a 7-bit PWM. In this case, the control power key can be connected according to the scheme shown in Fig. 4.




Fig. 4. Method of connecting the power switch to the PWM output.

The highest (sign) bit of the result yis output via any I / O pin to one of the inputs of the power key, and the remaining 7 bits (the last bit is zero) without any conversion can be loaded into the PWM cut-off register.

Let us prove this.

Q.E.D.