MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
quarc_mdl_ref_demoQUARC Model Referencing Demo
This example showcases QUARC's ability to support the model referencing feature from Simulink.
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 button inside the
gallery on the MODELING tab. Navigate to the Callbacks pane and select the 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 button inside the
gallery on the MODELING tab. Navigate to the Callbacks pane and select the 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.
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.
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.