Control Real-Time PID Autotuning in Simulink
Deploying the PID autotuner blocks lets you tune your system in real time without
Simulink in the loop. However, it can be useful to run the autotuning algorithm on
hardware while controlling the experiment from Simulink.
One way to do so is to use a model that contains a PID controller and a PID autotuner
block, and run this model in external simulation mode. External mode allows
communication between the Simulink block diagram and the standalone program that is
built from the generated code. In this mode, Simulink serves as a real-time monitoring
interface in which you can interact with the tuning algorithm running on hardware. For
instance, you can start and stop the experiment or change tuning goals from the Simulink
interface while the model is running.
When tuning in external mode, you can deploy the experiment algorithm only, such that
the PID tuning part of the calculation is performed in Simulink. Doing so can save
memory on your target hardware. Running the PID autotuning algorithm in external mode
requires a code-generation product such as Simulink Coder.
Simulink Model for External-Mode Tuning
A Simulink model for PID autotuning in external mode resembles the following
illustration.
Control Real-Time PID Autotuning in Simulink