This post was last edited by hbwhhj on 2016-8-5 at 14:52. A PID controller consists of a proportional element (P), an integral element (I), and a derivative element (D); a PI controller does not have a derivative element. The difficulty in PID control lies not in programming, but in tuning the controller parameters. The key to parameter tuning is to correctly understand the physical meaning of each parameter. The principle of PID control can be understood by considering how a person manually controls the furnace temperature. No advanced mathematical knowledge is required to read this article. 1. Proportional control: Experienced operators can manually control the temperature of electric furnaces, achieving very good control quality. There are many similarities between PID control and manual control strategies. Below is an explanation of how operators can use the concept of proportional control to manually regulate the temperature of an electric heating furnace. Assume that a thermocouple is used to detect the furnace temperature, with a digital instrument displaying the temperature value. During the control process, the operator reads the furnace temperature with their eyes and compares it with the set value for the furnace temperature, thereby obtaining the temperature error. Then, manually adjust the potentiometer to control the heating current, keeping the furnace temperature around the set value. The operator knows the approximate position of the potentiometer when the furnace temperature is stable at the set value (which we call position L), and adjusts the angle of the potentiometer that controls the heating current based on the temperature error at that time. When the furnace temperature is below the set value, the error is positive; the angle of the potentiometer is increased clockwise from position L in order to raise the heating current. When the furnace temperature is higher than the set value, the error is negative; in this case, the rotation angle of the potentiometer is decreased counterclockwise relative to position L, and the difference between this rotation angle and position L is made proportional to the error. The aforementioned control strategy is proportional control, that is, the proportional part of the output from the PID controller is proportional to the error. There are various types of delays in the closed loop. For example, after adjusting the potentiometer angle, there is a significant time delay until the temperature rises to the steady-state value corresponding to the new angle. Due to the presence of delay factors, the effect of adjusting the potentiometer angle cannot be seen immediately; therefore, the main reason for the difficulty in controlling a closed-loop system is the delay present in the system. If the proportional coefficient in proportional control is too small, that is, if the difference between the angle of the potentiometer after adjustment and the position L is too small, the degree of adjustment is insufficient, resulting in a slow change in the system’s output and an excessively long total time required for adjustment. If the proportionality coefficient is too high, that is, if the difference between the potentiometer’s angle after adjustment and the position L is excessive, the adjustment force will be too strong, resulting in over-adjustment; this can even cause the temperature to fluctuate up and down, oscillating back and forth. Increasing the proportional coefficient makes the system more responsive, accelerates the adjustment speed, and can reduce the steady-state error. However, an excessively large proportional coefficient increases overshoot, the number of oscillations, and the settling time; it deteriorates the dynamic performance, and an overly large proportional coefficient can even render the closed-loop system unstable. Simple proportional control finds it difficult to achieve the optimal adjustment and completely eliminate errors. 2. Integral control: In a PID controller, the integral term corresponds to the area enclosed by the error curve and the coordinate axes in Figure 1 (the gray area in the figure). The PID control program is executed periodically, and the period of execution is called the sampling period. Computer programs use the sum of the areas of the rectangles in Figure 1 to approximate the exact integral, where TS in the figure represents the sampling period. Figure 1 Schematic diagram of integral operation. In each PID calculation, a small amount proportional to the current error value ev(n) is added to the previous integral value. When the error is negative, the increment of the integral is negative. When adjusting the temperature manually, integral control is equivalent to periodically fine-tuning the angle of the potentiometer based on the current error value; the amount by which the angle is adjusted each time is proportional to the error value at that moment. When the temperature is below the set value, the error is positive; the integral term increases, causing the heating current to rise gradually. Conversely, the integral term decreases. Therefore, as long as the error is not zero, the output of the controller will keep changing due to integration. The “general direction” of integral control is correct; the integral term serves to reduce errors. It is only when the system reaches a stable state – at which point the error is consistently zero, both the proportional and derivative terms are zero – that the integral term ceases to change, and it takes on the exact value of the controller output required in the steady state, corresponding to the position L of the potentiometer knob in the aforementioned temperature control system. Therefore, the role of the integral term is to eliminate steady-state error and improve control accuracy; an integral action is generally necessary. The integral portion of the PID controller output is proportional to the integral of the error. Since the integration time TI is in the denominator of the integration term, the smaller TI is, the faster the integration term changes, and the stronger the integrating effect. 3. PI control: The integral term in the controller’s output is proportional to both the current error value and the cumulative sum of past error values; as a result, the integral action itself has severe lag characteristics, which is detrimental to the stability of the system. If the coefficient of the integral term is not set properly, its negative effects are difficult to correct quickly through the integral operation itself. The proportional term has no delay; as soon as an error occurs, the proportional part takes effect immediately. Therefore, integration is rarely used alone; it is generally combined with proportion and derivative to form PI or PID controllers. PI and PID controllers overcome the drawback of steady-state error associated with pure proportional control, while also avoiding the issues of slow response and poor dynamic performance associated with pure integral control; for these reasons they are widely used. If the controller has an integral action (for example, using PI or PID control), the integral term can eliminate the steady-state error caused by step inputs, allowing the proportional coefficient to be set at a lower value. If the integration effect is too strong (i.e., the integration time is too short), it is equivalent to adjusting the potentiometer’s angle by large amounts each time; this cumulative effect reduces the dynamic performance of the system, increases overshoot, and may even render the system unstable. If the integral action is too weak (i.e., the integration time is too long), the speed at which the steady-state error is eliminated is too slow; therefore, the value of the integration time should be set to an appropriate level. 4. Differential effect: The differential of an error is the rate of change of that error; the faster the error changes, the larger the absolute value of its differential. When the error increases, its derivative is positive ; As the error decreases, its derivative is negative. The differential part of the controller’s output is proportional to the derivative of the error, reflecting the trend in the change of the controlled quantity. Experienced operators, when the temperature rises too quickly but has not yet reached the set value, can anticipate that the temperature will exceed the set value and cause overshoot by observing the trend of temperature changes. Thus, the rotation angle of the potentiometer is adjusted to reduce the heating current in advance. This is similar to when soldiers shoot at moving targets in the distance; they need to account for the time it takes for the bullet to travel, which requires a certain amount of lead time. Figure 2 Step response curve. In Figure 2, c(∞) represents the steady-state value of the controlled variable c(t), or the desired value of that variable; the error e(t) is given by e(t) = c(∞) – c(t). In the rising phase of the startup process in Figure 2, at that time, the controlled variable has not yet exceeded its steady-state value. However, as the error e(t) continues to decrease, the derivative of the error and the derivative of the controller’s output become negative, which reduces the controller’s output. This is equivalent to applying a braking effect in advance to prevent the controlled quantity from rising, thereby reducing the overshoot. Therefore, differential control has leading and predictive characteristics, enabling control actions to be taken in advance before overshoot occurs. The fundamental reason for the oscillations or instability in closed-loop control systems is the presence of significant lag. Since the differential term can predict the trend of error variation, this “leading” effect can offset the influence of lagging factors. Appropriate differential control can reduce overshoot and increase system stability. For controlled objects with significant lag characteristics, if PI control does not yield satisfactory results, it is possible to incorporate differential control in order to improve the dynamic behavior of the system during regulation. If the differentiation time is set to 0, the differentiation part will not function. The differentiation time is proportional to the strength of the differentiating effect; the greater the differentiation time, the stronger the effect. If the differentiation time is too large, \"burrs\" may appear on the response curve when the error changes rapidly. The drawback of derivative control is its sensitivity to disturbance noise, which reduces the system’s ability to suppress disturbances. To this end, an inertial filtering element can be added to the differential part. 5. Sampling period: The PID control program is executed periodically, and the period of execution is called the sampling period. The smaller the sampling period, the better the sampled values can reflect the changes in the analog quantity. However, if it is too small, it will increase the computational load on the CPU; the difference between two consecutive samples remains almost unchanged, which causes the differential term in the output of the PID controller to approach zero. Therefore, it is also not advisable to choose a sampling period that is too short. It should be ensured that when the measured quantity changes rapidly (such as during the rising phase of startup), there are a sufficient number of sampling points, so that important information contained in the measured analog values is not lost due to too few sampling points. 6. Method of adjusting PID parameters: When tuning the parameters of a PID controller, it is possible to adjust these parameters through experimental methods, based on the qualitative relationship between the controller’s parameters and the system’s dynamic and steady-state performance. Experienced debuggers can generally achieve relatively satisfactory results more quickly. The most important issue during debugging is, when the system performance is not satisfactory, knowing which parameter to adjust and whether that parameter should be increased or decreased. To reduce the number of parameters that need to be tuned, a PI controller can be used first. To ensure system safety, relatively conservative parameters should be set at the beginning of debugging; for example, the proportional coefficient should not be too large, and the integral time should not be too small, so as to prevent abnormal situations such as system instability or excessive overshoot. By providing a step input signal, information on system performance can be obtained from the output waveform of the controlled variable, such as overshoot and settling time. The PID parameters should be adjusted repeatedly based on the relationship between them and system performance. If the overshoot of the step response is too large, and it takes multiple oscillations to stabilize or fails to stabilize at all, the proportional coefficient should be reduced and the integration time increased. If the step response has no overshoot, but the controlled variable rises too slowly and the transition time is too long, the parameters should be adjusted in the opposite direction. If the rate of error reduction is slow, the integration time can be appropriately reduced to enhance the integrating effect. By repeatedly adjusting the proportional coefficient and integral time, if the overshoot remains high, differential control can be added; the differential time should be increased gradually, while the parameters of the proportional, integral, and differential components of the controller are adjusted repeatedly. In summary, tuning PID parameters is a comprehensive process in which various parameters influence one another; multiple attempts during the actual tuning process are very important and essential.