The existing PID controller has gains of P = 0.02, I = 160, D = 0.00005 and N = 20000.
They are stored in a Data Store Memory block and provided externally to the PID block.
Having external gain inports allows you to change them after new gains are computed by
the Closed-Loop PID Autotuner block.
Introduction of Closed-Loop PID Autotuner Block
The Closed-Loop PID Autotuner block allows you to tune a single-loop PID controller in
both simulation and real time. It injects sinusoidal perturbation signals at the plant input
and measures the plant output during a closed-loop experiment. When the experiment
stops, the block computes PID gains based on the plant frequency responses estimated
near the desired bandwidth.
The Closed-Loop PID Autotuner block supports two typical PID tuning scenarios in real
time applications:
(1) Deploy the block on hardware and use it in a stand-alone real time application,
without the presence of Simulink.
(2) Deploy the block on hardware but monitor and manage the real time tuning process in
Simulink, using the external simulation mode. External mode allows communication
between the Simulink block diagram running on the host computer and the generated
code running on the hardware.
This example focuses on the first scenario, deploying the block to perform the real-time
tuning.
Simulink Control Design™ also provides an Open-Loop PID Autotuner block for real-time
PID tuning. The main difference between the two autotuner blocks is that the Open-Loop
PID Autotuner block carries out the experiment with the feedback loop open (i.e. the
existing controller is not in action). To decide which autotuner block is best for your
application, consider:
- If you don't have an initial controller, use the Open-Loop PID Autotuner block to obtain
one. You can continue using it to re-tune the controller or replace it with the Closed-
Loop PID Autotuner. - If you have an initial controller, use the Closed-Loop PID Autotuner block for re-tuning.
The major benefits are: (1) if there is an unexpected disturbance during the
experiment, it will be rejected by the existing controller to ensure safe operation; (2)
the existing controller will keep the plant running near its nominal operating point by
suppressing the perturbation signals as well.
8 PID Autotuning