Pid Auto Tuning Simulink

  
Pid Auto Tuning Simulink Rating: 7,7/10 3342 votes

Control Real-Time PID Autotuning in Simulink. Deploying the PID autotuner blocks lets you tune your system in real time without Simulink ® in the loop. However, it can be useful to run the autotuning algorithm on hardware while controlling the experiment from Simulink. Auto-tuning methods used in this study are Ziegler-Nichols Step Response, Relay and ISTE Tuning method. Because Matlab-SIMULINK based real time control is realized in this study, to control the temperature of the experiment set (oven) is more practical. To implement real time temperature control of the oven, a PIC based card is used.

PID Autotuning for a Plant Modeled in Simulink

To use PID autotuning for a plant modeled in Simulink®, you incorporate a PID autotuner block into the model. You can control the autotuning process while the model is running. When tuning is complete you can validate tuned controller parameters against the simulated plant. Using PID autotuning this way can be useful for generating an initial PID design that you later refine with real-time autotuning.

Workflow for Autotuning in Simulink

The following steps provide a general overview of the workflow for PID autotuning in Simulink using the Closed-Loop PID Autotuner or Open-Loop PID Autotuner blocks.

  1. Incorporate a PID autotuner block into your model between the PID controller and the plant.

  2. Configure the start/stop signal that controls when the tuning experiment begins and ends.

  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. Run the model and initiate tuning. Use the start/stop signal to initiate the PID autotuning process. When you start the process, the autotuner block injects test signals and measures the response of the plant.

  6. Stop the experiment with the start/stop signal. When the experiment stops, the autotuner block computes and returns tuned PID gains. You can examine the tuned gains for reasonableness.

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

Step 1. Incorporate Autotuner into Model

The following illustration shows one way to incorporate a Closed-Loop PID Autotuner block in between your PID controller and your plant.

The control signal u from the PID controller feeds into the u port of the autotuner block. The u+Δu port feeds into the plant input. Before you begin the autotuning process, the autotuner block feeds the PID control signal directly from u to u+Δu and the plant input. In that state, the autotuner block has no effect on plant or controller behavior. During the autotuning process, the block injects test signals at the plant input and measures the response at y.

The start/stop signal controls when the autotuning process begins and ends (see Step 2. Configure Start/Stop Signal). When the experiment ends, the block calculates PID gains and returns them at the pid gains port.

Pid Tuning Simulink

For a more detailed example of a Simulink model configured for closed-loop PID autotuning, see Tune PID Controller in Real Time Using Closed-Loop PID Autotuner Block.

Bumpless Transfer for Open-Loop Tuning

The Open-Loop PID Autotuner block opens the loop between u and u+Δu during the estimation experiment. If your controller includes integral action, you can use signal tracking to avoid integrator windup while the loop is open. Signal tracking enables the PID controller to continue to track the real plant input while it is out of the loop. Without it, your system can experience a bump when the control loop is closed at the end of the tuning process. In system of the following illustration, the PID controller is a Simulink PID Controller block with the Enable tracking mode parameter on. The plant input feeds into the tracking input of the controller block.

For a more detailed example of a Simulink model configured for open-loop PID autotuning, see Tune PID Controller in Real Time Using Open-Loop PID Autotuner Block.

Step 2. Configure Start/Stop Signal

To start and stop the autotuning process, use a signal at the start/stop port. When the experiment is not running, the block passes signals unchanged from u to u+Δu. In this state, the block has no impact on plant or controller behavior.

The frequency-response estimation experiment begins and ends when the block receives a rising or falling signal at the start/stop port, respectively. In the systems illustrated in Step 1. Incorporate Autotuner into Model, the start/stop signal is a simple switch. While the model is running, you can use the switch to begin and end the experiment. When you end the experiment, the algorithm generates the tuned PID gains and the block returns them at the pid gains port.

As an alternative to a manual switch, you can configure the start/stop signal to begin and end the experiment automatically at particular simulation times. For example, you can use the sum of two Step blocks: Configure one Step block to step from 0 to 1 at the experiment start time, and a second Step block to step from 1 to 0 at the end time. Feed the sum of the two signals into the start/stop port of the PID autotuner block.

You can configure any other logic appropriate for your application to control the start and stop times of the experiment. For more information about when to start and stop the experiment, see Step 5. Run Model and Initiate Tuning Experiment.

Step 3. Specify Controller Parameters and Tuning Goals

In the PID autotuner block, specify the configuration of the PID controller you are tuning, using the following block parameters:

  • Type

  • Form

  • Time Domain

  • Controller sample time (sec)

  • Integrator method

  • Filter method

Then, specify the target bandwidth and phase margin for tuning with the Target bandwidth (rad/sec) and Target phase margin (degrees) parameters, respectively.

The target bandwidth is the target value for the 0-dB gain crossover frequency of the tuned open-loop response CP, where P is the plant response, and C is the controller response. This crossover frequency roughly sets the control bandwidth. For a desired rise-time τ, a good guess for the target bandwidth is 2/τ.

The target phase margin reflects your desired robustness of the tuned system. Typically, choose a value in the range of about 45°– 60°. In general, higher phase margin improves overshoot, but can limit response speed. The default value, 60°, tends to balance performance and robustness, yielding about 5-10% overshoot, depending on the characteristics of your plant.

For more information about setting these parameters, see the Closed-Loop PID Autotuner or Open-Loop PID Autotuner block reference pages.

Step 4. Set Experiment Parameters

The frequency-response estimation experiment injects sinusoidal signals at frequencies around the target bandwidth ωc:

  • [1/3, 1, 3, 10]ωc for the Open-Loop PID Autotuner block

  • [1/10,1/3, 1, 3, 10]ωc for the Closed-Loop PID Autotuner block

Use the Sine Amplitudes parameter of the blocks to specify the amplitudes of these signals.

If your plant is asymptotically stable, the Open-Loop PID Autotuner block can estimate the plant DC gain with a step perturbation. Specify the amplitude of this perturbation with the Step Amplitude parameter. If your plant has a single integrator, clear the Estimate DC gain with step signal parameter.

Caution

  • Do not use either closed-loop or open-loop PID autotuning with an unstable plant.

  • Do not use open-loop PID autotuning with a plant that has more than one integrator. You can use closed-loop PID autotuning with a multiple-integrator plant.

All the perturbation amplitudes must be:

  • Large enough that the perturbation overcomes any deadband in the plant actuator and generates a response above the noise level.

  • Small enough to keep the plant running within the approximately linear region near the nominal operating point, and to avoid saturating the plant input or output.

For more information about setting the experiment parameters, see the Closed-Loop PID Autotuner and Open-Loop PID Autotuner block reference pages.

Step 5. Run Model and Initiate Tuning Experiment

After you have configured all the parameters for tuning, run the model.

  • If you have configured a manual start/stop signal, begin the experiment when your plant has reached steady-state.

  • If you have configured the start/stop signal to begin and end the tuning process at specific times, allow the simulation to run long enough to begin the experiment.

Pid Auto Tuning Simulink Free

Step 6. Stop Experiment and Examine Tuned Gains

The frequency-response estimation experiment ends when the start/stop signal falls.

  • If you have configured a manual start/stop signal, end the experiment when the signal at the % conv output stabilizes near 100%.

  • If you have configured the start/stop signal to begin and end the tuning process at specific times, allow the simulation to run through the end of the experiment.

In either case, a conservative estimate for the experiment time is 200/ωc for closed-loop tuning or 100/ωc for open-loop tuning, where ωc is your target bandwidth.

Block

When you stop experiment, the block computes new PID gains based on the estimated frequency response of the system and your specified tuning goals. Examine them for reasonableness. For instance, if you have an initial PID controller, you might expect the tuned gains to be roughly the same magnitude as the gains of the initial design. There are several ways to see the tuned gains:

  • View the output of the pid gains port of the autotuner block. One way to view this output is to connect the output to a Simulink Display block.

  • In the block, in the Block tab, click Export to MATLAB. The block creates a structure in the MATLAB® workspace, OnlinePIDTuningResult. For more information about the contents of this structure, see the Closed-Loop PID Autotuner or Open-Loop PID Autotuner block reference pages.

Step 7. Update PID Controller with Tuned Gains

The autotuner block can write tuned controller parameters directly to the PID controller block, if your PID controller is either:

  • A Simulink PID Controller block.

  • A custom PID controller for which the following conditions are both true:

    • The custom controller is a masked subsystem.

    • The PID gains are mask parameters named P, I, D, and N. (You do not need to use all four parameters. For example, if you use a custom PI controller, then you only need mask parameters P and I.)

To configure the autotuner block to write tuned gains to your controller, designate the controller as the associated PID block in the PID autotuner block parameters. (For more information, see the see the Closed-Loop PID Autotuner or Open-Loop PID Autotuner block reference pages.) Then, update your controller by clicking Update PID Block. You can update the PID gains while the simulation is running. Doing so is useful for immediately validating tuned PID gains.

Note

At any time during simulation, you can change tuning or experiment parameters, start the experiment again, and push the new tuned gains to the PID block. You can then observe the behavior of your plant as simulation continues with the new gains.

Manual Update of PID Gains

If your custom PID controller does not satisfy the conditions for direct update, you must transfer the tuned gains to your controller some other way, such as manually or with your own logic.

When you examine these gains and transfer them to your own controller, be aware of the meaning of these gains in the PID autotuner blocks. In discrete time, the blocks assume the following PID controller transfer function:

in parallel form, or in ideal form,

Fi(z) and Fd(z) depend on the values you specify for the Integrator method and Filter method formulas, respectively. For more details, see the Closed-Loop PID Autotuner or Open-Loop PID Autotuner block reference pages.

See Also

Closed-Loop PID AutotunerOpen-Loop PID Autotuner

Related Topics

This example shows how to automatically tune a PID Controller block using PID Tuner.

Introduction of the PID Tuner

PID Tuner provides a fast and widely applicable single-loop PID tuning method for the Simulink® PID Controller blocks. With this method, you can tune PID controller parameters to achieve a robust design with the desired response time.

A typical design workflow with the PID Tuner involves the following tasks:

(1) Launch the PID Tuner. When launching, the software automatically computes a linear plant model from the Simulink model and designs an initial controller.

(2) Tune the controller in the PID Tuner by manually adjusting design criteria in two design modes. The tuner computes PID parameters that robustly stabilize the system.

(3) Export the parameters of the designed controller back to the PID Controller block and verify controller performance in Simulink.

Open the Model

Open the engine speed control model with PID Controller block and take a few moments to explore it.

Pid Tuning Explained

Design Overview

In this example, you design a PI controller in an engine speed control loop. The goal of the design is to track the reference signal from a Simulink step block scdspeedctrlpidblock/Speed Reference. The design requirement are:

  • Settling time under 5 seconds

  • Zero steady-state error to the step reference input.

In this example, you stabilize the feedback loop and achieve good reference tracking performance by designing the PI controller scdspeedctrl/PID Controller in the PID Tuner.

Open PID Tuner

To launch the PID Tuner, double-click the PID Controller block to open its block dialog. In the Main tab, click Tune.

Initial PID Design

When the PID Tuner launches, the software computes a linearized plant model seen by the controller. The software automatically identifies the plant input and output, and uses the current operating point for the linearization. The plant can have any order and can have time delays.

The PID Tuner computes an initial PI controller to achieve a reasonable tradeoff between performance and robustness. By default, step reference tracking performance displays in the plot.

Pid Tuning Simulators

The following figure shows the PID Tuner dialog with the initial design:

Display PID Parameters

Click Show parameters to view controller parameters P and I, and a set of performance and robustness measurements. In this example, the initial PI controller design gives a settling time of 2 seconds, which meets the requirement.

Adjust PID Design in PID Tuner

Simple way.3utools. The overshoot of the reference tracking response is about 7.5 percent. Since we still have some room before reaching the settling time limit, you could reduce the overshoot by increasing the response time. Move the response time slider to the left to increase the closed loop response time. Notice that when you adjust response time, the response plot and the controller parameters and performance measurements update.

Pid Tuning Software

The following figure shows an adjusted PID design with an overshoot of zero and a settling time of 4 seconds. The designed controller effectively becomes an integral-only controller.

Complete PID Design with Performance Trade-Off

In order to achieve zero overshoot while reducing the settling time below 2 seconds, you need to take advantage of both sliders. You need to make control response faster to reduce the settling time and increase the robustness to reduce the overshoot. For example, you can reduce the response time from 3.4 to 1.5 seconds and increase robustness from 0.6 to 0.72.

The following figure shows the closed-loop response with these settings:

Write Tuned Parameters to PID Controller Block

After you are happy with the controller performance on the linear plant model, you can test the design on the nonlinear model. To do this, click Update Block in the PID Tuner. This action writes the parameters back to the PID Controller block in the Simulink model.

The following figure shows the updated PID Controller block dialog:

Pid Auto Tuning

Completed Design

The following figure shows the response of the closed-loop system:

The response shows that the new controller meets all the design requirements.

You can also use the Control System Designer to design the PID Controller block, when the PID Controller block belongs to a multi-loop design task. See the example Single Loop Feedback/Prefilter Compensator Design.

See Also

Related Topics