Compensate for Disturbances in Spring-Mass-Damper System
This example shows how to compensate for disturbances in a spring-mass-damper system using the Disturbance Compensator block.
Spring-Mass-Damper Model
The spring-mass-damper system consists of two carts of mass and , connected to each other through a spring with stiffness coefficient and a damper with damping coefficient [1].
Define the values of these physical constants in the model.
k = 1.2; m1 = 1.5; m2 = 1.5; c = 1.2;
You can represent this system as a state-space model with four states .
Here:
and are the positions of mass 1 and mass 2.
and are the velocities of mass 1 and mass 2.
is the control input acting on mass 1.
is the measured output.
and are the disturbances acting on mass 1 and mass 2.
In this example, set , thus the disturbance and control input come from different channels.
Specify the state-space model for the plant .
Ap = [0, 0, 1, 0; 0, 0, 0, 1; -k/m1, k/m1, -c/m1, c/m1; k/m2, -k/m2, c/m2, -c/m2]; Bu = [0;0;1/m1;0]; Bd = [0;0;0;1/m2]; Cp = [0, 1, 0, 0]; Bp = [Bu,Bd]; Gp = ss(Ap,Bp,Cp,0);
Plant Knowledge for Control Design
You can approximate a mathematical model of the spring-mass-damper system by taking higher-order derivatives of in the dynamics equation until you find an explicit dependence on the input . Here, the approximation is given by , where represents unknown dynamics and disturbances in the system. You cannot approximate these dynamics well with a single or double integrator. Therefore, the Active Disturbance Rejection Control block is not suitable for control design and may not achieve a good performance. In this example, use the Disturbance Compensator block for satisfactory performance.
For controller design, the example considers two levels of plant knowledge.
Minimal knowledge of plant model: , where denotes the unknown dynamics and disturbances of the system model.
Full knowledge of plant model: .
Specify the model information for controller design with minimal plant model.
b = k/(m1*m2); A1 = [0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1; 0, 0, 0, 0]; B1 = [0;0;0;b]; C1 = [1, 0, 0, 0]; sys1 = ss(A1,B1,C1,0);
Specify the model information for controller design with full plant model.
sys2 = ss(Ap,Bu,Cp,0);
Design Controller for Disturbance Compensation
First consider the case where you have full knowledge of plant model. When the variant of Disturbance Compensation
is set to full knowledge
, the Disturbance Compensator block is configured to have these five inports in the model.
Nominal controller
Plant output
Disturbance input matrix
Observer gain matrix
Disturbance compensation gain
Design a nominal state-feedback controller at bandwidth rad/s.
wc = 1;
Specify the pole locations and differences.
dist = 1e-3; % pole location differences p = -[wc,wc+dist,wc+dist*2,wc+dist*3]; % pole locations
To calculate the state-feedback matrix for both plant models, use the place
command.
K2 = place(Ap,-Bu,p); % K2 for full knowledge of plant model K1 = place(A1,-B1,p); % K1 for minimal knowledge of plant model
Design the observer gain matrix at bandwidth rad/s.
Specify the pole locations and spacing, extended model matrices, and use the place
command to obtain the gain matrix.
wo = 5; % observer bandwidth dist = 1e-2; % pole location differences p = -[wo,wo+dist,wo+dist*2,wo+dist*3,wo+dist*4];% pole locations Ae = [Ap,Bd;zeros(1,4),0]; % extended model matrix Ce = [Cp,0]; % extended model matrix L = place(Ae',Ce',p)'; % observer gain matrix
Compute the disturbance compensation gain based on [2]. For discrete-time modeling, you calculate the observer gain and disturbance gain matrices differently [3].
Af = Ap+Bu*K2; Kd = -(Cp/Af*Bu)\(Cp/Af*Bd);
Open the Simulink® model with full knowledge of plant model.
mdl = 'scdSpringMassDamper'; open_system(mdl) level = 2; % for full knowledge of plant model
Simulate the model and view the results.
out = sim(mdl); logsout = out.logsout; y1 = logsout.getElement('y'); y1data = y1.Values.Data(:,:)'; plot(y1.Values.Time,y1data); xlabel('time') ylabel('y') grid on; hold on;
The plot shows that the disturbance is fully rejected within 10 seconds.
Compare Results
For the case where you have minimal knowledge of plant model, the linear relationship holds. The Disturbance Compensator block also lets you automatically computes and using the block parameters. For the nominal control , you computed the state feedback gains at the bandwidth rad/s in the previous section. When the variant of Disturbance Compensation
is set to minimal knowledge
, the Disturbance Compensator block is configured to have two default inports as shown in the model.
Set controller with minimal knowledge. Simulate the model and view the results.
level = 1; % for minimal knowledge of plant model out = sim(mdl); logsout = out.logsout; y2 = logsout.getElement('y'); y2data = y2.Values.Data(:,:)'; plot(y2.Values.Time,y2data); legend('full knowledge','minimal knowledge')
The plot shows that, for this example, more knowledge of plant model leads to better disturbance rejection performance given the same controller and observer bandwidth.
Close the model.
bdclose(mdl)
References
[1] Wie, Bong, and Dennis S. Bernstein. “Benchmark Problems for Robust Control Design.” In 1991 American Control Conference, 1929–30. Boston, MA, USA: IEEE, 1991. https://doi.org/10.23919/ACC.1991.4791727.
[2] Li, Shihua, Jun Yang, Wen-Hua Chen, and Xisong Chen. “Generalized Extended State Observer Based Control for Systems With Mismatched Uncertainties.” IEEE Transactions on Industrial Electronics 59, no. 12 (December 2012): 4792–4802. https://doi.org/10.1109/TIE.2011.2182011.
[3] Zhang, Pengcheng, Jianyu Wang, Yun Cheng, and Shiyu Jiao. “Reduced-Order Generalized Extended State Observer Based Control for Discrete-Time Systems.” In 2022 International Conference on Cyber-Physical Social Intelligence (ICCSI), 670–75. Nanjing, China: IEEE, 2022. https://doi.org/10.1109/ICCSI55536.2022.9970623.
See Also
Extended State Observer | Disturbance Compensator | Active Disturbance Rejection Control