- Your problem statement.
- Your solution approach to the above problem.
- Details about the issue you are encountering.
Why the controller block diagram is not working (while tracking the reference and water level in tank 2 at specific level)?
1 次查看(过去 30 天)
显示 更早的评论
Please help, why the controller (u) is not working?
1 个评论
Suvansh Arora
2022-11-30
In order to understand this better, please send the following information:
回答(1 个)
Sam Chak
2022-11-30
编辑:Sam Chak
2022-11-30
It seems that your equation for u causes the level of Tank #2
to dip below 0, thus term sqrt(x(2)) returns an error message related to the complex number. In the attached Simulink model, your original u is disabled and two lines are added in the "Level Controller" Function Block:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213388/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213393/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213398/image.png)
where
and
are the reference levels of Tank #1 and Tank #2, respectively.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213403/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213408/image.png)
Note: I didn't know how you derived your original equation for u. But from your scripts, the Dual Tank Liquid Level System is given by
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213413/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213453/image.png)
and you want to regulate the level of Tank #2 to
. Since
can only be affected by
, I designed the reference level of Tank #1,
so that
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213418/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213423/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213428/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213403/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213438/image.png)
Then, I backstepped the process and designed the control equation for u so that
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213448/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1213443/image.png)
5 个评论
Sam Chak
2022-12-6
If you find the MATLAB code and math explanation helpful, please consider accepting ✔ and voting 👍 the Answer. Thanks a bunch! 🙏
Back to your query, I actually used basic algebra manipulation and the exponential decay principle. No difficult math!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221427/image.png)
I started from your original error definition, where you want to track the tank #2 level ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221432/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221432/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221437/image.png)
Taking the time derivative of ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221442/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221442/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221447/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221452/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221457/image.png)
Making substitution to obtain the error dynamics
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221462/image.png)
Following the principle that guarantees exponential decay
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221467/image.png)
where
,
is chosen as the indirect manipulated variable because we can directly manipulate
in
dynamics through the direct manipulated variable u.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221472/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221477/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221482/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221487/image.png)
Thus, we can equate both equations where ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221492/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221492/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221497/image.png)
and solve for ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221502/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221502/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221507/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221512/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221517/image.png)
Making substitution for
to obtain the reference
where
must track
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221522/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221527/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221532/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221537/image.png)
Similarly, repeat the design steps to obtain for u:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221542/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221547/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221552/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221557/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221562/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221567/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221572/image.png)
Here, because I find it a little mathematical tedious to obtain the time derivative for
, I let
, and thus it is reduced to
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221577/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221582/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221587/image.png)
By the way, how did you derive the original equation for u? Can you show me?
% -------------------------------------------
Afterthoughts: I think you can possibly design based on
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221592/image.png)
which leads to
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221597/image.png)
and
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221602/image.png)
leads to
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1221607/image.png)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Computations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!