quarc_mdl_ref_demo.mdl
Open this model

QUARC Model Referencing Demo

This example showcases QUARC's ability to support the model referencing feature from Simulink.

Model Referencing Demo Simulink Diagram

The two models being referenced in this example are namely qc_controller.mdl and qc_plant.mdl. As the names suggest, the first model is a controller which generates a control input to be fed into the second model which is the plant. The gain variables in the first model and the plant variables in the second model are all initialized using the "Preload" model callback function of each model.

Configuring the Demonstration

To set up the demonstration, double-click on the "Controller" model block to open the qc_controller.mdl model. Once in that model's diagram, open the Model Properties by choosing the Model Properties button inside the Setup gallery on the MODELING tab. Navigate to the Callbacks pane and select the PreLoadFcn item. In the Model pre-load function field, set the Kp and Ki variables to your desired values. These variables are respectively, the proportional and integral gains of the controller. Once you make the changes, save the model, close and re-open the quarc_mdl_ref_demo.mdl model to apply these changes.

Next, double-click on the "Plant" model block to open the qc_plant.mdl model. Once in that model's diagram, open the Model Properties by choosing the Model Properties button inside the Setup gallery on the MODELING tab. Navigate to the Callbacks pane and select the PreLoadFcn item. In the Model pre-load function field, set the K and tau variables to your desired values. These variables are respectively, the gain and time constant of the first-order system as our plant. Once you make the changes, save the model, close and re-open the quarc_mdl_ref_demo.mdl model to apply these changes.

Demonstration

Building, deploying and starting the model

Refer to One Step Process in QUARC Basic Procedures to build, deploy and start the model.

Running the model

The "Desired vs. Actual Signal" Scope displays the desired signal which is square wave and the actual output of the plant model being controlled by the controller model. This Scope looks similar to the following figure.

Desired vs. Actual Signal Scope

Stopping the model

Refer to One Step Process in QUARC Basic Procedures to stop the model.

Running the example on a different target

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