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 you don't have a model of your plant we will show you 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 plan can be
simulated using representations such as transfer functions 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're
trying to control such as electrical or mechanical models developed using simscape in this case we're
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 a plant is linear but if 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 games
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 balance 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're satisfied with the response of your closed loop
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 set up 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'll 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 auto tuner block
in our model this block should be placed in the signal connecting your pid controller
to your plant and also requires as an input to plant measurements the algorithm will inject the
test signal into the controller output in order to estimate the frequency response of your system
however the starting gain 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 final 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 goes 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 a two hertz bandwidth and since the range of velocities of my motor is negative 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
and once it gets close to 100 percent you can stop the test and record the pid gains calculated
in this case i would generate and deploy c code to my microcontroller
and also interact directly with the hardware by using the hardware monitor and tune functionality
included with an available hardware support package 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 percent 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 on the auto tuner block parameters in this case although we have some overshoot we improved
our response time and eliminated the steady state error thanks for watching i hope you
enjoyed this video and if you're 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