How PID Autotuning Works

To use PID autotuning, configure and deploy one of the PID autotuner blocks, Closed-Loop PID Autotuner or Open-Loop PID Autotuner.

What Does Auto Tuning For A Pid Controller Mean Home

Tuning a control loop is the adjustment of its control parameters (gain/proportional band, integral gain/reset, derivative gain/rate) to optimum values for a target response. To tune a PID use the following steps: Set all gains to zero. Increase the P gain until the response to a disturbance is steady oscillation. Increase the D gain until the the oscillations go away (i.e. It's critically damped). Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.

Autotuning Process

The PID autotuner blocks work by performing a frequency-response estimation experiment. The blocks inject test signals into your plant and tune PID gains based on an estimated frequency response.

  1. Jul 24, 2018  Now that we have this model, we can use it to tune a PID controller that will work to control the physical system. PID tuning can be thought of in two ways: Adjusting the three path gains (Kp, Ki.
  2. Jan 29, 2016  Auto-tuning PID capabilities in temperature controllers solve most problems if used properly, but they do not always work as desired. Sometimes, a good old.
  3. PID Auto-Tuning. Most modern PID process controllers will support auto-tuning (also known as self-tuning) of the PID settings. Typically the way this works will depend on which manufacturer’s product you are using, but commonly they use a rule based calculation in the same way that an experienced engineer tuning the device manually would.
  4. PID tuning entails establishing appropriate gain values for the process being controlled. While this can be done manually or by means of control heuristics, most modern controllers provide auto tune capabilities. However, it remains important for control professionals to understand what happens after the button in pressed.
  5. This White Paper from OMEGA Engineering discusses how to tune a PID controller. Even though many controllers provide auto tune capabilities, an understanding of PID tuning methods will help in achieving optimal performance. Individual sections address.

The following schematic diagram illustrates generally how a PID autotuner block fits into a control system.

Until the autotuning process begins, the autotuner block relays the control signal directly from u to the plant input at u+Δu. In that state, the module has no effect on the performance of your system.

When the autotuning process begins, the block injects a test signal at u out to collect plant input-output data and estimate frequency response in real time.

  • If you use the Open-Loop PID Autotuner block, the block opens the feedback loop between u and u+Δu for the duration of the estimation experiment. It injects into u+Δu a superposition of sinusoidal signals at frequencies [1/3, 1, 3, 10]ωc, where ωc is your specified target bandwidth for tuning. For nonintegrating plants, the block can also inject a step signal to estimate the plant DC gain. All test signals are injected on top of the nominal plant input, which is the value of the signal at u when the experiment begins.

  • If you use the Closed-Loop PID Autotuner block, the plant remains under control of the PID controller with its current gains during the experiment. Closed-loop tuning uses sinusoidal test signals at the frequencies [1/10,1/3, 1, 3, 10]ωc.

When the experiment ends, the block uses the estimated frequency response to compute PID gains. The tuning algorithm aims to balance performance and robustness while achieving the control bandwidth and phase margin that you specify. You can configure logic to transfer the tuned gains from the block to your PID controller, allowing you to validate closed-loop performance in real time.

Workflow for PID Autotuning

The following steps provide a general overview of the workflow for PID autotuning.

  1. Incorporate a PID autotuner block into your system, as shown in the schematic diagram.

  2. Configure the start/stop signal that controls when the tuning experiment begins and ends. You can use this signal to initiate the PID autotuning process at any time. When you stop the experiment, the block returns tuned PID gains.

  3. Specify controller parameters such as controller type and the target bandwidth for tuning.

  4. Configure experiment parameters such as the amplitudes of the perturbations injected during the frequency-response experiment.

  5. Dev c++ change how mouse works. Start the autotuning process using the start/stop signal, and allow it to run long enough to complete the frequency-response estimation experiment.

  6. Stop the autotuning process. When the experiment stops, the autotuner computes and returns tuned PID gains.

  7. Transfer the tuned gains from the block to your PID controller. You can then validate the performance of the tuned controller in Simulink® or in real time.

For detailed information on performing each of these steps, see:

See Also

Closed-Loop PID AutotunerOpen-Loop PID Autotuner

Related Topics

From the series: Understanding PID Control

The previous video showed three different approaches to developing a mathematical model of your physical system. Now that we have this model, we can use it to tune a PID controller that will work to control the physical system.

PID tuning can be thought of in two ways: Adjusting the three path gains (Kp, Ki, and Kd), or placing two moveable zeros and adjusting the loop gain to get the desired response. This video shows how thinking of PID tuning using moveable zeros allows you to approach the problem with loop shaping and pole placement methods. These methods provide a more systematic approach over the brute force method of guessing gain values and checking the response.

In addition to manually tuning a controller, this video introduces how automatic tuning can be a way to quickly get a controller design to meet the system requirements.

The last video showed three different approaches to developing a mathematical model of your physical system. Now that we have this model, we have the ability to tune our PID controller in a more systematic way. So in this video, I’m going to introduce you to a couple of PID tuning techniques that use a mathematical model. We have a lot to cover, so without further ado, let’s get to it. I’m Brian, and welcome to a MATLAB Tech Talk.

Let’s start with a block diagram. When I draw a box and label it plant, as I’ve said before, this is the system that we’re trying to control. We can feedback the output and wrap a PID controller around it to adjust the way this plant behaves. When we have a model, this plant is replaced with a mathematical description of the system and we can use that description to tune the PID controller. That is, to get our model to behave in a certain way.

Once we have a tuned system, we can take that controller design, usually run it on a digital computer, and wrap it around the physical system. If the model was good enough, then the gains we derived using the model will work for the physical system as well. That’s the goal anyway.

What Does Auto Tuning For A Pid Controller Mean Work

So the question might be: 'How do you tune a PID controller?' Not 'how do you get the right values,' but 'what are you doing when you tune it?' To answer that, let’s look at the structure of an ideal PID controller in the time domain. We have the three paths and we can adjust Kp, Ki, and Kd to change the relative amounts that each path contributes to the control. But, another way to think of this is in the s-domain. If we take the Laplace transform of the PID controller and rearrange a few terms, we get the transfer function in orange. So what can we learn from this? Well, first, there is a single pole at the origin. We don’t have control over that; it’s just an integrator that exists in the controller. But if you look in the numerator, there are 2 zeros whose placement is given by Kp, Ki, and Kd, and an overall gain term. That’s it! Everything you learn about tuning a PID controller comes down to where to place these two zeros and how much gain to apply.

Well, that’s for an ideal controller with an ideal derivative. If you recall from the third video in this series, we don’t implement a pure derivative. It is usually a filtered derivative. Therefore, there is another pole along the real axis that does the filtering. But we’ll touch on that in a bit more detail later on.

Let’s start looking at tuning methods -- and to do that, we’ll go back to the flow chart we created in the fourth video. Regardless of whether you have a model or not, you always have the option tweaking the gains manually with the brute force method of guessing some gain values and checking the response. This tweaking is often done to fine-tune the response after you already have an initial guess of the gains through some other method. But starting with the guess-and-check approach isn’t particularly attractive, since it sometimes feels like you’re just randomly changing values and hoping to stumble onto something good.

With that being said, though, practicing manually tweaking gains with a model and a simulation is a good way to get an intuitive feel for how each branch of a PID controller affects the output. And with a model of your system, you can tweak and adjust the gains without fear of harming any physical hardware. Take a transfer function, wrap a PID controller around it, and see if you can generate a nice response by adjusting the gains. At the very least, you’ll get a good feeling for how hard it can be to tune an unruly plant with this method.

But here’s the thing: you’ve possibly spent some time learning a bit of control theory, so why are we messing around with random guessing? We have a model and two moveable zeros in our controller, so let’s put our theory to the test!

A quick caveat before we begin. In fact, the same caveat from the last video. The rest of this video isn’t intended to explain all of the mathematics, techniques, and nuances of pole placement, loop shaping, and heuristic methods. The goal is to tie together the concepts of multiple control methods to show you that there is more than one way to accomplish tuning. If you’d like more details on any of the methods I cover here, please check out the links below.

From the last video, we have these three mathematical models that we can choose from to tune our PID controller. We have a nonlinear model and two different linear models. Since each one is different, we’d expect the final PID gains to be slightly different from each other depending on the model we use for tuning. The hope, however, is that these models are all close enough to each other that tuning on one will produce similar results for the other two as well. We’ll check that by the end of this video. Going forward, I’m going to just use the model we developed through linearization.

As I mentioned, from a simplistic viewpoint, PID tuning comes down to placing two zeros and adjusting the gain. And with our linear model, I’m going to highlight two different methods for accomplishing this: pole placement and loop shaping.

What Does Auto Tuning For A Pid Controller Mean Good

What is pole placement? If you know where you want your closed loop poles to be - that is, you know how you want your system to behave and you’ve figured out locations of the poles that generate that behavior - then you can devise a controller that places those poles right where you want them. Of course, this is within reason because the system itself has to be capable of producing that response: both the actuators to generate the driving forces and the sensors that allow you measure the state of the system.

For our SISO model, we can approach pole placement using a root locus plot. That is, we can draw the root locus for our linear model, which is the open loop plant. For what I drawn in green, this root locus doesn’t go through our desired pole locations, so no amount of gain will suffice. But once we add the integrator and the two zeros of the PID controller, we have a lot more control over the root locus lines. Now we can solve for where to place the two zeros so that the root locus lines go through the area where we want our dominant poles, and then we can solve for the gain that places them there.

Autotune for fl studio

Loop shaping, on the other hand, looks at the frequency response of the open loop system and uses our knowledge of open loop gain and phase, crossover frequency, and so on to predict how the closed loop system will behave. By adding our PID controller and adjusting the location of the two zeros and the gain, we can shape the open loop Bode plot to get the desired frequency characteristics that we want.

Now we can tackle both of those methods in a traditional sense using math and writing out the solution we’re looking for. That’s a perfectly great way to solve for the gains, and it's a way you’re probably used to from course work. But in this video, I want to do something that is a bit more graphical, because I think it’ll help solidify these concepts in your mind. And we’ll do this using the Control System Designer app and Simulink.

Within Simulink, I have my linear model, and I’ve wrapped a feedback loop around it with a PID controller. I’m going to launch to the Control System Designer app and set it up to allow me to graphically tune the PID controller block and show me the root locus plot from the reference signal, r, to the output, y. Remember, the point here is not to walk through how to use this app, it’s just to show you that graphical tuning is possible and give you something to watch as I move these zeros around so you can see their impact.

OK, here's is the root locus and it has a bit going on. There are the two open loop poles from the plant, the two zeros from the PID controller, and two more poles from the PID controller - one is the integrator at the origin and the other is the filter derivative pole. Now, the closed loop poles on the lines off to the left aren’t contributing too much to the solution because they are so much faster then the ones closer to the origin. So I’m going to zoom in and focus on this area.

Now from within this app, I can just grab one of the zeros and move it around however I want. These are complex pairs so when I move one zero, the other moves with it in a mirrored fashion. You can see how the lines move with the zeros - and if I can get them to go through the pole locations that I desire, then I can just adjust the gain by dragging the pink squares into that region.

What Does Auto Tuning For A Pid Controller Mean Free

Before I do that, I want to also plot a closed loop step response so you can see how moving these zeros impacts the system. Now I can move the zeros around and drag the gain along the lines and get to a response that I’m happy with. Watching the step response in real time is a good way to know when you you’ve placed the poles in a desired location if you don’t quite know exactly where you want them. OK, approaching PID pole placement by moving these things around by hand is not as precise as just solving the math, but a lot of times this might be good enough and you get to instantly see the affects while you’re doing it.

For loop shaping, it’s nearly the same idea, but we’ll be using a Bode plot instead so that we can watch the frequency characteristics of the open loop system. Again, I can move the zeros around and drag the gain plot up and down to adjust the gain. If I had a particular frequency response in mind, I could use the Bode plot and the free parameters of the PID controller to get the loop shape that I desire.

I want to show you something else real quick that might get you in trouble if you’re not careful. Lets go back to the root locus and up the gain a lot to decrease the rise time of the system and make a really fast response. Perfect. Now I’ll populate my Simulink PID block with the resulting gains and run the simulation to verify the response is what I predicted. And look at that, it’s perfect as well. A nice fast response.

Well maybe it’s not perfect - let’s not be too hasty. To find out what is wrong with this design, let’s plot the output of the PID controller for this step input and see what voltage we’re commanding in order to get this response.

Wow! That’s like 350 volts! Way, way too high. Our system saturates at 24 volts. So what looks like an awesome controller with a linear model was misleading. Really, we shouldn’t have placed the poles where we did because our nonlinear system is incapable of actuating in this way. Let me add saturation to our controller with clamping for the anti-windup method and see how this impacts the system. Well, as expected, it saturates at 24 volts and the motor takes almost a full second to reach the commanded speed. So this is the fastest that the motor could accelerate to 100 rpm, but it may not be the most ideal way. This is because we have such a huge gain that even though it’s saturating and not making it through the controller, it will still amplify low amplitude noise and cause our system to follow that noise. Not ideal.

At this point, we could go back to Control System Designer and adjust our controller to slow it down back into the region the actuator can handle. However, I want to demonstrate another powerful way to tune your controller, and that is to let software automatically do it for you.

Back inside the PID block parameters, there is this option to select a tuning method. It defaults to a transfer function based tuning method and hitting the Tune button launches the PID Tuning app. Right when the app opens, you can see two different responses. The dashed line is the response for the system that I tuned with loop shaping. And the solid line is the result of the automatic tuning app. I’ll also plot the controller effort so I can see that my new design won’t saturate the controller. Again, the dashed line shows that my design required a lot of controller effort.

Now to adjust the tuned gains, I can move the sliders at the top to change the requirements of the system. Do I want a faster or slower rise time, and do I want it to be more aggressive or more robust? If your requirements are given in the frequency domain then you also have the option of changing the bandwidth and phase margin. Once you settle on a step response that you’re happy with, you can update the block parameters and you’re good to go.

Now look at this response; a nice smooth rise, with very little overshoot, and no steady state error. Plus, the voltage is never saturated. That’s exactly what I wanted.

So this looks pretty good, but I’m only running it with the linearized model - which is the model that I used to auto tune in the first place. The question is, how does this behave with the model we got with system identification or the nonlinear model from first principles? To find out, I’ll play an arbitrary set point through all three closed loop systems with the exact same PID gains and compare the responses against each other. If we did this correctly, we should see the noisy signal from our nonlinear model lie right on top of the two linear model responses. And that’s exactly what we have. The yellow line is the reference signal, and the other three lines are the closed loop responses from our three models. So our PID gains that we auto tuned on one model, did in fact work for all three.

Alright, this video along with the previous video showed several different ways you could model your system and then use that model to tune the PID gains. There are several other methods out there that I didn’t mention that could do this as well, but hopefully, these videos gave you a better understanding of some of the options you have available to you next time you are trying to tune your PID controller.

In the next video, we will move past tuning and cover a few other interesting topics in PID control. So if you don’t want to miss the next tech talk video, don’t forget to subscribe to this channel. Also, if you want to check out my channel, control system lectures, I cover more control theory topics there as well. Thanks for watching. I’ll see you next time.

Other Resources

Series: Understanding PID Control

    Part 1: What is PID Control? Explore the fundamentals behind PID control. This introduction skips the detailed math and instead jumps straight to building a solid foundation. You’ll learn what a controller is used for and why PID is the most prevalent form of feedback control.

    Part 2: Expanding Beyond a Simple Integral An ideal PID controller can fail when implemented on a real, nonlinear system. This video expands beyond a simple integral and outlines a few changes that protect your system against saturation, one of the most common nonlinear problems.

    Part 3: Expanding Beyond a Simple Derivative Noise is generated by sensors and is present in every system. The derivative in an ideal PID controller amplifies high frequency noise. This video describes how to modify the derivative path to reduce the noise before it impacts the controller.

    Part 4: A PID Tuning Guide PID tuning depends on a system’s characteristics, which is why a one-size-fits all method doesn’t exist. Rather than presenting one method, this video is a guide for understanding the overall picture.

    Part 5: 3 Ways to Build a Model There are many PID tuning methods available if you have a mathematical model of the system. This video presents three different ways to model your system so that you can take advantage of each of these methods when tuning your controller.

    Part 6: Manual and Automatic Tuning Methods If you have a model of a physical system, you can use it to tune a PID controller that will work to control the physical system. This video presents several PID tuning techniques that use a mathematical model.

    Part 7: Important PID Concepts This video covers two important concepts in PID control: cascaded loops and discrete systems. Both concepts are fundamental to most practical control systems, and they each change the way you approach and think about your problem.