Online Tuning using the Closed-Loop PID Autotuner Block
- Open QLabs. Click on QUBE 2 – DC Motor, then click on the Servo Workspace.
- Download the supplied Simulink model, self_tuning_PI_controller.slx
- The Simulink model implements a PI speed controller. A square wave with a frequency of 0.4 Hz is commanded to the digital twin to alternate the speed of the load shaft between 10 rad/s and 50 rad/s. The model starts off by using kp and ki values of 0.2 and 0.1, respectively. These initial gains were selected such that they would not result in an unstable system.
- The Autotuner block is configured with a desired bandwidth and phase margin values of 75 rad/s and 60 deg respectively. With the Start Tuning manual switch set to 0 (effectively bypassing the Autotuner block), run the model. Below is the untuned response that you should observe.
- Toggle the Start Tuning manual switch block. The Autotuner block will started to interject test signals int the digital twin plant. The sine amplitude of the test signals is set to 0.1. You can change that value to see how it affects the results. Below is the response of the digital twin while being subjected to the test signals.
- The One Shot block is used to produce a pulse signal that would run the Autotuner block for 4 seconds. During this time, the model monitored the %conv output of the Autotuner block. Once the value converged to 98%, tuning is considered complete, and the Simulink diagram displayed the tuned gains as well as the estimated phase margin. Additional logic is implemented to transfer the tuned gains generated by the autotuning block to the PI controller. This means that you do not have to stop my model to apply the tuned gains to the plant.
- Below is the system response upon completion of the autotuning process and applying the new controller gains. You can see a far better response compared to the untuned controller we started with. The resulting estimated phase margin was 58 deg (very close to the desired 60 deg) and the calculated tuned gains were kp = 0.38 and ki = 2.68.
Cite As
Quanser (2024). Online Tuning using the Closed-Loop PID Autotuner Block (https://www.mathworks.com/matlabcentral/fileexchange/101874-online-tuning-using-the-closed-loop-pid-autotuner-block), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.14 | Updated URL |
||
1.0.13 | Fixed URL |
||
1.0.12 | Fixed typo |
||
1.0.11 | Updated text for clarity. |
||
1.0.10 | Updated instructions |
||
1.0.9 | Corrected typo |
||
1.0.8 | Fixed heading formatting |
||
1.0.7 | Update section headings and added instructions related to QLabs. |
||
1.0.6 | Fixed hyper links |
||
1.0.5 | Added instructions on how to open the Virtual QUBE-Servo 2 in QLabs |
||
1.0.4 | Corrected typo |
||
1.0.3 | Changed cover image |
||
1.0.2 | Corrected title |
||
1.0.1 | Left aligned images and captions. |
||
1.0.0 |