AVR221: Discrete PID controller. Development and design of pid-regulators

  • Tutorial

The PID controller is the simplest controller that has effective hardware analog implementations, and therefore is applied most widely. For its work, it is necessary to adjust the 3 coefficients for a specific object, allowing to choose the process of regulation according to the requirements. Possessing simple physical meaning and simple mathematical recording, it is used widely and often in temperature regulators, gas flow regulators and other systems where it is required to maintain a certain parameter at a given level, with possible transitions between different preset levels. Of course, there are more complex controllers that allow more accurate and quicker and with fewer overshoots to reach the specified parameters, as well as taking into account the non-linearity or hysteresis of the regulated object, but they are more computationally complex and more difficult to set up.

Despite its simplicity of both physical meaning and mathematical notation:

In the software implementation of the PID controller, mistakes are often made that occur even in the authenticated automation devices.

And to check the quality of the implementation of the PID controller is extremely easy.

Let's consider the simplest example: a thermoregulator. To test its quality, a fast, low inertial, low-power object is best suited. Classics of the genre: a conventional 100W light bulb with a thin thermocouple attached to it (HA). And the first thing on which to check the PID controller is the degradation of the PID to just the P-regulator. That is, the coefficients of the integral and differential are set to zero, but proportional to the maximum.

Turn on the regulator, check: the current temperature is 22 degrees, the set point is 16 degrees. The light does not light. We begin to increase the set point: 16.1, 16.3, 16.7, 18 ... 19 ... the light bulb caught fire. How?! Where from ?! We stop - turned off. So, we met with the first classic mistake  implementation of the PID controller.

A small mathematical digression: remember once again the integral record mentioned above. We implement it programmatically, which means it is discrete. That is, with an enviable regularity we make a measurement of the input quantity, compare it with the set point, calculate the effect, issue it, repeat it. So, we must go from the integral form to the finite-difference scheme. In the transition, the transition to the forehead is usually used:

  where E (n) = X (n) - X0 (n) - that is, the amount of mismatch between the current and the set value of the controlled parameter.

The use of a direct formula requires that the integral of mismatches be counted and stored for a long period, secondly, it requires working with a high-precision floating point (since the integral coefficient Ki is always< 1), либо операции деления (представляя коэффициент в форме 1/Ki) большой разрядности. Всё это требует вычислительных ресурсов, коих в embedded как правило сильно ограничено… Поэтому, вместо реализации прямой схемы, реализуют рекуррентную формулу:

  The use of a recurrence formula makes it possible to reduce the amount of computation and the width of intermediate values.

So, back to our regulator. So, there is an adjustable object: a light bulb. To control the power supplied to it, a simple approach is used: the power network (220V 50Hz) is fed through the triac to the load. The triac at the time of the half-wave transition through zero is turned off, and remains off until a signal is sent to the control electrode. Thus, the earlier after the beginning of the half-wave we give the control signal, the more energy from this half-wave will reach the controlled object. Correctly calculating the time for the linearity of the area of ​​the half-wave part from the time X to the end of the half-wave, we are able to output power from 0 to 100% with the accuracy with which the linearization table was calculated.

So, we can give power from 0 to 100%. In real objects, it is often impossible to give out 100% of the power - for example, it is overheating the heating element. Therefore, all devices have a setting of the minimum and maximum output power per object.

So, after calculating U (n) according to the parent formula, the result restriction is added:
   if Un< Umin then Un:= Umin; if Un>Umax then Un: = Umax;
  After that, the computed Un is the required output power for the current moment. Ta-dam! It is this implementation that creates the error, which is written above.

The reason is trivial: at the moment of transition from a specific to a finite-difference scheme, we "bracket" the operation of calculating the integral, and at each step we add the derivative to the accumulated sum U (n-1). By imposing a restriction on it, we actually nullify the entire integral. (Well, not how many we reset, how many we bring to the range 0-100, which in this case is insignificant). Thus, we are differentiated by the PID controller, and there remains a differential-accelerator. What in reality looks like a simple differential regulator - the power is supplied in proportion to the change in the set point or the regulated value, and not in proportion to the difference between the setpoint and the regulated value.

Conclusion №1: the computation of U (n) can not be restricted. To limit the power supplied to the output device, a separate variable must be set.

Now, when we started Urn, for limited power, we re-pour, we continue testing.
  Turn on the regulator, check: the current temperature is 22 degrees, the set point is 16 degrees. The light does not light.
  We begin to add the set-point: 16.1, 16.4, 17, 18, 20, 22, 24 (it's lighted up! Hurray!), 28, 30, 40, 60 ... Beauty! Working!
  We are watching the process - it turned out about 60, hangs a little back and forth, but holds. It seems that everything is beautiful. Exhale, check the control from the PC: set 600 degrees. And ... The light turns off. How so? Setpoint 600, current 60, and the light is off?

While we wait and slowly realize that we have obviously run into some kind of «Classic Cant No.2»  ™ light slowly inflames, comes out at 100% power, and so it remains - 600 degrees it gives out well, can not.

We return again to our difference scheme. U (n) = U (n-1) + Kp * (dE + ...). To the current calculated value of the impact, the residual difference multiplied by the proportionality coefficient is added. We had setpoint 60, temperature 60, that is, zero residual. The output power was also zero. And then, at once, abruptly, the set point was increased to 600 degrees. the discrepancy sharply became 540 degrees, multiplied by a proportionality factor ... and flew for the storage capacity U (n). Do not laugh, use math from a fixed point, instead of a floating point. With a difference of 540 degrees and working through 1/16, with a proportionality factor of 20, we get ... 540 * 20 * 16 = 172800, and if we have a 16-bit U (n), moreover, a signed one, in fact, as a result of the calculation, we got A300h = -8960. Opacca. Instead of a big plus - a tangible minus.

Conclusion number 2: calculations must be performed with correct overflow support. Overflowed? Limit the limit number, certainly not wrap.

So, we increased the bit capacity U (n), rebroadcast, sewed up, and started. The light bulb is still not completely cooled, there are 80 degrees, the setting is still the same 600. The light is lit ... and it goes out. Lights up and goes out. How so? Setpoint 600, the bulb 80 - and maintains its own 80! How is that?! Clearly we climbed out Beetle No. 3.

Again, a lyrical-mathematical digression. So, there is our difference scheme: U (n) = G (U (n-1), dE (n)). Once again: the new value of the impact is the sum of the past impact and some impact, depending on the difference of the residual at the current time and the previous one. And what is the previous moment? And what is the previous moment of the previous one? Well, remember the school. Proof by induction. If we can construct a proof for K + 1, assuming that the proof for K is true, AND  To prove separately what is true for K = 0, then the proof is true. So, how do we consider U (0)?

Frequently encountered solution: all zero, set the setpoint from the flash settings, wait for 1 poll cycle, and read X (0). Now, zero is ready, now we are working. And ... And it's not right. Why? Because the recursion formula is based on changes in the discrepancy. And having initialized zero and having loaded the current values, we lost the starting conditions. All - instead of maintaining the absolute value of the temperature at a level equal to the absolute setting, the controller starts keeping the temperature equal to the starting value plus the difference in the set point. That is, it was 80 degrees and setpoint 200, turned on the device - it holds 80. Change the setting to 240 - it started to hold 120.

Correct initialization of the difference scheme: zeroing _all all_. I.e
   X (0) = 0, X0 (0) = 0. U (0) = 0. E (0) = X (0) -X0 (0) = 0.
  And on the first cycle of calculations, we have, as it were, the setting and the current value appearing abruptly:
   X (1) = 80. X0 (1) = 200. (1) = U (0) + Kp * (E (1) -E (0)) = U (0) + Kp * (X (1) -X0 (1) -E (0)) = 0 + 20 * (200 - 80 - 0) = 2400
  Now the circuit works correctly.

Conclusion №3: correctly initialize the start conditions.

Is it right? Well, well, well ... Once again ... Set the set point 20. We are waiting for the cooling ... Turn it off. Turn it on. So, beauty: the current 20, setting 20. We put a jump in 600. I went to bask. 100, 120 ... set the setting 20. Has disappeared, it has gone to cool. We are waiting for a bit (120 ... 110 ... 100 ... 90 ... 80 ...) and set the set-point to 100. It went to warm ... 105 degrees, it turned off. Stop. And why does it hold 105? At us now only proportional component works. With the correct implementation of the physical meaning of the process, the oscillatory process can not keep the set point higher than given. Strictly lower. And holds 5 degrees more than asked. This is observed Funny number 4.

So, we remember what we had above: Conclusion number 2: U (n) can not be limited. And Conclusion number 3: in case of overflow, it is necessary to limit all the same. Yes Yes. Otherwise, the "working point" is shifted for a limited time. What to do? Increase the discrepancy? Well, if you have enough processing power. And whether it is necessary? Actually, what's wrong with us, U (n) = 9999.99, not 29999.99? In general, only the fact that we lost 20,000. But now for work, we still need to get 100% of power, right? Correctly. Hence, there is no problem with the restriction in the regiment, until we depart from the limit. Thus, in case of overflow, the flag should be put, and after reaching, for example, half of the range (that is, as U (n) after 9999.9 dropped below 5000.00), reinitialize the circuit. That is, discard the story, say that n = 0 and see above Conclusion # 3. The inquisitive mind has already realized that in the case of a complete scheme, when all three components are not zero, zeroing out the iterative process in the process, we also zero the accumulated integral of the integral component. However, due to the fact that we have to clear up significantly in advance, it will have time to dig in during the time of finishing the remainder. And it is not entirely correct to accumulate the integral on the "large" distances, since the goal of the integral component is to "choose" a discrepancy that the proportional component can not work out separately.

Conclusion No. 4: if for some reason U (n) was limited, the scheme should be reinitialized as soon as the impression appeared that the circuit returned to its normal state.

In the next issue: and whether it is necessary to implement the difference scheme? Detailed implementation of a direct discrete circuit with simple and understandable adjustable coefficients, with direct physical meaning, which without problems calculates a control action with a frequency of 25Hz on the ADuC847 processor (fast 8-bit controller, with 8051 core), leaving still a lot of CPU time for other processes .

  (Pictures depicting formulas are taken from the article

Send your good work in the knowledge base is simple. Use the form below

Students, graduate students, young scientists who use the knowledge base in their studies and work will be very grateful to you.

It is placed on http://www.allbest.ru

Ministry of Education and Science of the Russian Federation

Federal State Budget Educational Institution

higher professional education

"KUBAN STATE UNIVERSITY"

(FGBOU HPE "KubSU")

EXTENDED QUALIFICATION OF BACHELOR

Development and design of PID controllers

The work was carried out by Roman Valeryevich Presnyakov

scientific adviser

dr. fiz.-mat. Sciences, Professor

E.N. Tumayev

Standard controller

cand. fiz.-mat. Sci., Associate Professor AA Martynov

Krasnodar 2015

Graduation qualification work 83 pp., 29 Fig., 42 sources.

PID ADJUSTMENT, BUILT-IN SYSTEMS, MICROCONTROLLERS, SOFTWARE MODULES, MSP430, INTERRUPTIONS

The object of investigation of the final qualifying work is the study of the general principles of the construction of proportional-integral-differential technological regulators and the design of an algorithm for temperature controllers based on cheap microcontrollers MSP430 (Texas Instruments). In work the review of means of modern microcontrollers and principles of their work is carried out.

The analysis of problems of hardware and software implementation of technological microprocessor regulators is carried out. Recommendations are given on the design of microprocessor measuring and control devices and the creation of software for embedded systems. An embodiment of the PID-controller algorithm is proposed. A distinctive feature is the use of algorithms that exclude the use of floating-point numbers.

Notations and abbreviations

Introduction

2. Sensitivity functions. The equation of the digital pid controller

2.2 The discrete form of the regulator. The equation of the digital PID controller

3. Quality of regulation

3.1 Weakening the influence of external disturbances. Quality criteria

4. Adjust the controller parameters. basic principles

4.1 Selection of the controller parameters. Manual and Automatic settings

5. Programming Embedded Systems

5.1 General principles for the development of embedded systems

5.2 Stages of creating software for embedded systems

5.3 Hierarchy of executable code in embedded systems

6. Algorithm of the created software

6.1. Description of the algorithm of operation of the temperature PID controller based on the microcontroller MSP430F149

Conclusion

List of sources used

Notations and abbreviations

regulator temperature microcontroller

microcontroller

PID algorithm

Proportional-integral-differential algorithm

hardware abstraction layer (hardware abstraction layer)

Integrated development environment (integrated development environment)

pulse width modulation

programmable logic controller

supervisory control and data acquisition

serial peripheral interface (serial peripheral interface)

application programming interface

workstation

software

INTRODUCTION

Control of technological processes with the help of regulators working in the proportional-integral-differential law (PID regulators) allows to maintain the required technological value with a sufficiently high accuracy and acceptable noise immunity to external disturbing effects. Modern PID-controllers are implemented as a software module SCADA-system executable on the workstation (APM) or programmable logic controller (PLC), and as separate technological regulators located on local and central control cabinets. As the basic elements of information processing and management, microprocessors with limited functionality are often used, which leads to a problem of lack of hardware resources and a rise in the cost of the system.

The purpose of this work is to review the principles of constructing proportional-integral-differential regulators and to develop, based on the review, the principles of creating a PID temperature controller.

When creating a temperature PID controller, a programmable microprocessor technological measuring regulator F0303.2 was used based on the MSP430F149 microcontroller, MSP-FET430UIF programmer, P3003 voltage comparator with a voltage range from 10 nV to 11.111110 V and accuracy class 0.0005. The microcontroller program was created in the integrated development environment of IAR Embedded Workbench for MSP430. 6. Technical documentation was obtained on the site of the microcontroller manufacturer.

For the full implementation of PID regulation in a microprocessor device, the following subsystems must be implemented:

The measurement subsystem

PID processing subsystem

Management UI subsystem

Subsystem of issue of regulatory influence

1. Principles of creating PID regulators

1.1 General questions of implementation of PID controllers

For practical implementation, it is necessary to take into account the features generated by real conditions of application and technical implementation. These features include:

The final dynamic range of changes in physical variables in the system (for example, limited heater power, limited valve capacity);

Not always the existing possibility of changing the sign of the control action (for example, in a temperature maintenance system, there is often no refrigerator, the engine may not have a reversal, not every aircraft has a negative traction system);

Limited measurement accuracy, which requires special measures to perform the differentiation operation with an acceptable error;

The presence in almost all systems of typical nonlinearities: saturation (limiting the dynamic range of variation of variables), limiting the rate of build-up, hysteresis and backlash;

Technological dispersion and random variations of the regulator and object parameters;

Discrete implementation of the regulator;

Need for smooth (unstressed) switching of control modes;

1.2 Differential node of the PID controller

The problem of numerical differentiation is quite old and common in both digital and analog regulators. Its essence lies in the fact that the derivative is usually calculated as the difference of two variables close in magnitude, therefore the relative error of the derivative always turns out to be greater than the relative error of the numerical representation of the differentiable variable.

In particular, if a sinusoidal signal A * sin (tt) arrives at the input of the differentiator, then at the output we get A * щ * cos (tt), that is, the signal amplitude at the output of the differentiator increases with increasing frequency ui. In other words, the differentiator enhances high-frequency noise, short emissions and noise.

If the interference amplified by the differentiator lies outside the range of the operating frequencies of the PID controller, they can be weakened using a high-pass filter. The structural implementation of the differentiator with the filter is shown in Figure 1. Here

that is, the transfer function of the resulting differentiator D (s) can be represented as a product of the transfer function of an ideal differentiator and the transfer function of a first-order filter:

where the coefficient N specifies the cut-off frequency of the filter and is usually chosen to be 2 ... 20;

T / N - filter time constant;

s is the complex frequency.

A greater attenuation of high-frequency noise can be obtained by using a separate filter, which is connected in series with the PID controller. Usually a second order filter with a transfer function

The filter time constant is chosen to be TF = Ti / N, where N = 2 ... 20, Ti is the integration constant of the PID controller. It is preferable not to select the filter boundary frequency below the 1 / Ti frequency, as this complicates the calculation of the regulator parameters and the stability margin.

Figure 1 - Structural implementation of the differential member of the PID controller

In addition to noise differentiation, the characteristics of the PID controller are influenced by measurement noise. Through a feedback loop, these noises are input to the system and then appear as a variance of the control variable u. High-frequency noise is harmful in that it causes an accelerated wear of pipeline fittings and electric motors.

Since the control object is usually a low-pass filter, measurement noise rarely penetrates the control loop to the output of the system. However, they increase the measurement error y (t) and reduce the accuracy of regulation.

In PID regulators, noise is distinguished with a spectrum in the low frequency region caused by external influences on the control object and high-frequency noise associated with electromagnetic interference, interference through power and ground buses, with sampling of the measured signal, and other causes. Low-frequency noise is modeled as an external disturbance d (s), high-frequency noise is simulated as measurement noise n (s).

1.3 Integral node of the PID controller. Integral saturation

In the steady-state operating mode and with small disturbances, most systems with PID regulators are linear. However, the process of entering the regime almost always requires taking into account the non-linearity of the "constraint" type. This nonlinearity is associated with natural limitations on power, speed, speed, angle of rotation, cross-sectional area of ​​the valve, dynamic range, and the like. The control loop in the system in saturation (when the variable has reached the limit) turns out to be open, since when changing the variable at the input of the link with the restriction its output variable remains unchanged.

The most typical manifestation of the limitation regime is the so-called "integral saturation", which arises in the process of outputting the system to a mode in regulators with non-zero integration constant Ti? 0. Integral saturation leads to a tightening of the transient process (Figures 2 and 3). A similar effect occurs due to the limitation of the proportional and integral term of the PID controller (Figures 4 and 5). However, often under the integral saturation we mean a set of effects associated with nonlinearity of the "constraint" type.

T 1 = 0.1 s; T2 = 0.05 s; L = 0.02 s; K = 2; Ti = 0.06 s; Td = 0

Figure 2 - Reaction of the output variable y (t) to the jump in the input effect r (t) for the PI regulator, provided that the power at the input of the object u (t) is limited and unlimited (second-order object)

T1 = 0.1 s; T2 = 0.05 s; L = 0.02 s; K = 2; Ti = 0.06 s; Td = 0

Figure 3 - Signal at the input of the object u (t) under the condition of power limitation and without (second-order object)

K = 10; Ti = 0.014 s; Td = 0.3 s; T1 = 0.1 s; T2 = 0.05 s; L = 0.02 s

Figure 4 - Reaction of the output variable y (t) to the jump in the input action r (t) for the PID controller, provided that the power at the input of the object is u (t) and unlimited (second-order object)

T1 = 0.1 s; T2 = 0.05 s; L = 0.02 s; K = 10; Ti = 0.014 s; Td = 0.3 s

Figure 5 - Signal at the input of the object u (t) in the loop with the PID controller under condition of power limitation and without (second-order object)

and of the second order

where Kp is the transmission coefficient in steady state;

T, T1, T2 are the time constants;

L is the transport delay.

The essence of the integral saturation problem is that if the signal at the input of the control object u (t) enters the saturation zone (restriction) and the error signal r (t) - y (t) is not zero, the integrator continues to integrate, at its output it grows, but this signal does not participate in the regulation process and does not affect the object due to the saturation effect. The control system in this case becomes equivalent to an open system whose input signal is equal to the saturation level of the control signal u (t).

For thermal systems, the limitation from below is usually the zero heating power, while the PID controller requires the supply of "negative heating power" to the object, that is, cooling the object. The effect of integral saturation has been known for a long time. In analog regulators, its elimination was quite complicated, because in them the problem could not be solved algorithmically, but solved only by hardware.

With the advent of microprocessors, the problem can be solved much more effectively. Methods for eliminating integral saturation are usually the subject of invention, are classified as commercial secrets of manufacturing firms and protected by patents.

Limitation of the rate of increase in the input impact. Since the maximum value of the input action on the control object u (t) decreases with decreasing difference r (t) - y (t), in order to eliminate the restriction effect, it is possible to simply reduce the rate of rise of the set point signal r (t), for example by means of a filter. The disadvantage of this method is the decrease in the speed of the system, as well as the inability to eliminate the integral saturation caused by external disturbances, and not the setpoint signal.

When the control action on the object reaches saturation, the feedback breaks and the integral component continues to grow, even if in the absence of saturation it should fall. Therefore, one of the methods for eliminating the integral saturation is that the controller monitors the magnitude of the control action on the object, and once it reaches saturation, the controller introduces a software prohibition of integration for the integral component.

Saturation compensation with additional feedback. The effect of integral saturation can be weakened by monitoring the state of the actuator entering saturation and compensating for the signal fed to the integrator input. The structure of the system with this compensator is shown in Figure 6.

Figure 6 - Compensation of the integral saturation effect by means of additional feedback for the transmission of the error signal es to the integrator input

The principle of its work is as follows. The system generates a mismatch signal between the input and output of the actuator es = u - v. The signal at the output of the actuator is either measured or calculated using a mathematical model (Figure 6). If es = 0, this is equivalent to the absence of a compensator and obtains a conventional PID controller. If the actuator enters saturation, then v\u003e u and es< 0. При этом сигнал на входе интегратора уменьшается на величину ошибки es, что приводит к замедлению роста сигнала на выходе интегратора, уменьшению сигнала рассогласования и величины выброса на переходной характеристике системы (рисунки 7 и 8). Постоянная времени Ts определяет степень компенсации сигнала рассогласования.

Figure 7 - The response of the system to a unit jump r (t) for different values ​​of the time constant Ts

K = 7; Ti = 0.01 s; Td = 0.1 s, T1 = 0.1 s; T2 = 0.05 s; L = 0.01 s

Figure 8 - System response to the error signal es (second-order object, regulator parameters:

In some regulators, the input u of the comparator es is selected as a separate input - "tracking input", which is convenient for building complex control systems and for cascading several regulators.

Conditional integration. This method is a generalization of the algorithmic prohibition of integration. After the prohibition, the integral component remains constant, at the same level that it had at the time of the prohibition of integration. The generalization is that the prohibition of integration occurs not only when saturation is reached, but also under certain other conditions.

Such a condition can be, for example, reaching an error signal e or an output variable y of some given value. When the integration process is turned off, it is necessary to monitor the status of the integrator at the moment of shutdown. If it accumulates an error and the degree of saturation increases, then the integration is turned off. If, at the moment of switching-off, the degree of saturation decreases, then the integrator is left switched on.

Figure 9 shows an example of a transient process in a system with an integrator cut-off when the output value y (t) reaches the specified value (y = 0, y = 0.2, y = 0.8).

Figure 9 - Response to a single jump r (t) of the system with saturation of the actuator at various levels of the integrator y trip

The integrator with restriction. In the presented version of the implementation of the PI-regulator with the help of an integrator in the feedback loop. If this circuit is supplemented with a limiter (Fig. 10), then the signal u at the output will never exceed the limits set by the thresholds of the limiter, which reduces the ejection on the transient response of the system (Figure 12). Figure 11 shows the modification of this limiter.

The model of the constraint effect can be improved if, after exceeding the level at which the restriction occurs, reduce the signal at the output of the model (Figure 13). This accelerates the output of the system from saturation.

Figure 10 - Modification of the integrator with a limiter (in parallel)

Figure 11 - Modification of the integrator with a limiter (in series)

Figure 12 - Response to a unit jump r (t) of the system containing

upper bound integrator

Figure 13 - Improved transfer function of the constraint effect model

1.4 System stability. Nyquist Criterion

The possibility of loss of stability is the main disadvantage of systems with feedback. Therefore, providing the necessary margin of stability is the most important step in the design and configuration of the PID controller.

The stability of a system with a PID controller is the ability of the system to return to monitoring the setpoint after the termination of external influences. In the context of this definition, external influences are understood not only as external perturbations acting on the object, but any perturbations acting on any part of the closed system, including measurement noise, temporal instability of the set point, sampling and quantization noise, noise and calculation error. All these disturbances cause deviations of the system from the equilibrium position. If

after the cessation of their impact, the system returns to the equilibrium position, then it is considered stable. When analyzing the stability of PID controllers, it is usually limited to examining the system response to a step change in the set point r (t), measurement noise n (t), and external disturbances d (t). The loss of stability manifests itself as an unlimited increase in the controlled variable of an object or as its oscillation with an increasing amplitude.

In the production environment, attempts to achieve the stability of a PID controller system in an experimental way, without its identification, do not always lead to success (in the first place it concerns systems with a high-order object or with objects that are difficult to identify, as well as systems with a large transport delay) . It seems that stability is a mystical property that can not always be managed. However, if the process is identified with sufficient accuracy, the mysticism disappears and the stability analysis reduces to an analysis of the differential equation describing a closed loop with feedback. Practically interesting is the analysis of the stability stock, that is, the definition of the numerical values ​​of the criteria that allow us to indicate how far the system is from the state of instability.

The most complete information on the stability margin of a system can be obtained by solving a differential equation describing a closed system under external perturbations. However, this process is too laborious, therefore for linear systems simplified methods are used, allowing to estimate the stability margin without solving the equations. We consider two estimation methods: using the hodograph of the complex frequency characteristic of an open loop (the Nyquist test) and using logarithmic frequency response and PFC (Bode diagrams).

A stable system can become unstable with small changes in its parameters, for example, due to their technological dispersion. Therefore, further, we will analyze the sensitivity function of the PID controller system, which allows us to identify the conditions under which the system becomes coarse (not sensitive to changes in its parameters). The system, which maintains the specified stability margin in the entire range of parameter changes due to their technological dispersion, aging, operating conditions, is called robust in the whole range of changes in the load parameters, as well as in the whole range of perturbations acting on the system under real operating conditions. Sometimes robustness and rudeness are used as equivalent concepts.

The Nyquist criterion. Consider a system consisting of a controller R and a control object P (Fig. 14), which is obtained by eliminating the setpoint signal circuit from a classical system with a PID controller. We assume that the feedback is open, and for its closure it is sufficient to connect the points x and y. Suppose now that a signal is input to the input x

Then, passing through the regulator and the control object, this signal will appear at the output y with a changed amplitude and phase in the form:

y (t) =? | G (jm0) | sin (w0t +?), (4)

where is the complex frequency response of the system, (? = arg (G (jm0)) is the argument of the CRC, | G (jw0) | is the CFC module at the frequency w0. Thus, when passing through the controller and the object, the amplitude of the signal changes in proportion to the modulus, and the phase by the value of the CFC argument.

Figure 14 - Structure of an open control system with a PID regulator for stability analysis

If we now close the points x and y, then the signal will circulate along a closed contour, and the condition y (t) = x (t) will be satisfied. If in this case | G (jm0) | ? 1 and? = 180 °, that is, after passing through the contour, the signal enters the regulator input in the same phase as in the previous cycle, then after each passage along the contour the amplitude of the sinusoidal signal will increase until it reaches the boundary of the linearity range of the system, after which the waveform will differ from the sinusoidal. In this case, for the analysis of stability, one can use the method of harmonic linearization, when only the first harmonic of the distorted signal is considered. In the steady state, after the onset of the vibration amplitude limit, in view of the equality y (t) = x (t), the following condition is satisfied:

| G (jm0) | = 1, that is, G (jm0) = -1 (5)

Solving the equation G (jm0) = -1, one can find the oscillation frequency u0 in a closed system.

The complex frequency response G (j) is graphically depicted in the form of a hodograph (Nyquist diagram) - a graph in the coordinates Re and Im (Fig. 15). The arrow on the hodograph line indicates the direction of movement of the "pencil" as the frequency increases. The point G (jm0) = -1, which corresponds to the existence condition for undamped oscillations in the system, has the coordinates Re = -1 and Im = 0 on this graph. Therefore, the Nyquist stability criterion is formulated as follows: a contour that is stable in the open state will retain stability and after its closure, if its CFC in the open state does not cover a point with the coordinates [-1, j0]. More strictly, when moving along the hodograph trajectory in the direction of increasing frequency, the point [-1, j0] must remain on the left, so that the closed contour is stable.

K = 6; T1 = T2 = 0.1 s; L = 0.01 s

Figure 15 - Three hodographs of the CFC of the open system G (j) for the second-order object

Figure 16 shows the reactions of a closed system with three different travel curves (Figure 15) per unit jump in the set point. In all three cases the system is stable, however, the rate of damping of the oscillations and the shape of the transient

process they have different. It is intuitively clear that the system with parameters Ti = 0.01 s, Td = 0.1 s is closest to switching to a state of undamped oscillations with a slight change in its parameters. therefore

when designing a PID controller, it is important to ensure not so much stability as its stock, which is necessary for the normal functioning of the system in real conditions.

The stability margin is estimated as the degree of the distance of the CFC from the critical point [-1, j0]. If | G (jm0) |< 1, то можно найти, во сколько раз осталось увеличить передаточную функцию, чтобы результирующее усиление вывело систему в колебательный режим: gm|G(jщ0)| = 1, откуда

The gain margin gm is the quantity by which the transfer function of the open system G (jm180) must be multiplied so that its modulus at the phase shift frequency of 180 ° (n180) becomes equal to 1. If at the frequency n180 the gain of the open loop is G (js180) = -1 / gm (Figure 15), then the additional gain gm will translate the system to [-1, j0], since (-1 / gm) gm = -1. Similarly, the notion of phase margin is introduced: this is the minimum value of m to which the phase shift in the open system arg (G (jf)) needs to be increased, so that the total phase shift reaches 180 °, that is,

The sign "+" before arg (G (jm1)) is because arg (G (jm1))< 0. Для оценки запаса устойчивости используют также минимальное расстояние sm от кривой годографа до точки [-1, j0] (рисунок 15).

In practice, the values ​​gm = 2 ... 5, m = 30 ... 60 °, sm = 0.5 ... 0.8 are considered acceptable. For the graph in Figure 15, these criteria have the following values:

Gm1 = 12.1; m1 = 15 °; sm1 = 0.303 (for the case of Ti = 0.01 sec,

Gm2 = 11.8; m2 = 47.6 °; sm2 = 0.663 (for the case of Ti = 0.05 s,

Gm3 = 1.5; m3 = 35.2 °; sm3 = 0.251 (for the case of Ti = 0.05 s,

If the curve of the hodograph crosses the real axis at several points, then to estimate the stability margin take one of them, which is closest to the point [-1, j0]. With a more complicated hodograph, the stability margin estimate can be used as a margin for delay. The delay margin is the minimum delay, when it is added to the circuit, it loses stability. Most often this criterion is used to estimate the stability margin of systems with Smith's predictor.

The frequency stability criterion. Logarithmic frequency response and phase response can be used to graphically represent the transfer function of an open system and the stability margin estimate (Figure 17). To estimate the phase margin, first, frequency response (frequency of cut, or frequency of unit gain) at which G (jm1) = 1 is found by frequency response is found, then the corresponding phase margin is found by PFC. In order to estimate the gain margin, we first find the frequency u180 at which the phase shift is 180 °, then the gain is found by the gain characteristic. Figure 17 shows examples of graphical constructions for estimating the margin of gain and phase for a system whose travel times are shown in Figure 15.

If the margin of the open loop phase is 0 ° or the gain margin is 1, the system will be unstable after closing the feedback loop.

Figure 16 - Transient response of a closed system, which

has the travel curves shown in Figure 15

2. Sensitivity functions. digital PID controller equation

2.1 Sensitivity functions. Robustness. Impulsive switching of control modes

The transfer function of the real object P (s) can vary during operation by the amount of DP (s), for example, due to changes in the load on the motor shaft, the number of eggs in the incubator, the level or composition of the liquid in the autoclave, due to aging and wear of the material, changes in lubricant, etc. Correctly designed automatic control system should maintain its quality indicators not only in ideal conditions, but also in the presence of the listed harmful factors. To assess the effect of the relative change in the transfer function of the DP / P object on the transfer function of the closed system Gcl

y (s) = r (s), Gcl (s) = (8)

find the differential dGcl:

Dividing both sides of this equality by Gcl and substituting in the right-hand side Gcl = PR / (1 + PR), we get:

Figure 17 - Estimated margin for gain and phase for a travel time system shown in Figure 15

From (10) we can see the meaning of the coefficient S - it characterizes the degree of influence of the relative change in the transfer function of the object on the relative change in the transfer function of the closed loop, that is, S is the sensitivity coefficient of the closed loop to the variation of the transfer function of the object. Since the coefficient S = S (jf) is frequency-dependent, it is called the sensitivity function.

As follows from (10),

We introduce the notation:

The value of T is called the complementary (additional) sensitivity function, since S + T = 1. The sensitivity function allows us to estimate the change in the properties of the system after closing the feedback. Since the transfer function of an open system is G = PR, and closed Gcl = PR / (1 + PR), then their ratio is Gcl / G = S. Similarly, for an open system, the transfer function from the disturbance input d to the output of a closed system is (see) P (s) / (1 + P (s) R (s)), and the open one is P (s), hence their ratio is also S. For the transfer function from the measurement noise input n to the system output, you can get the same ratio S.

Thus, knowing the form of the function S (jm) (for example, in Figure 18), we can say how the suppression of external influences on the system for different frequencies will change after the feedback loop is closed. Obviously, the noise lying in the frequency range in which | S (j) | \u003e 1, after the closure of the feedback will be amplified, and noise with frequencies at which | S (jm) |< 1, после замыкания обратной связи будут ослаблены.

The worst case (the greatest gain of external influences) will be observed at the frequency of the maximum Ms of the modulus of the sensitivity function (Figure 18):

The maximum sensitivity function can be associated with the stability margin sm (Figure 15). To do this, we draw attention to the fact that | 1 + G (jm) | represents the distance from the point [-1, j0] to the current point on the hodograph of the function G (j). Consequently, the minimum distance from the point [-1, j0] to

function G (j) is equal to:

Comparing (13) and (14), we can conclude that sm = 1 / Ms. If the modulus of G (j) decreases with increasing frequency, then, as can be seen from Fig. 15, (1 - sm)? 1 / gm. Substituting here the relation sm = 1 / Ms, we obtain the estimate of the gain margin, expressed in terms of the maximum of the sensitivity function:

Similarly, but with more rough assumptions, it is possible to write the margin estimate in phase through the maximum of the sensitivity function:

For example, if Ms = 2, we get gm? 2 and? 29 °.

Figure 18 - Sensitivity functions for the travel time curve system shown in Figure 13

Robustness is the ability of a system to maintain a given stability margin with variations in its parameters caused by a change in load (for example, when the kiln load changes, its time constants change), technological variability of parameters and their aging, external influences, calculation errors, and model object error. Using the notion of sensitivity, we can say that robustness is the low sensitivity of the margin of resistance to the variation of the parameters of the object.

If the parameters of the object vary within a small range, when the differential can be used as a finite increment, the effect of changes in the object's parameters on the transfer function of the closed system can be estimated using the sensitivity function (10). In particular, it can be concluded that, at those frequencies where the sensitivity function modulus is small, the effect of changes in the parameters of the object on the transfer function of the closed system and, accordingly, on the stability margin will also be small.

To assess the effect of large changes in the parameters of an object, let us represent the transfer function of an object in the form of two terms:

P = P0 + DP, (17)

where P0 is the calculated transfer function, DP is the deviation from P0, which should be a stable transfer function. Then loop amplification of the open system can be represented in the form G = RP0 + RDP = G0 + RDP. Since the distance from the point [-1, j0] to the current point A on the hodograph of the unperturbed system (for which ΔP = 0) is | 1 + G0 | (Figure 19), the stability condition of a system with a deviation of loop amplification RDP can be represented as:

| RDP |< |1+G0|,

where T is an additional sensitivity function (12). Finally, we can write the relation:

which must be fulfilled so that the system remains stable when the process parameters are changed by the value AP (jf).

Reduction of zeros and poles. Since the transfer function of the open system G = RP is the product of two transfer functions, which in general have both a numerator and a denominator, it is possible to shorten the poles that lie in the right half-plane or are close to it. Since in real conditions, when there is a spread of parameters, such a reduction is not performed accurately, a situation may arise when the theoretical analysis leads to the conclusion that the system is stable, although in fact, with a small deviation of the process parameters from the calculated values, it becomes unstable.

Therefore, every time the poles are cut, it is necessary to check the stability of the system with a real spread of the parameters of the object.

Figure 19 - Explanation of the derivation of relation (18)

The second effect of pole reduction is the appearance of a significant difference between the time of establishment of a transient process in a closed system under the action of the setpoint signal and external disturbances. Therefore, it is necessary to check the reaction of the synthesized regulator under the action of not only the setpoint signal, but also external disturbances.

Impulsive switching of control modes. In PID regulators, there may be modes when their parameters change abruptly. For example, when the operating system needs to change the integration constant or when after manual system control it is necessary to switch to automatic mode. In the cases described, unwanted emissions of the controlled quantity may appear, unless special measures are taken. Therefore, the problem arises of smooth ("unstressed") switching of operating modes or regulator parameters. The main method of solving the problem consists in constructing such a regulator structure when the parameter change is performed before the integration stage. For example, with the changing parameter Ti = Ti (t), the integral term can be written in two forms:

I (t) = or I (t) =.

In the first case, with an abrupt change in Ti (t), the integral term will change abruptly, in the second case smoothly, since Ti (t) is under the integral sign, whose value can not change abruptly.

A similar method is implemented in the incremental form of the PID controller (see subsection "Incremental form of the digital PID controller") and in the serial form of the PID controller, where integration is performed at the final stage of the calculation of the control action.

2.2 Discrete shape of the controller The equation of the digital PID controller

Continuous variables are useful for analysis and synthesis of PID regulators. For technical implementation, it is necessary to move to a discrete form of equations, since the basis of all regulators is a microcontroller, controller or computer that operates with variables derived from analog signals after their quantization in time and level sampling.

Due to the finite time of the calculation of the control action in the microcontroller and the delay in the analog-to-digital conversion between the moment of the analog signal input to the regulator input and the appearance of a control action on its output, an unwanted delay appears that increases the overall delay in the control loop and reduces the stability margin.

The main effect that appears in discretization and which is often "reopened" is the appearance of alias frequencies in the spectrum of the quantized signal in the case when the quantization frequency is not high enough.

A similar effect occurs when shooting a rotating car wheel. The frequency of the alias signal is equal to the difference between the interference frequency and the sampling frequency. In this case, the high-frequency interference signal is shifted to the low-frequency region, where it is superimposed on the useful signal and causes big problems, since it is impossible to filter it at this stage.

To eliminate the aliasing effect, an analog filter must be installed before the input of the analog-to-digital converter, which would attenuate the interference by at least an order of magnitude at a frequency equal to half of the quantization frequency. Usually a second or higher order Butterworth filter is used. The second solution to the problem is to increase the quantization frequency so that it is at least 2 times (according to Kotel'nikov's theorem) higher than the maximum frequency of the interference spectrum. This makes it possible to apply a digital low-pass filter after quantization. At this sampling frequency, the received digital signal in terms of the amount of information is completely equivalent to the analog one, and all the properties of the analog regulator can be extended to digital.

Transition to finite-difference equations. The transition to discrete variables in the equations of the analog regulator is performed by replacing the derivatives and integrals with their discrete analogs. If the equation is written in operator form, the transition from the image area to the original area is performed first. The differentiation operator is replaced by the derivative, and the integration operator by the integral.

There are many ways of approximating the derivatives and integrals by their discrete analogs, which are presented in the courses of numerical methods for solving differential equations. In PID regulators, the most common are the simplest kinds of approximation by the derivative of a finite difference and the integral by a finite sum. Consider the integral term of the PID controller:

Differentiating both parts in time, we obtain

Replacing the differentials in this expression by finite differences (left differences), we obtain

where the subscript i denotes that the given value is taken at time ti (note that here and below the i-index in Ti denotes not the time step number, but the integral coefficient of the PID controller). From the last expression, we get:

Thus, the next value of the integral can be calculated, knowing the previous value and the error value at the previous time. However, such a formula has the property of accumulating a computational error over time if the ratio Δt / Ti is not sufficiently small. The other integration formula is more stable - with right differences, when the error value is taken at the same time as the calculated integral:

Consider the differential term of a PID controller with a filter:

Going in this formula from the images to the originals, we get:

Replacing the differentials by finite increments, we obtain the difference equation:

We note that for the convergence of the iterative process (21) it is necessary that

At Δt\u003e Td / N, the iterative process (21) becomes oscillatory, which is inadmissible for the PID controller. The best characteristics are obtained by the difference equation obtained using the right differences:

Here the convergence condition holds for all A, and no oscillations arise for any values ​​of the parameters. In addition, the last formula allows you to "disconnect" the differential component in the PID controller by assigning Td = 0, which can not be done in expression (21), since this causes division by zero. You can use even more precise formulas of numerical differentiation and integration, known from the course of numerical methods for solving equations. The value of the quantization step Δt is chosen as small as possible, this improves the quality of the control. To ensure good quality of regulation, it should not be more than 1/15 ... 1/6 of the time of setting the transient characteristic of the object at the level of 0.95 or 1/4 ... 1/6 of the transport delay. However, when the quantization frequency is increased by more than 2 times in comparison with the upper frequency of the spectrum of the disturbing signals (by Kotel'nikov's theorem), further improvement in the quality of regulation does not occur.

If there is no antialiasing filter at the regulator input, the sampling frequency is selected 2 times higher than the upper boundary frequency of the interference spectrum in order to use digital filtering. It must also be taken into account that the actuator must be able to work during the time Dt.

If the controller is used not only for regulation but also for alarms, the quantization clock can not be less than the permissible alarm delay.

With a small quantization cycle, the error in calculating the derivative increases. To reduce it, you can use the smoothing of the received data on several collected points before the differentiation stage.

The equation of the digital PID controller. Based on the above, the equation of a discrete PID controller can be written in the form:

where i is the number of the time step.

To start the algorithm, we usually choose uD0 = 0, I0 = 0, e0 = 0, but there may be other initial conditions, depending on the meaning of the particular control problem.

Note that the algorithm obtained by simply replacing the differentiation and integration operators in the classical PID controller equation

finite differences and finite sums

has poor stability and low accuracy, as was shown earlier. However, as the sampling rate increases, the difference between the two algorithms is erased.

Incremental form of the digital PID controller. Quite often, especially in neural network and Fuzzy regulators, the PID controller equation is used in the form of the dependence of the increment of the control quantity on the control error and its derivatives (without an integral term). Such a representation is convenient when an external device, eg a conventional or stepper motor . The angle of rotation of its axis is proportional to the value of the control signal and time. In fuzzy regulators, when formulating fuzzy rules, the expert can formulate the dependence of the control quantity on the magnitude of the derivative, but on the magnitude of the integral-can not, since the integral "remembers" the whole history of error change, which a person can not remember.

The incremental form of the PID controller is obtained by differentiating equation (25):

To obtain a zero error in the regulation, the integrator must stand at the output of the incremental controller (Figure 20):

Figure 20 - Incremental form of the PID controller

Passing in the obtained expressions to finite differences, we obtain the discrete form of the incremental PID regulator:

where Au + 1 = ui + 1 - ui;

Ae = ei - ei-1.

A more stable and precise difference equation can be obtained by substituting the expressions for ui + 1 and ui from (24) into the formula Auui + 1 = ui + 1 - ui.

The incremental shape of the regulator is convenient for use in microcontrollers, since in it the bulk of the computations are performed in increments for which a word with a small number of bits can be used. To obtain the value of the control value, you can perform the cumulative summation in the final stage of the calculations: ui + 1 = ui + Dui + 1.

Before calculating the parameters of the regulator, it is necessary to formulate the purpose and quality criteria for regulation, as well as restrictions on the magnitude and rate of change of variables in the system. Traditionally, the main qualitative indicators are formulated based on the requirements for the reaction form of a closed system for a step change in the set point. However, such a criterion is very limited. In particular, he does not say anything about the magnitude of the attenuation of measurement noise or the influence of external disturbances, can give an erroneous idea of ​​the robustness of the system.

Therefore, for a complete description or testing of a system with a PID controller, a number of additional quality indicators are needed, which will be discussed further.

In general, the choice of quality indicators can not be fully formalized and must be carried out, based on the meaning of the problem being solved.

3. Quality of regulation

3.1 Quality criteria Weakening the influence of external disturbances

The choice of the quality criterion depends on the purpose for which the regulator is used. The goal may be:

Maintain a constant value of the parameter (for example, temperature);

Monitoring the setpoint change or program control;

Control of the damper in a tank with a liquid, etc.

For one or another task, the most important factor can be:

The form of response to external disturbances (time of establishment, re-regulation, response time, etc.);

The form of response to measurement noise;

The form of response to the setpoint signal;

Robustness in relation to the spread of the parameters of the control object;

Energy saving in a controlled system;

Minimization of measurement noise.

For a classical PID controller, the parameters that are best for monitoring the setpoint are generally different from those that are best for reducing the effects of external disturbances. In order for both parameters to be simultaneously optimal, it is necessary to use PID regulators with two degrees of freedom.

Accurate tracking of the change in the set point is necessary in motion control systems, in robotics; in process control systems where the setpoint usually remains unchanged for a long time, the maximum influence of the load (external disturbances) is required; in the control systems of tanks with liquid, it is required to ensure laminar flow (minimizing the variance of the output variable of the regulator), etc.

As it was shown in the subsection, the feedback weakens the influence of external disturbances in | S (j) | times except for those frequencies on which | S (jm) |. External perturbations can be applied to the object in various parts of it, however, when a particular place is unknown, it is believed that the perturbation affects the input of the object. In this case, the response of the system to external disturbances is determined by the transfer function from the input of external disturbances to the output of the system:

Since external perturbations usually lie in the low-frequency part of the spectrum, where | S (j) | and, consequently, T, then expression (28) can be simplified:

Thus, to reduce the influence of external disturbances (in particular, the effect of the load), the integration constant Ti can be reduced.

In the time domain, the response to external disturbances is estimated from the response to the unit jump d (t). Reducing the effect of measurement noise: The transfer function from the point of application of noise to the output of the system is:

Due to the drop in the frequency response of the object at high frequencies, the sensitivity function tends to 1 (Figure 18). Therefore, it is impossible to reduce the influence of measurement noise by feedback. However, these noises are easily eliminated by applying low-pass filters, as well as proper shielding and grounding.

A closed system remains stable when the parameters of the object are changed by the value AP (jf), if condition (18) is satisfied.

Criteria for quality in the time domain. To assess the quality of regulation in a closed system with a PID controller, stepwise input action and a series of criteria are used to describe the shape of the transient process (Figure 21):

Maximum adjustment error

and the time instant Tmax, at which the error reaches this maximum;

Integrated absolute error

The square of the error integral

The damping decrement d (this ratio of the first maximum to the second, the typical value d = 4 or more)

note that in the literature there are other definitions of the damping decrement, in particular, as or as b / a coefficient in the exponential exponent describing the envelope of damped oscillations;

Static error e0 (this is a constant error in the equilibrium, that is, in the steady state, or static, mode of the system);

The time of establishment of Te with a given error es (this is the time after which the error of regulation does not exceed the set value of es, usually es = 1%, less than 2% or 5% respectively, the setting time is T0.01, T0.02, T0.05 );

The overshoot of emax (this is the excess of the first release above the steady-state value of the variable, usually expressed as a percentage of the steady-state value);

The rise time Tr (this is the time interval during which the output variable rises from 10 to 90% of its steady-state value);

The period of decaying oscillations of Tcl (strictly speaking, damped oscillations are not periodic, so here by the period is meant the distance between two neighboring maxima of the transition characteristic).

Figure 21 - Time domain quality control criteria

For motion control systems, a linear signal is more often used as a test signal than a jump function, since electromechanical systems usually have a limited rate of increase in the output quantity.

The above criteria are used to evaluate the quality of the reaction as a change in the set point, and on the effect of external disturbances and measurement noise.

Frequency criteria of quality. In the frequency domain, the following criteria are usually used, obtained from the amplitude-frequency characteristic curve of the closed system y (ui) (Figure 22):

The bandwidth of n-3dB (or n0.7) at -3 dB (or at the level 1 / = 0.7) is the frequency bandwidth from 0 to n-3dB = n0.7, within which the amplitude-frequency characteristic curve does not decrease by more than by 3 dB with respect to its value at zero frequency y (0);

The oscillation M is the ratio of the peak (peak) value of the amplitude-frequency characteristic ymax to its value at zero frequency y (0), that is, in the steady state

typical values ​​are M = 1.5 ... 1.6;

The resonance frequency of the system is the frequency at which the amplitude-frequency characteristic reaches a maximum ymax = y (wp).

Frequency criteria for real regulators can not be uniquely associated with time criteria due to nonlinearities (usually these are nonlinearities of the "constraint" type) and algorithms for eliminating the effect of integral saturation. However, it is approximately possible to establish the following relationships between the criteria in the frequency and time domains:

The frequency of the maximum transfer characteristic of a closed system approximately corresponds to the period of damped oscillations of the response to the stepped input action - s;

The slower the oscillations decay, the greater the oscillation index M.

Selection of controller parameters. In the general theory of automatic control, the structure of the regulator is selected based on the model of the control object. In this case, more complex control objects are associated with more complex controllers. In our case, the regulator structure has already been set-we are considering the PID controller. This structure is very simple, so the PID controller can not always give good quality control, although in the vast majority of applications in the industry PID controllers are used.

Similar documents

    Types and use of sensors for automatic control of the regime parameters of technological processes of chemical production. The principle of operation of the measured sensors, temperature regulators, modular switches. Means of protection of electrical installations.

    thesis, added on 04/26/2014

    Acquaintance with the stages of calculating the settings of typical regulators in a single-loop automatic response system. Features of the choice of the type of industrial controller. Methods of constructing a region of stability in the plane of tuning parameters of the regulator.

    thesis, added on 06/17/2013

    Analysis of the properties of the control object, typical regulators and selection of the type of regulator. Calculation of the optimal parameters of the regulator settings. Dependence of the regulating effect on the deviation of the regulated quantity. Integral and proportional regulators.

    term paper, added on 02/11/2014

    Designing a device that measures the temperature in the room. Selection of temperature sensor, microcontroller and debug board. Study the operation of the built-in temperature sensor. Software development. Functional organization of the program.

    term paper, added on 12/26/2013

    Designing a model of a motor with calculated parameters in a Simulink environment. Modeling of the engine with different loads (disturbing moment). Calculation of parameters and optimal regulators and quality indicators for a number of characteristics.

    course work, added 24.06.2012

    Calculation of the complex frequency characteristic of the object in the required frequency range. Determination of the stability margin of a closed automatic control system. Evaluation of the quality of management when using PI and PID regulators and choosing the best and them.

    course work, added 12/04/2014

    Accelerating characteristic of the object of regulation and determination of parameters, characterizing the inertial properties of the object. Calculation of the adjustment parameters of the regulators for the amplitude-phase characteristic of the control object. Calculation of ATS quality indicators.

    course work, added on 10/22/2012

    Synthesis of the proportional-integral-differential controller, which provides for the closed system the indicators of accuracy and quality of control. Amplitude-frequency characteristic, dynamic analysis and transient process of the corrected system.

    term paper, added on 08/06/2013

    Calculation of the PI controller settings for a second-order object. Analytic calculation and implementation of the program in the MatLab environment, which defines the parameters of the regulator and the transient process. Criteria for the quality of the transient process of a closed system.

    laboratory work, added on 09/29/2016

    Classification of electromagnetic suspensions. Construction of the mathematical model of the stand. Software implementation of a proportional-integral-differential controller. Description of the microcontroller ATmega 328 and the Arduino board. Assembling and putting the stand into operation.

Lecture 30.Realization of PID controller and digital filtering in controllers

Microprocessor controllers allow the implementation of both discrete and analog regulators, as well as non-linear and self-adjusting regulators. The main problem of digital control is to find the appropriate controller structure and its parameters. The software implementation of control algorithms for these parameters is usually a relatively simple task.

Each controller must also include a means of protection that prevent dangerous development of the process under the influence of the controller in emergency situations.

Many TPs are characterized by several input and output parameters. Often internal communications and the interaction of the corresponding signals are not of fundamental importance, and the process can be controlled with a set of simple controls, with each loop being used in direct digital control systems.

Linear regulators with one input / output can be presented in a generalized form

where uIs the controller output (control variable), u from  Is the set value, and the- output signal of the process (controlled variable). Parameter pis the order of the regulator.

A conventional PID controller can be considered as a special case of a generalized discrete p= 2.

Consider a regulator consisting of two parts: a feedback loop (feedback) G FB (s), which runs the error E , and the feedforward contour G FF (s), which controls the changes in the control action and adds a correction term to the control signal, so that the system responds more quickly to changes in the task. For this regulator, the control action U (s ) is the sum of two signals

This expression can be rewritten in the form

where U F 1 (s) - a pre-emptive signal by the reference value (specifying the effect), a U F 2 (s) Is the feedback signal.


Fig.30.1.The regulator containing the pre-control loop by reference value (reference) and the output feedback loopa

The controller has two input signals U c (s) and Y(s) and, therefore, can be described by two transfer functions G F 1 (s) and G R (s).


Since the regulator with PF (30.3) has at its expense G F 1 (s) more adjustable coefficients than a conventional regulator, then a closed CS has better characteristics.

The position of the poles of the feedback system can be changed using the controller G R (s), and the anticipatory regulator G F 1 (s) adds new zeros to the system. Therefore, the SS can respond quickly to changes in the reference signal, if G F 1 (s) is selected correctly.


Fig.30.2. Structure of a linear controller with proactive control and feedback

Thanks to the use of such a controller, it is possible to create high-precision (servo) SU electric drives, robots or machine tools. It is important for them that the reaction to the output value of the process be fast and accurate for any changes in the task.

If the numerator and denominator of the PF G R (s), and G F 1 (s) in (23.3) is expressed by polynomials in s , then the description of the regulator after the transformations can be represented in the following form

g



de

r i ,s i ,t i    parameters of PF polynomials, s   the Laplace operator.

The controller corresponding to equation (30.4) can be represented as a general controller (generalcontroller)

The FF process can be expressed as follows


Fig.30.3. Structure of a linear regulator with proactive control and feedback in the form of a FF

If R(s),S(s) and T(s) have a sufficiently high order, i.e., a sufficient number of "tuning knobs", the FS of a closed system can be varied over a wide range. Regulator order pmust be the same as the original process. So, choosing R(s) and S(s), we can arbitrarily change the denominator of the FS of a closed system. Theoretically this means that the poles of a closed system can be moved to any place in the complex plane. (In practice, the maximum amplitude and rate of change in the control signal limit the freedom of movement of the poles.)

As a result, an unstable system having a pole with a positive real part can be stabilized with the aid of a CS.

30.1. Implementing the PID controller

First of all, we need to develop a discrete model of the regulator and determine the appropriate sample rate. The amplitude of the controller output value must be between the minimum and maximum allowable values. Often it is necessary to limit not only the output signal, but also the rate of its change due to the physical capabilities of the MI and preventing their excessive wear.

Changing parameter settings and switching from automatic operation to manual or other changes in operating conditions should not lead to disturbances in the regulated process.

Regulators can be created by analog technology based on operational amplifiers or as digital devices based on microprocessors. At the same time, they have almost the same appearance - a small rugged housing that allows installation in an industrial environment.

Although digital technology has many advantages, an analog approach is the basis for digital solutions. The advantages of digital controllers include the ability to connect them with communication channels to each other, which allows for data exchange and remote control. We are interested in programs for digital PID controller

Discrete PID controller model . It is necessary for the software implementation of an analog regulator. If a regulator is projected on the basis of an analog description and then its discrete model is constructed, for sufficiently small sampling intervals, the time derivatives are replaced by finite differences, and integration by summation. The process output error is calculated for each sample

   e(k)  = u c (k) y(k) .

The sampling interval t s  is assumed constant, and any changes in the signal that could come up during the sampling interval are not taken into account.

There are two types of PID controller algorithm - positional and incremental

Positional algorithm of PID controller. In the positional algorithm ( position form), the output signal is the absolute value of the control variable MI. The discrete PID controller has the form

u(k)  = u 0    + u P (k)  + u I (k)  + u D (k).

The sampling interval ts is assumed to be constant, and any changes in the signal that could come up during the sampling interval are not taken into account.

Even with zero control error, the output signal is non-zero and is determined by the offset u 0 .

The proportional part of the regulator has the form

u P (k)  = K e(k).

The integral part is approximated by finite differences

u I (k) = u I (k1) + K (t s / T i) ∙ e(k)= u I (k1) + K a e(k).

The value of the second term for small t s and large T i  can become very small, so you need to ensure the necessary accuracy of its machine representation.

The differential part of the PID controller is approximated by the difference back

u D (k) =b u D (k1)K (T d / t s) ∙ (1b)∙ [y(k)y(k1)],


Value T d / N = T f   Is the normalized (in Ntimes) the filter time constant in approximation of the differential component of the control law by an aperiodic link of the first order. Number Nis taken in the range from 5 to 10. The value bis in the range from 0 to 1.

Algorithm of increments. It calculates only the change in its output signal. Incremental algorithm ( incremental form) The PID controller is useful when the MI is a kind of integrator, for example, a stepper motor. Another example of such an IM is a valve whose opening and closing is controlled by pulses and which maintains its position in the absence of input signals.

In the increment algorithm, only changes in the control output signal from the time point k1) until the moment k. The algorithm of the regulator is written in the form

Δ u I (k) = u (k)u (k1) =? u P (k) + Δ u I (k) + Δ u D (k).

The proportional part of the increment algorithm is calculated from equation

Δ u P (k) = u P (k)u P (k1) =K [e(k)e(k1)] = K Δ e(k).

Integral part - from equation

Δ u I (k) = u I (k)u I (k1) =K a e(k).

Differential part - from equation

Δ u D (k) =b Δ u D (k1)K (T d / t s)∙(1b)∙ y(k)Δ y(k1),

Δ y(k) =y(k)y(k1).

The algorithm is very simple. For its application, as a rule, it is enough to perform operations with a floating point of ordinary accuracy. It does not cause problems due to saturation. When switching from manual mode to an automatic controller that calculates increments, it does not require assigning an initial value to the control signal ( u  0 in the positional algorithm).

The MI can be brought to the desired position during the start-up, both with manual and automatic control. A small drawback of the increment algorithm is the need to take into account the integral component.

The reference value is reduced in both the proportional and differential parts, starting with the second sample after its change. Therefore, if a regulator is used based on an incremental algorithm without an integral component, drift of the controlled process from the reference value is possible.

Determining the frequency of sampling in CS . It is more an art than a science. Too low sampling frequency reduces the effectiveness of control, especially the ability of the SS to compensate for disturbances. But if the sampling interval exceeds the reaction time of the process, the disturbance can affect the process and disappear before the regulator begins corrective action. Therefore, when determining the sampling frequency, it is important to take into account both the dynamics of the process and the characteristics of the disturbance.

On the other hand, too high a sample rate leads to increased computer load and wear of the IM.

Thus, the determination of the sampling frequency is a compromise between the requirements of the dynamics of the process and the available performance of computers and technological mechanisms. Standard digital controllers that operate with a small number of control loops (from 8 to 16) use a fixed sampling frequency on the order of fractions of a second.

The sampling rate is affected by the signal-to-noise ratio. For small values ​​of this ratio, that is, for large noise, a high sampling frequency should be avoided, because the deviations in the measurement signal are more likely associated with high-frequency noise, rather than with real changes in the physical process.

It is considered that the adequate sample rate is related to the bandwidth or the time of establishment of the closed loop. The empirical rules recommend that the sampling frequency be b-10 times higher than the bandwidth, or that the establishment time correspond to at least five sampling intervals.

If additional phase lag is permissible by 5-15 °, the following rule is valid

t s · ω from = 0,15 – 0,5 ,

where ω from   - bandwidth of the system (at a level of 3 dB), t s   - quantization period, or sampling interval. (This approach is used in many industrial digital single- and multi-loop PID regulators.)

Control signal limitation . To limit the control signal, there are two prerequisites:

1) the amplitude of the output signal can not exceed the range of the DAC at the output of the computer;

2) the operating range of the IM is also always limited. The valve does not open more than 100%; The motor can not be supplied with unlimited current and voltage.

Therefore, the control algorithm must include some function that limits the output signal. In some cases, a dead band must be defined, or a deadband.

If a regulator with an incremental algorithm is used, the changes in the control signal can be so small that the MI can not process them. If the control signal is sufficient to act on the MI, it is advisable to avoid small but frequent trips that can accelerate its wear.

A simple solution is to sum the small changes in the control variable and output the control signal of the IM only after a certain threshold value is exceeded. The introduction of the deadband makes sense only if it exceeds the resolution of the DAC at the computer output

Prevention of integral saturation. The integralwindup effect is observed when the PI or PID controller has to compensate for a long time an error outside the range of the controlled variable. Since the output of the regulator is limited, it is difficult to reduce the error to zero.

If the control error persists for a long time, the value of the integral component of the PID controller becomes very large. This happens if the control signal is limited enough that the calculated output of the regulator is different from the actual output of the IM.

Since the integral part becomes zero only a short time after the error value has changed the sign, the integral saturation can lead to a large overshoot. Integral saturation is the result of non-linearities in the system associated with limiting the output control signal, and can never be observed in a linear system.

Limit the influence of the integral part by conditional integration. While the error is large enough, its integral part is not required for the formation of a control signal, but for controlling a sufficiently proportional part.

The integral part used to eliminate stationary errors is needed only in cases where the error is relatively small. In conditional integration this component is taken into account in the final signal only if the error does not exceed a certain threshold value. At large errors, the PI controller acts as a P-regulator. Selecting a threshold for activating the integral term is not an easy task. In analog regulators, conditional integration is performed using a Zener diode (limiter), which is connected in parallel with the capacitor in the feedback loop of the operational amplifier in the integrator block of the regulator. This scheme limits the contribution of the integral signal.

In digital PID controllers, it is easier to avoid integral saturation. The integral part is adjusted at each sampling interval so that the output of the regulator does not exceed a certain limit.

The control signal is first calculated using the PI controller algorithm, and then it is checked whether it exceeds the set limits:

u = u min , if u d < u min ;

u = u d , if u min u d < u max ;

u = u max , if u d u max ;

After limiting the output signal, the integral part of the regulator is reset. The following is an example of a PI regulator program with protection against saturation.

While the control signal remains within the set limits, the last operator in the text of the program does not affect the integral part of the regulator.

(* initialization *) c1: = K * taus / Ti;

(* regulator *)

Ipart: = Ipart + c1 * e;

ud: = K * e + Ipart; (* calculation of the control signal *)

if (ud

else if (ud< umax) then u:= ud

Ipart: = u-K * e; (* "antisaturation" correction of the integral part *)

An illustration of the integral saturation problem for a positioning drive with a PI controller is shown in Fig. 30.4.

Smooth switching of operating modes. When switching from manual to automatic mode, the controller output may change abruptly, even if the control error is zero. The reason is that the integral term in the controller algorithm is not always zero. A regulator is a dynamic system, and the integral part is one of the elements of the internal state that should be known when the control mode is changed.

A jump in the output value of the regulator can be prevented, and a mode change in this case is called a smooth transition (bumplesstransfer).

There are two possible situations: a) transition from manual to automatic mode or vice versa; b) changing the parameters of the regulator.

A smooth transition in case a) for an analog regulator is achieved by bringing the process manually to a state in which the measured value of the output quantity is equal to the reference value.

The process is maintained in this state until the output of the regulator is zero. In this case, the integral part is also zero, and since the error is zero, a smooth transition is achieved. This procedure is also suitable for digital controllers.

Another method is to slowly bring the reference value to the desired final value.

First, the reference value is set equal to the current measurement, and then gradually adjusted manually to the desired value.

If this procedure is performed rather slowly, the integral part of the regulator signal remains so small that a smooth transition is ensured. The disadvantage of this method is that it requires a sufficiently long time, which depends on the nature of the process.

Limitation of the rate of change of the control signal . In many CS, it is necessary to limit both the amplitude and the rate of change of the control signal. To do this, use special protection schemes that are connected after the manual input channel of the reference value u c (t) and transmit the filtered signal to the regulator u L (t), as shown in Fig. 30.5.

As a result, the process "sees" this control signal instead of being entered manually. This method is usually used in the regulation of electric drives. The rate of change of the signal can be limited by a simple feedback loop.

Manual control signal u c (t), serving as a reference, is compared with an admissible control signal u L (t). First, their difference is limited by ueminand uemoh.

Then the obtained value is integrated, and the integral is approximated by a finite sum.

The algorithm for limiting the rate of change is as follows:

if (uε< uemin) then uelim:= uemin (*функция ограничения*) else if (ue < uemax) then uelim:= ue

else uelim: = uemax;

uL = uL_old + taus * uelim;

Computational features of the PID controller algorithm. The digital implementation of the PID controller due to the sequential nature of the calculations leads to delays that are not present in analog technology. In addition, some restrictions (saturation protection and smooth transition algorithms) require that the controller output and MI trigger occur simultaneously. Therefore, computational delays must be minimized. To do this, some elements of the digital controller are calculated until the time of sampling.

For a regulator with saturation protection, the integral part can be calculated in advance using the forward differences

u I (k +1) = u I (k)  + c  1 ·   e (k) + c  2 · [u (k) - u d (k) ] ,

where u - limited value u d ;

T t   - coefficient, which is called the tracking time constant.

The differential part looks like

c 3 = (1 b) · K· T d /t s ;

x (k -1) = b· u D (k -1)  + c  3 · y (k -1).

Variable xcan be updated immediately after the time point k

x (k) = b· x(k -1)  + c  3 · (1 b) · y (k).

In this way, u D (k + 1) can be calculated from (24.2) as soon as the measurement result is obtained y(k + 1).

Optimization of computations is necessary, since the digital controller sometimes has to execute several thousand control operations per second. Under these conditions, it is important that some coefficients are available immediately, rather than being calculated each time anew. In addition, industrial controllers do not have the fastest processors ( i386, 486). Therefore, the order and type of calculations greatly affect the speed of control operations.

PID controller algorithm . An example of a PID program in Pascal. Calculating the coefficients c 1 ,c  2 and c  3 it is necessary to make only in case of changing the parameters of the regulator K, T i , T d   and T f  . The controller algorithm is executed at the time of each sample. The program has protection against saturation integral component.

(* Preliminary calculation of the coefficients *)

c1: = K * taus / Ti; (* equation 23.7 *)

c2: = taus / Tt; (* equation 24.1 *)

beta: = Td / (Td + taus * N); (* equation 24.1 *)

c3: = K * Td * (l-beta) / taus; (* equation 24.2 *)

c4: = c3 * (1 - beta); (* local constant *)

(* Management Algorithm *)

uc: = ADinput (ch1); (* reference input, analog input *)

y: = AD_input (ch2); (* measurement input, analog input *)

e: = uc-y; (* calculation of control error *)

ppart: = K * e; (* proportional part *)

dpart: = x - (c3 * y); (* the differential part, *)

ud: = uO + ppart + ipart + dpart; (* controller output before signal limit *) if (ud