in this video I will show you how to tune a control system interactively using the control
system designer app in MATLAB whether you are learning control systems and want to see the
concepts visually or are tuning a controller for your robot and want to learn how you can
do it in MATLAB this video is for you but note this video will only cover single input single
output systems the system that we will be looking at is the classic spring mass damper which is a
box with some maths connected to a spring and a damper that you keep the Box stable whenever a
force acts on it our goal will be to move the box one meter given these design requirements
to do this we must first describe our spring mass damper as a transfer function which is a
mathematical function describing the dynamics of the system telling us the output for a given input
or in our case telling us the displacement of the box due to an input force to get this equation we
start by summing all the forces acting on the box by substituting the values for each force
and rearranging the equation so the input force is on the Left we arrive to the equation of motion of
our system with this equation we then apply the Laplace transform and then simplify it to get
the general transfer function of a spring mass damper lastly I'll use ones for the mass spring
coefficient and damping ratios for my system now that we have our transfer function we will input
it into MATLAB using the TF function using the step function we can plot the open-loop response
of the system I want to see values in our system such as peak response so I will right click on
the plot go to characteristics and click on the characteristics I want to view as we can
see this doesn't quite fit the design requirements specified so we will need to move to a closed-loop
design using the control system designer app to open up the app we'll go back to MATLAB and use
the control system designer function the app opens up with a bode route locus in step response plots
which is what we'll be using but if you need to use other plots for your applications such as a
Nyquist plot you can add them by clicking this new plot drop as I said previously we're using
this app to design a closed-loop control system to view or modify the architecture of the system
I will click on this edit architecture button in this closed loop she represents the transfer
function that we found earlier she represents the compensator that will be tuning which is currently
one F and H are feed-forward and feedback terms respectively that we don't have and will remain
at one if you are unsure of what these values are you can click on a term in this panel on
the left and the value will be displayed below in this preview section before I move on the
tuning let me add peak response and steady state value characteristics to my plot I will also add
design requirements by right-clicking on the plot going to design requirements and then
clicking new in this popup menu I will fill in my design requirements in their respective fields I
then click OK to enter these requirements which will cause part of the plot to become shaded the
shaded area is the exclusion region and we want our plot to stay out of this region in order to
achieve the design requirements entered I will also save this design so we can compare our work
with this original compensator the first thing I will do to get our system out of the exclusion
region is to increase the gain of the compensator by dragging the bode plot upwards looking at the
compensator value we can see it changes as we move the bode plot now that we have the
system closer to the 1 meter mark there's a lot more oscillatory behavior going on just moving
it out I will add a zero to the bode plot by right clicking going to add pole or 0 and selecting real
0 now I can place it wherever I want by left clicking notice how adding the 0 changed the
shape of the root locus we can edit the shape of the root locus plot to further edit the response
after doing a little more loop shaping looks like our system is within the design requirements we
can visualize the impact of the compensator by comparing this design back to the original design
where the compensator was set to one if I wanted to do more work in this system I could save this
design and use a automated tuning methods such as a PID tuner but I will leave that to you guys to
try out check out the links in the description to learn about automated tuning methods as well as
other resources related to what I covered in this video and if you have any suggestions on topics we
should be creating short how-to videos on be sure to let us know in the comment section thank you