File Exchange Pick of the Week

Our best user submissions

Simulink Dual Gravity Drained Tank

Will's pick this week is Simulink Dual Gravity Drained Tank by John Hedengren.

How often do you find a File Exchange submission accompanied by a video tutorial? I've only explored a small fraction of all the content on the File Exchange, but in my limited sampling, I have to say that this is the first contribution with such an achievement. The model is simple enough: a prediction of the water level of two tanks as they are filled and drained. But as John notes in his video, the model doesn't jump up and scream "I'm clearly two draining tanks!" when look you at it.

Can you tell that there are two tanks modeled here?

The video explains how the problem is configured and what is being calculated in a way that even someone outside the field of chemical engineering can appreciate. He also includes a clever animation of the process. As the model simulates, a MATLAB figure displays the water level in each tank.

Water level diagram

The submission also includes an Excel file with background data used to determine initial gains for a PID controller that is added to the model in the video. He demonstrates how to create a feedback loop to control water flow into the top tank, the goal being to maintain water level in the bottom tank. This is a tricky controls problem because of the long lag time before the bottom tank fills. Presumably, this is why a valve is available that enables flow directly into the bottom tank. But including it in the control system is a task left to the user.

As I reviewed the model, other thoughts came to mind on how to improve it. The tank levels are calculated using a Level- 1 MATLAB S-Function. This technique is so old that MathWorks doesn't even provide a documentation page for it. The only thing available is a discussion on how to maintain them. I recommend avoiding the S-Function and instead rely on a MATLAB Function block for the derivative calculation combined with an Integrator block. Or better yet, the whole thing could be done with Simuink blocks without MATLAB code. I'd also suggest eliminating all the Muxes and Demuxes in favor of separate signal lines or buses. So there's room for improvement, but a solid model nevertheless.

In my mind, it's material like this that the File Exchange was meant for. John combines MATLAB, Simulink, Excel, and YouTube together into an interactive educational experience. It's a lot of fun, and I hope you check it out.

Let us know what you think here or leave a comment for John.
  • print
  • send email


要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。