MathWorks - Mobile View
  • Melden Sie sich bei Ihrem MathWorks Konto anMelden Sie sich bei Ihrem MathWorks Konto an
  • Access your MathWorks Account
    • Eigener Account
    • Mein Community Profil
    • Lizenz zuordnen
    • Abmelden
  • Produkte
  • Lösungen
  • Forschung und Lehre
  • Support
  • Community
  • Veranstaltungen
  • MATLAB erhalten
MathWorks
  • Produkte
  • Lösungen
  • Forschung und Lehre
  • Support
  • Community
  • Veranstaltungen
  • MATLAB erhalten
  • Melden Sie sich bei Ihrem MathWorks Konto anMelden Sie sich bei Ihrem MathWorks Konto an
  • Access your MathWorks Account
    • Eigener Account
    • Mein Community Profil
    • Lizenz zuordnen
    • Abmelden

Videos und Webinare

  • MathWorks
  • Videos
  • Videos Homepage
  • Suche
  • Videos Homepage
  • Suche
  • Vertrieb kontaktieren
  • Testsoftware
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

How to Automatically Tune PID Controllers

Jose Avendano, MathWorks

Learn how to automatically tune PID controllers, whether you have an existing mathematical model of your dynamic system or you are tuning your PID parameters based on the response of an algorithm running on hardware. Automatic PID tuning can work for a variety of systems and will save development time by providing a good initial set of control parameters for your control system.

In this video you will learn how to automatically tune PID controllers using two methods.  If you have a mathematical model for your system, we will show you how to use simulations and interactive PID tuning tools. On the other hand, if don’t have a model of your plant, we will show how to generate tests that run in the hardware used by your physical plant, in order to automatically calculate optimized PID gains.

To tune a PID controller using a simulation, start from a mathematical model representing the dynamics of the plant that you want to stabilize. A plant can be simulated using representations such as a transfer function or state space models, or the behavior can also be simulated using a physical model of the system based on the domain of the plant you are trying to control. Such as electrical or mechanical models developed with Simscape. In this case we are using the transfer function of a DC motor with input voltage and output shaft angle. Then set up the architecture for your controller using the PID Controller block in Simulink and select the type of controller you would like to implement using the options provided in the dialog window. Then click the “Tune” button in the automated tuning section of the block parameters. In this example our plant is linear, but if you your plant is non-linear, this process will linearize your plant with respect to its operating point and then calculate an initial set of control gains. Once it has finished, it will bring up the tuned response of your system in the PID tuner app. By default the tuning process calculates a set of gains for balanced performance, but you can further adjust your response by selecting options to prioritize between reference tracking or disturbance rejection, and you can fine tune your parameters by interacting with the “Response time” and “Transient Behavior” controls. Once you are satisfied with the response of your closed loop system, you can click the “Update block” button to send the calculated parameters back to your PID block. And finally, verify the system behavior using the simulation model, this verification will be more crucial for more complex non-linear systems. It is also worth noting that if you prefer a more programmatic approach you can setup your control architecture and the tuning process using MATLAB functions. For more information on that check out the links in the description.

On the other hand if you don’t have a model for your plant, or your system presents non-linear or complex behavior difficult to replicate in simulation, you can create an automated test to be uploaded to your hardware and as a result will provide you with a set of optimized PID  gains.

For the purpose of this example we are controlling the rotation of a wheel by setting the motor velocity and using the information from a rotational encoder attached to the motor shaft. In this case we will also start by setting up a stable control architecture in Simulink using the PID control block. However, we will now include the Closed-Loop PID Autotuner block in our model. This block should be placed in the signal connecting your PID controller to your plant and requires as an input the plant measurements. The algorithm will inject a test signal into the controller output in order to estimate the frequency response of your system. However, the starting gains set in the PID control block will be used throughout the experiment, so the system remains stable in the closed-loop configuration. Since the auto tuning algorithm is meant to execute a triggered test, you also get the option of controlling when the test starts and stops using the third input signal, and the third block output will contain the finals PID gains calculated by the algorithm. The minimum test setup includes making sure that the controller options matches those of your PID block, a set of tuning goals for the response of your controller, and a coefficient for the magnitude of the test signals injected into the system. In this case I would like my controller to respond within half a second or at 2 hertz bandwidth, and since the range of velocities of my motor is -100 to 100, I will set the disturbance magnitude to 10, which is a conservative fraction of that actuation range. To determine whether the test is successful or not, you can monitor the test convergence using the second output. Once we start the test, this value should converge quickly, once it gets close to 100% you can stop the test and record the PID gains calculated.

In this case I will  generate and deploy C code to my microcontroller and also interact directly with the hardware by using the hardware monitor and tune functionality included within available hardware support packages, but you can also generate standalone C code and integrate it with your preferred testing method. After the test has been enabled and the convergence is close to 100% you can stop the test and get the new PID gains. it is also possible to update the gains on your PID block directly from the block tab of the autotuner block parameters. In this case we improved our rise time by X seconds compared to the initial gains.

Thanks for watching, I hope you enjoyed this video. And if you are interested in learning more about PID controllers in general or tuning methods based on MATLAB and Simulink please check the links in the description below.

Related Products

  • Simulink
  • Control System Toolbox
  • Simulink Control Design

Learn More

PID Tuning Methods for MATLAB and Simulink
PID Autotuning on Hardware
Understanding PID Control
Related Information
Get Control System Toolbox

Feedback

Featured Product

Simulink

  • Request Trial
  • Get Pricing

Up Next:

41:49
How to Develop Interactive User Interfaces for Simulink...

Related Videos:

4:26
When and How to Use a Data Dictionary
36:42
Simulink: Tips and Tricks
4:51
Gain Scheduling of PID Controllers
4:42
Using Bode Plots, Part 4: Lead, Lag, PID Controllers

View more related videos

MathWorks - Domain Selector

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: .

Select web site

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.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • 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)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Vertrieb kontaktieren
  • Testsoftware

Produkte

  • MATLAB
  • Simulink
  • Software für Studierende
  • Hardware-Unterstützung
  • File Exchange

Testen oder Kaufen

  • Downloads
  • Testsoftware
  • Vertrieb kontaktieren
  • Preise und Lizenzierung
  • Store

Lernen

  • Dokumentation
  • Tutorials
  • Beispiele
  • Videos und Webinare
  • Schulungen

Support

  • Hilfe zur Installation
  • Antworten
  • Consulting
  • License Center
  • Support kontaktieren

Über MathWorks

  • Jobs & Karriere
  • Newsroom
  • Social Mission
  • Vertrieb kontaktieren
  • Über MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks ist der führende Entwickler von Software für mathematische Berechnungen für Ingenieure und Wissenschaftler.

Entdecken Sie…

  • Select a Web Site United States
  • Patente
  • Handelsmarken
  • Datenschutz
  • Datendiebstahl verhindern
  • Status von Anwendungen

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Folgen Sie uns