This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Design a PID Controller Using Simulated I/O Data

This example shows how to tune a PID controller for plants that cannot be linearized. You use the PID Tuner to identify a plant for a buck converter. Then tune the PID controller using the identified plant.

This example requires the Simscape Electronics® product.

Buck Converter Model

Buck converters convert DC to DC. This model uses a switching power supply to convert a 30V DC supply into a regulated DC supply. The converter is modeled using MOSFETs rather than ideal switches to ensure that device on-resistances are correctly represented. The converter response from reference voltage to measured voltage includes the MOSFET switches. PID design requires a linear model of the system from the reference voltage to measured voltage but because of the switches automated linearization results in a zero system. In this example you use the PID tuner to identify a linear model of the system using simulation instead of linearization.

The buck converter model is described in more detail in the Simscape Electronics example elec_switching_power_supply.


The model is configured with a reference voltage that switches from 15 to 25 Volts at 0.004 seconds and a load current that is active from 0.0025 to 0.005 seconds. The controller is initialized with default gains and results in overshoot and slow settling time.

open_system('scdbuckconverter/Scope 1')
open_system('scdbuckconverter/Scope 2')

Simulate Model to Generate I/O Data

Open the Feedback controller subsystem, open the PID Controller block dialog and click Tune to launch the PIDTuner to tune the buck converter controller. The tuner opens indicating that the model cannot be linearized and returned a zero system.

The PID tuner provides several alternatives when linearization fails. From the Plant menu you can

  • Import. Use this option to import a linear model from the MATLAB workspace.

  • Re-linearize Closed Loop. Use this option to linearize the model at different simulation snapshot times.

  • Identify New Plant. Use this option to use measured data to identify a plant model.

For this example click the Identify New Plant menu to open the Plant Identification tool.

Use the Get I/O Data menu to launch a tool that simulates the model to collect data that is used to identify a plant.

The I/O Data simulation tool simulates the plant seen by the controller. The PID block is temporarily removed from the model. An input signal is injected where the output of the PID block used to be. The resulting signal at the point where the PID input used to be is logged. This data then describes the response of the plant seen by the controller. The PID tuner uses this response data to estimate a linear plant model.

Configure the data generation signal to use a step input signal:

  • Sample time $\Delta T$ = 5e-6, the controller sample rate.

  • Offset $u_0$ = 0.4. This is the controller output value that puts the converter in a state where the output voltage is near 15V and gives the operating point around which to tune the controller.

  • Onset time $T_{\Delta}$ = 0.003. This allows sufficient time for the converter to reach the 15V steady state before applying the step change.

  • Step amplitude $A$ = 0.4. This is the step size of the controller output (plant input) to apply to the model. This value is added to the offset value $u_0$ so that the actual plant input steps from 0.5 to 0.9. Note that the controller output (plant input) is limited to the range [0.01 0.95].

Click the Run Simulation button to collect I/O Data.

Click Show Input Response, Show Offset Response, and Show Identification Data. Three output curves are displayed on the I/O Data plot.

The red curve is the offset response. The offset response is the plant response to a constant input of $u_0$. The response shows that the model has some transients with a constant input, in particular:

  • The [0 0.001] second range where the converter reaches the 15V steady state. Recall that this signal is the control error signal and hences drops to zero as steady state is reached.

  • The [0.0025 0.004] second range where the converter reacts to the current load being applied while the reference voltage is maintained at 15V.

  • The 0.004 second point where the reference voltage signal is changed from 15V to 25V resulting in a larger control error signal.

  • The [0.005 0.006] second range where the converter reacts to the current load being removed.

The blue curve is the plant output when the step input is applied. Note that it has similar dynamic regions to the red signal where the current load is applied and removed but also has a transient response at the time the step is applied (at time 0.003 seconds).

The green curve is the data that will be used for plant identification. This curve is the difference between the blue (input response) and red (offset response) curves.

Click Apply to use the measured data to identify a plant model. Click Close to return to plant identification.

Plant Identification

The data generated by simulating the model is used to identify a plant model. You tune the identified plant parameters so that the identified plant response, when provided the measured input, matches the measured output.

You can manually adjust the estimated model. Click and drag the plant curve and pole location (X) to adjust the identified plant response so that it matches the identification data as closely as possible.

Click Auto Estimate to use automated identification to tune the identified plant. The automated tuning response is not much better than the interactive tuning. The identified plant and identification data do not match well. Change the plant structure to get a better match:

  • Click One Pole and select Underdamped pair.

  • Click and drag the 2nd order envelope to match the identified data as closely as possible (almost critically damped).

  • Click Auto Estimate to fine tune the plant model.

Click Save Plant to use the identified plant to tune the controller. Clicking Save Plant returns you to the PID Tuner tab with the saved plant selected and automatically tunes a controller for the identified plant.

Controller Tuning

The PID Tuner automatically tunes a PID controller for the identified plant. The tuned controller response has 10% overshoot and settling time of around 1e-3 seconds.

The controller output is the duty cycle for the PWM system and must be limited to [0 1]. Create a controller effort plot to confirm that the controller output satisfies these bounds.

The plots show the response of the design controller with both the identified plant (in green) and the linearized plant (in blue). The linearized plant is zero and not accurate, remove these responses from the plots: right click the plot, select Plants, and uncheck Plant (blue).

Adjust the PID Response Time and Transient Behavior sliders to fine tune the controller. Click Update Block to update the simulink block with the tuned controller values.

Simulate the model to confirm the PID controller performance on the simulink model.

Was this topic helpful?