Table of Contents > QUARC > User's Guide > QUARC Basics for Scripts
Basic Procedures
Once the initial configuration of QUARC is complete, scripts may be created, built and then run on target machines. The first step after creating a MATLAB script is to generate code and build it for the desired target. Once it is built, the script may then be run on the target. This section explains the procedures involved in building and running a script on a target. The following list may be used to refer to each topic:
Building a Script
To build a script to run in real-time on a target, use the qc_build_script command. The qc_build_script command performs the following sequence of operations. These operations are all performed automatically when you build the script, but are listed here to give you a better understanding of how QUARC generates code.
.rt-<target type>
,
where <target type>
is the name of the type of target. For example, the extension .rt-win64
is used for
the QUARC Win64 target.
Once a build script has been generated, it can be invoked directly to build the script executable instead of re-running qc_build_script. It is also possible to run qc_build_script each time, since it does not overwrite the build script or main C file by default. See the qc_build_script documentation for other options such as updating the target in a build script, overwriting existing files, or generating files without building.
Running a Script
After building the real-time code for a MATLAB script using the qc_build_script command, the code may now be run on the QUARC target. To run a script executable on a QUARC target, the qc_run_script command may be used. The script executable may also be run directly from Windows Explorer.
The qc_run_script commands takes the script executable name, including file extension,
as its argument along with any arguments to pass to the script itself. For example, to run the myscript.rt-win64
script executable, use the command:
qc_run_script myscript.rt-win64
To pass it arguments, simply add those arguments to the end of the command line, as follows:
qc_run_script myscript.rt-win64 -kp 7.3
Note that spaces delineate arguments, so the above example will pass two arguments, "-kp" and "7.3", to the myscript QUARC "executable".
The above command could also be specified in the equivalent functional form as:
qc_run_script('myscript.rt-win64', '-kp', '7.3')
Note that all the arguments to qc_run_script are strings. Hence, to use a variable
for one of the arguments, the variable value must be converted to a string. For example, suppose the scalar
gain
contained the desired value of Kp. Then the following command could be used to pass the
value of gain
as an argument to the script:
qc_run_script('myscript.rt-win64', '-kp', num2str(gain))
The target on which the script executable will be run is determined by the target URI. QUARC uses Universal Resource Identifiers (URIs) for its communications paradigm. In short, a URI identifiers the protocol and address of the target. For example, the URI tcpip://remhost:17000 identifies a remote target named "remhost" listening on TCP/IP port 17000.
The target URI used for a script executable is returned by the qc_get_target_uri
function when passed the script exeecutable name e.g. qc_get_target_uri('myscript.rt-win64')
.
To run the script executable on a different target, the -t target_uri
option may be passed to the
qc_run_script command. For example:
qc_run_script -t tcpip://remhost:17000 myscript.rt-win64
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.