Main Content

Frequency Response Based PID Tuner

Frequency Response Based PID Tuner tunes the gains of PID controller based on a simulation experiment that estimates the frequency-response of the plant in your model. It is particularly useful for tuning or retuning the gains of a PID Controller for a plant that you cannot linearize.

The frequency-response based PID tuning process begins with an estimation experiment that breaks the loop at the plant input, and perturbs the plant with sine and step signals. The tuner then uses the resulting data to estimate the plant frequency response. Finally, it uses the estimated frequency response to compute PID gains to balance performance and robustness.

Use the settings in this dialog box to specify parameters for the frequency-response estimation experiment and the goals for PID tuning. Then, click Tune to run the experiment and tune the PID gains.

For more information about how Frequency Response Based PID Tuner works, see Frequency-Response Based Tuning.

Note

While the estimation experiment is running, the tuner replaces the PID Controller block in your model with an unnamed subsystem. When the estimation experiment is completed or canceled, the tuner restores the PID Controller block. This process might result in some displacement of signal wires on the model canvas.

Experiment Settings

Use the settings in this section to specify parameters of the estimation experiment.

Number of simulations

Specify whether to perform two simulations to remove the effects of disturbances in the model.

  • 2 simulations (remove disturbances) — Select when your model includes disturbances that have a large enough effect on the plant response to interfere with the estimation experiment. In this case, the tuner performs two simulations:

    • A simulation without any perturbations, to generate a baseline plant response, including plant input and output values at the nominal operating point.

    • A simulation with perturbations on the plant input.

    The tuner uses the difference between these two simulations to compute the estimated frequency response that it uses for tuning. This process removes the effect of disturbances in the model, which would otherwise distort the estimated frequency response.

  • 1 simulation — Select when your model does not include disturbances that affect the frequency-response estimation. Selecting this option skips the baseline simulation, cutting the overall PID tuning time in half.

Default: 2 simulations (remove disturbances)

Plant information

Specify whether your plant is asymptotically stable or has an integrator.

  • Asymptotically stable — Select when your plant is stable and has no integrators. When this option is selected, the estimation experiment includes an estimation of the plant DC gain. The Frequency Response Based PID Tuner performs this estimation by injecting a step signal into the plant.

  • Has single integrator — Select when your plant contains one integrator. When this option is selected, the experiment does not include a step perturbation and DC-gain estimate.

Caution

Do not use the Frequency Response Based PID Tuner with an unstable plant or a plant containing multiple integrators.

Default: Asymptotically stable

Start time (t0)

Specify the experiment start time. Start the experiment when the plant is at the desired equilibrium operating point. For instance, if you know that your simulation must run to 10 s for transient effects to decay, specify a start time of 10.

Default: 0

Duration (tspan)

Specify how long to let the frequency-response estimation experiment run. Let the experiment run long enough for the frequency-response estimation algorithm to collect sufficient data for a good estimate at all frequencies it probes. A conservative estimate for the experiment duration is 100/ωc, where ωc is the target bandwidth for tuning that you specify with the Target bandwidth (rad/sec) parameter.

The Frequency Response Based PID Tuner computes tuned PID gains when the experiment ends.

Default: 100

Sine amplitudes (Asin)

During the tuning experiment, the Frequency Response Based PID Tuner injects a sinusoidal signal into the plant at four frequencies, [1/3,1,3,10]ωc , where ωc is the target bandwidth for tuning. Use Sine Amplitudes (Asin) to specify the amplitude of these injected signals. Specify a:

  • Scalar value to inject the same amplitude at each frequency.

  • Vector of length 4 to specify a different amplitude at each of [1/3,1,3,10]ωc , respectively.

In a typical plant with typical target bandwidth, the magnitudes of the plant responses at the experiment frequencies do not vary widely. In such cases, you can use a scalar value to apply the same magnitude perturbation at all frequencies. However, if you know that the response decays sharply over the frequency range, consider decreasing the amplitude of the lower-frequency inputs and increasing the amplitude of the higher-frequency inputs. It is numerically better for the estimation experiment when all the plant responses have comparable magnitudes.

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

In the experiment, the sinusoidal signals are superimposed (with the step perturbation, if any, in the case of open-loop tuning). Thus, the perturbation can be at least as large as the sum of all amplitudes. Therefore, to obtain appropriate values for the amplitudes, consider:

  • Actuator limits. Make sure that the largest possible perturbation is within the range of your plant actuator. Saturating the actuator can introduce errors into the estimated frequency response.

  • How much the plant response changes in response to a given actuator input at the nominal operating point for tuning. For instance, suppose that you are tuning a PID controller used in engine-speed control. You have determined that at frequencies around the target bandwidth, a 1° change in throttle angle causes a change of about 200 rpm in the engine speed. Suppose further that to preserve linear performance the speed must not deviate by more than 100 rpm from the nominal operating point. In this case, choose amplitudes to ensure that the perturbation signal is no greater than 0.5 (assuming that value is within actuator limits).

Default: 1

Step amplitude (Astep)

If Plant is asymptotically stable is selected, the Frequency Response Based PID Tuner estimates the DC gain by injecting a step signal into the plant. Use this parameter to set the amplitude of the signal. The considerations for choosing a step amplitude are the same as the considerations for specifying Sine amplitudes (Asin).

Default: 1

Design Specifications

Use the settings in this section to specify tuning goals.

Target bandwidth (rad/sec)

Specify 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/τ.

When tuning a discrete-time controller with sample time Ts, the target bandwidth, ωc, must satisfy ωcTs ≤ 0.3. This requirement ensures that the highest frequency in the estimation experiment, 10ωc, is less than the Nyquist frequency. Because of this condition, the fastest rise time you can enforce for discrete-time tuning is about 1.67Ts. If this rise time does not meet your design goals, consider reducing Ts.

Default: 1

Target phase margin (degrees)

Specify a target minimum phase margin for the tuned open-loop response at the crossover frequency. The target phase margin reflects 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.

Default: 60

Automatically Update Block

When this option is selected, the Frequency Response Based PID Tuner automatically updates the gains in the PID Controller block when the experiment and tuning is complete. If you want to examine the tuning results before updating the block, clear this option. In that case, click Update PID Block to write the tuned gains to the block.

Tune and Cancel

Click Tune to initiate the frequency-response estimation experiment. While the estimation experiment is running, the tuner:

  • Closes the open PID Controller block.

  • Clears any previous tuning results displayed in the tuner dialog box.

  • Replaces the PID Controller block in your model with an unnamed subsystem.

Note

When the estimation experiment is completed or canceled, the tuner restores the PID Controller block. This process might result in some displacement of signal wires on the model canvas, and puts your Simulink® model in a state with unsaved changes.

To abort the experiment before completion, click Cancel. When you do so, the tuner does not compute new gains.

Tuning Results

While the experiment is running, this section displays the progress of the estimation experiment. When the experiment and tuning is complete, the resulting PID gains are displayed. Also displayed are:

  • Estimated phase margin — Estimated phase margin achieved by the tuned system, in degrees. The tuner calculates this value from the angle of G(c)C(c), where G is the plant, C is the tuned controller, and ωc is the crossover frequency (bandwidth). The estimated phase margin might differ from the target phase margin you specify in the Target phase margin (degrees) parameter. It is an indicator of the robustness and stability achieved by the tuned system.

    • Typically, the estimated phase margin is near the target phase margin. In general, the larger the value, the more robust is the tuned system, and the less overshoot there is.

    • A negative phase margin indicates that the closed-loop system might be unstable.

  • Nominal plant input — Plant input at the nominal operating point, when the experiment begins.

For additional information about the experiment and tuning results, click Export To MATLAB. When you do so, the tuner creates a structure in the MATLAB® workspace, OnlinePIDTuningResult, containing the following fields:

  • P, I, D, N — Tuned PID gains. The structure contains whichever of these fields are necessary for the controller type of your PID Controller block. For instance, if you are tuning a PI controller, the structure contains P and I, but not D and N.

  • TargetBandwidth — The value you specified in the Target bandwidth (rad/sec) parameter.

  • TargetPhaseMargin — The value you specified in the Target phase margin (degrees) parameter.

  • EstimatedPhaseMargin — Estimated phase margin achieved by the tuned system.

  • Controller — The tuned PID controller, returned as a pid (for parallel form) or pidstd (for standard form) model object.

  • Plant — The estimated plant, returned as an frd model object. This frd contains the response data obtained at the four frequencies [1/3, 1, 3, 10]ωc.

  • PlantNominalInput — The plant input at the nominal operating point when the experiment begins.

  • PlantDCGain — The estimated DC gain of the system in absolute units, if Plant is asymptotically stable is selected during tuning.

See Also

Topics