MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
quarc_model_std_io_demoQUARC Model Standard I/O Demo
This example demonstrates how to use the Scan and Print blocks from the QUARC Targets library to interact with the model standard I/O. For details of these blocks, please refer to the Scan block and the Print block reference pages in the QUARC documentation.
The reason for executing these blocks in an asynchronous thread is that the Scan block is blocking and should not be placed in the main diagram. For information on the asynchronous threads, you can refer to the Asynchronous Threads section.
Configuring the Demonstration
To set up the demonstration, you need to open a QUARC console to be able to interact with the model standard I/O. Information on the QUARC console can be found in the QUARC Console - Model Standard I/O reference section.
Note that you need to open a console specific to the model. To open a QUARC console for your model, choose the
menu item in the model window.
Demonstration
Select Ctrl+B while the diagram is the active window. A great deal of output will appear in the Diagnostic Viewer about the progress of the build. If you cannot see the Diagnostic Viewer, you can open it by selecting from the menu of the diagram, or clicking on the View Diagnostics hyperlink at the bottom of the diagram. If you have MATLAB R2013b or earlier then the output will appear in the MATLAB Command Window.
from the menu of the diagram, or pressClick on the
button or select from the menu of the diagram to connect to the model.Start the model by clicking on the
button or selecting from the menu of the diagram. The item of the menu may also be used to both connect and start the model in one operation.In the QUARC console, the user is asked to input a number. Input a number and press Enter. The QUARC console would look similar to the following figure once you pressed Enter.
Now, enter a string rather than a number. The model would complain that the number you entered is invalid.
Because standard I/O is always blocking on the Windows target, it may be necessary to press a character and then press Enter in a QUARC Console before an asynchronous thread containing a Scan block can terminate. This restriction can prevent other block's termination functions from executing until the asynchronous thread has exited.
Referring to the above warning, in order to stop the model, click on the
button or select from the menu of the diagram and then press a character followed by the Enter key in the QUARC console. Notice that the messages regarding the model being terminated appear on the console. It is only when you press a character followed by Enter that the model terminates after you request a stop using the Simulink model window.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.