Accelerating the pace of engineering and science

# Documentation

## Troubleshooting Automatic PID Tuning

This section explains some procedures that can help you obtain better results from the PID Tuner if the basic procedures yield unsatisfactory controller performance.

### Plant Cannot Be Linearized or Linearizes to Zero

#### What This Means

When you open the PID Tuner, it attempts to linearize the model at the operating point specified by the model initial conditions. Sometimes, PID Tuner cannot obtain a non-zero linear system for the plant as seen by the PID controller.

#### How to Fix It

If the plant model in the PID loop cannot be linearized, you have several options for obtaining a linear plant model for PID tuning

#### What This Means

You have adjusted the PID Tuner sliders, but you cannot find a design that meets your design requirements when you analyze the PID Tuner response plots.

#### How to Fix It

Try a different PID controller type. It is possible that your controller type is not the best choice for your plant or your requirements.

For example, the closed-loop step response of a P- or PD-controlled system can settle on a value that is offset from the setpoint. If you require a zero steady-state offset, adding an integrator (using a PI or PID controller) can give better results.

As another example, in some cases a PI controller does not provide adequate phase margin. You can instead try a PID controller to give the tuning algorithm extra degrees of freedom to satisfy both speed and robustness requirements simultaneously.

To switch controller types, in the PID Controller block dialog box:

• Select a different controller type from the Controller drop-down menu.

• Click Apply to save the change.

• Click Tune to instruct the PID Tuner to tune the parameters for the new controller type.

If you cannot find any satisfactory controller with the PID Tuner, PID control possibly is not sufficient for your requirements. You can design more complex controllers using the SISO Design Tool. For more information, see Design and Analysis of Control Systems.

### Simulated Response Does Not Match the PID Tuner Response

#### What This Means

When you run your Simulink® model using the PID gains computed by the PID Tuner, the simulation output differs from the PID Tuner response plot.

There are several reasons why the simulated model can differ from the PID Tuner response plot. If the simulated result meets your design requirements (despite differing from the PID Tuner response), you do not need to refine the design further. If the simulated result does not meet your design requirements, see Cannot Find an Acceptable PID Design in the Simulated Model.

Some causes for a difference between the simulated and PID Tuner responses include:

• The reference signals or disturbance signals in your Simulink model differ from the step signals the PID Tuner uses. If you need step signals to evaluate the performance of the PID controller in your model, change the reference signals in your model to step signals.

• The structure of your model differs from the loop structure that the PID Tuner designs for. The PID Tuner assumes the loop configuration shown in the following figure.

As the figure illustrates, the PID Tuner designs for a PID in the feedforward path of a unity-gain feedback loop. If your Simulink model differs from this structure, or injects a disturbance signal in a different location, your simulated response differs from the PID Tuner response.

• You have enabled nonlinear features in the PID Controller block in your model, such as saturation limits or anti-windup circuitry. The PID Tuner ignores nonlinear settings in the PID Controller block, which can cause the PID Tuner to give a different response from the simulation.

• Your Simulink model has strong nonlinearities in the plant that make the linearization invalid over the full operating range of the simulation.

• You selected an operating point using the PID Tuner that is different from the operating point saved in the model. In this case, the PID Tuner has designed a controller for a different operating point than the operating point that begins the simulation. Simulate your model using the PID Tuner operating point by initializing your Simulink model with this operating point. See Simulate Simulink Model at Specific Operating Point.

#### What This Means

You tune the PID Controller using the PID Tuner and run your Simulink model with the tuned PID gains. However, the simulated response of your model does not meet your design requirements.

#### How to Fix It

In some cases, PID control is not adequate to meet the control requirements for your plant. If you cannot find a design that meets your requirements when you simulate your model, consider using a more complex controller. See Design and Analysis of Control Systems.

If you have enabled saturation limits in the PID Controller block without antiwindup circuitry, enable antiwindup circuitry. You can enable antiwindup circuitry in two ways:

• Activate the PID Controller block antiwindup circuitry on the PID Advanced tab of the block dialog box.

• Use the PID Controller block tracking mode to implement your own antiwindup circuitry external to the block. Activate the PID Controller block tracking mode on the PID Advanced tab of the block dialog box.

To learn more about both ways of implementing antiwindup circuitry, see Anti-Windup Control Using a PID ControllerAnti-Windup Control Using a PID Controller.

After enabling antiwindup circuitry, run the simulation again to see whether controller performance is acceptable.

If the loop response is still unacceptable, try slowing the response of the PID controller. To do so, reduce the response time or the bandwidth in the PID Tuner. See Refine the Design.

If you still cannot find an acceptable controller with antiwindup circuitry enabled in the PID Controller block, consider using a more complex controller. See Design and Analysis of Control Systems.

### Controller Performance Deteriorates When Switching Time Domains

#### What This Means

You obtain a well-tuned continuous-time PID controller. Then, you convert the controller time domain using the Time Domain selector button in the PID Controller block dialog box. The controller performs poorly or even becomes unstable when you convert the controller to discrete time.

#### How To Fix It

In some cases, you can improve performance by adjusting the sample time by trial and error. However, this procedure can yield a poorly tuned controller, especially where your application imposes a limit on the sample time. Instead, if you change time domains and the response deteriorates, click Tune in the PID Controller block dialog to design a new controller.

 Note:   If the plant and controller time domains differ, the PID Tuner discretizes the plant (or converts the plant to continuous time) to match the controller time domain. If the plant and controller both use discrete time, but have different sample times, the PID Tuner resamples the plant to match the controller. All conversions use the tustin method (see Continuous-Discrete Conversion Methods in the Control System Toolbox™ User's Guide).

### When Tuning the PID Controller, the D Gain Has a Different Sign from the I Gain

#### What This Means

When you use the PID Tuner to design a controller, the resulting derivative gain D can have a different sign from the integral gain I. The PID Tuner always returns a stable controller, even if one or more gains are negative.

For example, the following expression gives the PID controller transfer function in Ideal form:

$c=P\left(1+\frac{1}{s}+\frac{Ds}{\frac{s}{N}+1}\right)=P\frac{\left(1+DN\right){s}^{2}+\left(I+N\right)s+IN}{s\left(s+N\right)}$

For a stable controller, all three numerator coefficients require positive values. Because N is positive, IN  >  0 requires that I is also positive. However, the only restriction on D is (1 + DN) > 0. Therefore, as long as DN > –1, a negative D still yields a stable PID controller.

Similar reasoning applies for any controller type and for the Parallel controller form. For more information about controller transfer functions, see the PID Controller block reference page.