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.
Interactive Control Design Using Live Editor Tasks
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
- América Latina (Español)
- Canada (English)
- United States (English)
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- United Kingdom (English)
- Australia (English)
- India (English)
- New Zealand (English)
- 日本Japanese (日本語)
- 한국Korean (한국어)