quarc_scripting_for_srv02_position_control_sim_demo.m
quarc_srv02_position_control_sim_demo.mdl
Open these M-files

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

edit quarc_scripting_for_srv02_position_control_sim_demo.m; quarc_srv02_position_control_sim_demo

QUARC Scripting for SRV02 Position Control Simulation Demo

This example consists of two files; an M-file and a Simulink model. It demonstrates how to use the QUARC MATLAB functions to create a MATLAB script that runs and manages a Simulink model. The model is the position control simulation of the Quanser SRV02 plant. The MATLAB script configures parameters needed for the model and runs the model 4 times, each time plotting the response in a MATLAB figure. In each run, a different value for the proportional gain of the controller is chosen.

SRV02 Position Control Simulation Demo Simulink Diagram

Configuring the Demonstration

To set up the demonstration, click on the hyperlink included in the header of this document to open both files. You have to have the model opened before running the script. Once the model is opened in a Simulink model window, you are set to run the QUARC script.

Demonstration

To run the script, click on the Run menu item from the Debug menu in the M-file editor. You can also press F5 or use the Run icon in the editor's toolbar.

The model gets built and starts running. The progress of the demonstration is reported in the MATLAB command window. Once all 4 runs are finished, a figure containing 4 plots is created. Each plot corresponds to the SRV02 motor shaft's actual angle position and the desired angle position for a particualr proportional gain Kp.

MATLAB Figure Consisting of 4 Plots

Running the example on a different target

To run the example model on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.

Once the QUARC SRV02 Position Control Simulation Demo model has been configured for running on a remote target, the script may be run on the local machine and it will build and deploy the code generated from the Simulink model to the remote target and run it there.