- 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.
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.
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.)
8 PID Autotuning