Main Content

Real-Time Controller

This example shows how to build a simple closed-loop real-time controller by using Simulink Desktop Real-Time™. The output of the controlled plant is connected to the analog input of your data acquisition board. This signal is subtracted from the set point value generated by the signal generator and processed by a PID controller. The output of the controller drives the input of the plant by using the analog output of your data acquisition board.

This model is a simplified version of the controller used for thehttp://www.humusoft.cz/produkty/models/ce152CE152 Magnetic Levitation Model.

Note:To run this model, you must have a data acquisition board connected to your computer.

Run Model in Connected IO Mode

  1. Open the Analog Input and Analog Output blocks and select your data acquisition board. If there is no board installed, install it by clicking theInstall new boardbutton.

  2. To switch toConnected IOmode if needed, on the桌面实时tab, selectMode>Connected IO.

  3. To start the real-time execution, clickRun in Real-Time.

Run Model in Run in Kernel Mode

  1. Open the Analog Input and Analog Output blocks and select your data acquisition board. If there is no board installed, install it by clicking theInstall new boardbutton.

  2. To switch toRun in Kernelmode if needed, on the桌面实时tab, selectMode>Run in Kernel.

  3. To start the real-time execution, clickRun in Real Time.

The model builds, connects to Simulink inRun in Kernelmode, and starts.

Open the Model

open_system(fullfile(matlabroot,'toolbox','sldrt','sldrtexamples','sldrtex_controller'));

Close Open Scopes

close_system(find_system(gcs ,'BlockType',的范围'));

Clean Up Model

clear closeallbdcloseall

See Also