2020-12-28 Matlab automation control-Adrc active disturbance rejection control

Matlab automation control-Adrc active disturbance rejection control

To get a preliminary understanding of ADRC, you can read a literature and a book by Professor Han Jingqing
1. Literature: From PID technology to "Auto disturbance rejection control" technology ("Control Engineering", 2002)
2. Book: Active disturbance rejection Control technology-control technology that estimates and compensates uncertain factors

There are three main parts in ADRC control:

Tracking differentiator, nonlinear state feedback (non-linear combination), extended observer.

image

ADRC features:

Inheriting the essence of the classic PID controller, there is almost no requirement for the mathematical model of the controlled object. On the basis of it, the state observer technology based on modern control theory is introduced, and the anti-interference technology is integrated into the traditional PID control. Finally, a new controller suitable for wide application in engineering practice is designed.

1. Tracking Differentiator (TD)

This is a single-input dual-output module with two functions:

  • Avoid jumps in the input to facilitate real-time tracking of the actual system. Because the traditional pid has a problem, that is, the coexistence of overshoot and rise time when tracking a sudden change signal like a step signal, so our idea is to smooth the input signal, that is, to avoid sudden change.

  • Filter high frequency noise

So output 1 is the processed signal, and the second signal is the differential of output 1. Both outputs 1 and 2 will be used in the next step, which will not be introduced here.

First put out his output renderings, the input is a step signal:

image

Explanation: The blue is the processed step signal, which is obviously much better, not so sudden. Yellow is differential.

TD formula :

image

Simulink simulation model:

image

 

Friendly reminder: Discrete difference equation modeling is the same as continuous system differential equation modeling. First find the output y(k), then find the y(k-1)..., then connect them with unit delay, and finally base on this Connect other things.

hfst function module:

function out = hfst(u1,u2,r,h)

d=r*h;d0=h*d;y=u1+h*u2;a0=sqrt(d*d+8*r*abs(y));a=0;out1=0;if abs(y)>d0    a=u2+(a0-d)/2*sign(y);end
if abs(y)<=d0    a=u2+y/h;end
if abs(a)>d    out1=-r*sign(a);end
if abs(a)<=d    out1=-r*a/d;endout=out1;end

Or, instead of simulink+m as above, the entire td can be directly written in the m script, and the effect has been verified:

function [y1k,y2k] = fcn(u)persistent y1k_1 y2k_1h=0.01;delta=10;if isempty(y1k_1)    y1k_1=0;end
if isempty(y2k_1)    y2k_1=0;end
y1k=y1k_1+h*y2k_1;
% hfst计算内容d=delta*h;d0=h*d;y=y1k_1-u+h*y2k_1;a0=sqrt(d*d+8*delta*abs(y));a=0;out1=0;if abs(y)>d0    a=y2k_1+(a0-d)/2*sign(y);end
if abs(y)<=d0    a=y2k_1+y/h;end
if abs(a)>d    out1=-delta*sign(a);end
if abs(a)<=d    out1=-delta*a/d;endout=out1;% 更新变量y2k=y2k_1+h*out;
y1k_1=y1k;y2k_1=y2k;
end

Verification effect:

t = 0:0.01:2;u = zeros(length(t), 1);u (t >=1) = 1;figureplot(t,u)y1k = zeros(length(t), 1);y2k = zeros(length(t), 1);for i = 1:length(t)    [y1k(i),y2k(i)] = fcn(u(i));endfigureplot(t,y1k)figureplot(t,y2k)

Note: TD model involves two tuning parameters: δ and h, h is the sampling period, delta determines the tracking speed (the larger the δ, the closer the filtered output is to the input), the general simulation model r can be as large as possible, in 100~ The range of 500 is basically the same, even if the effect is large, there will be basically no big improvement. My delta is 50, h=0.001.


Two, non-linear combination

This part corresponds to the nonlinear combination module in the first picture. This module is a dual-input single-output. The input is two errors, which are the difference between the command signal and the command signal differential. The reference command signal and the reference command signal are both differential. Produced by TD.

The traditional PID or PD control is the linear weighted sum of proportional, integral, and differential, but this linear combination is not the best. Later, it was found that the nonlinear combination of the three has a better effect. The most commonly used is the non-linear combination of pd form:

image

There are three tuning parameters involved: β1, β2, δ, and δ are integer multiples of h.

Compare traditional PID and nonlinear PID

sys = tf([133],[1,25,0])dsys = c2d(sys,0.001,'z');[num,den]=tfdata(dsys,'v');

image

effect:

image

Non-linear pd control:

image

Function module code:

function y =nonlinear_pd(e1,e2)alfa1=0.75;alfa2=1.5;delta=0.002;beta1=150;beta2=1;fal1=1;fal2=1;
if abs(e1)<=delta    fal1=e1/(delta^(1-alfa1));end
if abs(e1)>delta    fal1=(abs(e1))^(alfa1)*sign(e1);end
if abs(e2)<=delta    fal2=e2/(delta^(1-alfa2));end
if abs(e2)>delta    fal2=(abs(e2))^(alfa2)*sign(e2);end
y=beta1*fal1+beta2*fal2;end

effect:

image

It can be seen that the effect is much better, so the nonlinear pid has an effect! ! ! ! ! !

Three, ESO expansion observer

ESO is a dual-input single-output module. The input values ​​are the output of the object and the control input of the object. See the first figure. There are three outputs, which are the estimated value of the object output and the first derivative of the estimated value of the object output. , The second derivative of the estimated value of the object output. The estimated value of the object output and the first derivative of the estimated value of the object output will be fed back to the initial tracking differentiator (TD), and the second derivative of the estimated value of the object output will be fed back to the output of the nonlinear combination for Make up for disturbances.

Generally, the observer only observes the state of the system, only the output and the derivative (speed) of the output. But here the derivative (acceleration) of the output derivative is also observed, here is the so-called disturbance (ie w in the first figure), and the disturbance is observed. The state quantity of the observer is also expanded by one dimension, so it is called an expanded observer.

The formula of ESO is shown in the figure below:

image

Simulink fcn model:

image

The code inside is as follows:

function [z1_k,z2_k,z3_k] = ESO(yk,uk)%%参数初始化persistent  z1_k_1 z2_k_1 z3_k_1bata01=30;beta02=300;beta03=1000;b=5;h=0.001;alfa1=0.25;alfa2=0.5;delta=0.002;fal1=1;fal2=1;if isempty(z1_k_1)    z1_k_1=0;endif isempty(z2_k_1)    z2_k_1=0;endif isempty(z3_k_1)    z3_k_1=0;end
e1=z1_k_1-yk;z1_k=z1_k_1+h*z2_k_1-bata01*e1;z1_k_1=z1_k; %%迭代更新z1_k_1
%%计算fal函数if abs(e1)<=delta    fal1=e1/(delta^(1-alfa1));endif abs(e1)>delta    fal1=(abs(e1))^(alfa1)*sign(e1);endif abs(e1)<=delta    fal2=e1/(delta^(1-alfa2));endif abs(e1)>delta    fal2=(abs(e1))^(alfa2)*sign(e1);end
z2_k=z2_k_1+h*(z3_k_1+b*uk)-beta02*fal1;z2_k_1=z2_k;%%迭代更新z2_k_1
z3_k=z3_k_1-h*beta03*fal2;z3_k_1=z3_k;%%迭代更新z3_k_1
end

But be careful: because b*u has been added to the ESO formula, b0 in the first picture is not needed when building the final model, that is, you don’t need to multiply b0, and directly enter the compensated u into ESO. In the same way, if you want to display the scale factor b0 in the similink model, then the formula in ESO should be changed to:z2_k=z2_k_1+h*(z3_k_1-beta02*fal1+uk);即去掉最后的uk前的系数b

Four, complete ADRC

This section will combine the previous ones to form a complete ADRC, which is the form in the first picture. The built structure is as follows:

image

Points to note:
1. Because this is a discrete model, ensure that the sampling time of all modules is the same
. 2. Pay attention to check the positive and negative of all the summation modules.
3. Pay attention to the black attention part in the third section above

Start the simulation, an error is reported:
image

The translation means the reason for the existence of algebraic rings

This problem is very well understood. We know that when we solve the feedback loop, the initial value of the feedback is o, that is, the order of the feedback system is: we first calculate the output of the main circuit according to the input of the main circuit (ie Get the input of the feedback circuit), calculate the output of the feedback circuit (that is, the feedback value) according to the input of the feedback circuit, and then proceed to the next cycle. In simulink, he is not like the m script we wrote before (we write the script from the main road). He does not know whether to calculate the main road or the feedback path first, so we need to tell him that the solution is to Add a unit delay to the output of the feedback circuit, which means you are told to wait for the feedback circuit.

In fact, we can also understand the algebraic loop in this way. It is understood that the feedback amount has no initial value in the initial state. Our previous control models such as pid, etc., our feedback feedback amount will have an initial value, and the ESO of this model The output as the feedback quantity has no initial value, so the reason for his error can be understood as the feedback quantity has no initial value, so we set an initial value for the feedback quantity, and we can use the memory module (the function of this module is to have When input, output = input. When there is no input, the output remains in the original state, and the output changes when the input changes, otherwise the output remains unchanged), set an initial value in the memory module so that the feedback amount has an initial value. The unit delay module we used above is a memory module, and the two are originally the same. So the unit delay module above can also be understood in this way.

The modified simulink is:

image

Or (the two are equivalent):

image

After the simulation, the results are correct and the results are satisfactory:

image

The yellow is the initial step signal, the red is the signal after TD, and the blue is the control output.

Guess you like

Origin blog.csdn.net/qingfengxd1/article/details/111830762