Interactive Control Design Using Live Editor Tasks
Melda Ulusoy, MathWorks
Live Editor tasks are apps you can add to your live script to complete a set of different operations without writing any code. This video will walk you through the design of a controller from measured plant data using Live Editor tasks. You'll learn how you can interactively estimate a state-space model from measured data, discretize the identified model, and finally, design a PID controller, all in one place: your live script.
In 19b, we introduce Live Editor tasks, which are apps you can add to a live script to perform a specific set of operations. Let’s say this is the workflow you need to follow to design a controller from measured plant data. Live Editor tasks let you accomplish all the workflow steps in one place, saving you time and eliminating the need of writing code. Let’s see how you can use these Live Editor tasks to estimate a state-space model from measured plant data, discretize the identified model, and then design a controller for the discretized plant.
This code here loads and plots the measured plant data. You can display the output of this code either inline or on the right-hand side of the script. To work on the first step of this workflow, we’ll use the Estimate State-Space Model task. To find this task, we’ll go to the Live Editor tab and click task. Here you’ll find Live Editor tasks from different toolboxes. Here’s the one we need. Let’s insert it to our live script. As you see here, the Live Editor task lets you interactively specify parameters. When you select data, it automatically finds the appropriate pre-defined variables from the MATLAB workspace that you can choose in these drop-down menus. By clicking this circular icon, you can enable the task to run automatically and update and display the results every time you adjust values within the task. If you don’t have the knowledge of the plant order, you can simply try out different values. Since the task is running automatically, when you change the plant order, you’ll see updated results on the right. The increased order of 5 didn’t improve the estimation fit much. So let’s set the order back to 4. If you want, you can rename the identified model in this field here. Using the task, we easily estimated a model from measured data without writing any code. If you want to see the MATLAB commands that are used by this task, you can display them by clicking the arrow on the bottom of the task. You can also enable this feature from the options menu by selecting “controls and code.” This task also lets you adjust parameters of the estimation algorithm, such as the search method and maximum iterations. As we change some of the parameters here, you see how the appropriate arguments are automatically called by these functions. This saves you time and eliminates the need to search for the specific MATLAB functions and the different options they can be set up with.
Now, we’ll move on to the second step of the workflow to discretize the identified model. For that we’ll be using the Convert Model Rate task. If you already know the name of the task you want to use, you can simply start typing its name in the live script and add the task by selecting it from the suggested list. After choosing the model and specifying the sample time of your controller, you can try out different conversion methods to find the one that gives you a better match between the original and converted model.
The final step is to design a PID controller for the discretized plant. For that, we’ll add this task that’s available under Control System Toolbox. After selecting the discretized plant, you can experiment with different controller settings such as the degrees of freedom and controller type. You can then fine-tune your controller by using these sliders which helps you alter the balance between reference tracking and disturbance rejection. By checking this box, you can also display system response characteristics such as the rise time and overshoot, and make sure the controller meets your design requirements.
If you want to share your work with others, you can simply share this live script with them, and they can play with different parameters to come up with new controller designs. Alternatively, you can hide the interactive user interface by choosing this option on each task and then share the generated code.
For more information on Live Editor tasks, check out the documentation.
选择中国网站（中文或英文）以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。