quarc_gumstix_target_demo_model_1.mdl
quarc_gumstix_target_demo_model_2.mdl
Open these models

Running Models using the QUARC Linux Verdex Target

This example demonstrates how to run models on a Gumstix's Verdex board using the QUARC Linux Verdex target. The gumstix target runs in Linux on an ARM processor and is suitable for embedded control applications. For a detailed description of this target, you can refer to the QUARC Linux Verdex Target reference section. This example consists of two demonstrations. The first demonstration showcases running one model on the gumstix target. The second demonstration showcases steps required to run multiple models on this target. We have used two simple models for this example which are shown in the following figures.

gumstix Target Demo - Model #1 Simulink Diagram

gumstix Target Demo - Model #2 Simulink Diagram

System Requirements

This demonstration is run using the QUARC Linux Verdex target. For the gumstix configuration and software requirements, please refer to the QUARC Linux Verdex Target reference section.

In addition, the Gumstix Cross-Compilers component should be selected during the QUARC installation. This feature of the QUARC installer supplies the LLVM-GCC Windows-based cross-compiler customized for the Gumstix Verdex as well as a framework to also use CodeSourcery Lite, as another Windows-based cross-compiler for the Gumstix. This LLVM-GCC cross-compiler is used in QUARC by default. Alternatively if the Gumstix Cross-Compilers package has not been selected during the QUARC installation and no cross-compiler has been installed, the Native GCC compiler can still be chosen to compile the QUARC model on the remote Gumstix target itself.

Configuring the Demonstration

Open the QUARC Preferences dialog by selecting Preferences from the QUARC menu of one of the Simulink diagrams.

Select linux_verdex as the Target type on the Model pane. Then change the IP address in the Default model URI parameter to match your gumstix target. For example, if your gumstix board has an IP address of 172.16.0.253, then the Default model URI should be tcpip://172.16.0.253:17001. A hostname may be used instead of the IP address if the gumstix target is configured with a hostname. The IP address of the gumstix target may be determined using the ifconfig Linux command. The concept of URI's and their use in communications is discussed in Communicating with the Target. In this example, communications between Simulink and the model will occur using TCP/IP. This step configures the default communications scheme used with the gumstix target and does not have to be repeated unless the address of the gumstix target changes.

QUARC Preferences Dialog

Since the Verdex is a remote target, it can be beneficial to open a QUARC console for that target to monitor its behaviour. The QUARC console is a tool you can use to monitor a model's standard I/O. For a detailed discussion of this tool, please refer to the QUARC Console - Model Standard I/O reference section.

To open the QUARC console for your gumstix target, go to start menu and select the Quanser/QUARC/Console for Target menu item. In the "Console for *" window, change the Target URI to the URI you set for the default model URI in the above step with one small change; a port number should be set to 17000. Therefore, for a gumstix board with the IP address mentioned above, the "Console for *" window would look similar to the following figure.

QUARC Console

The last step in configuring this example is to use a cable to connect 2 of the Digital I/O pins on the gumstix to form a loopback system. This step is needed since one of the demonstrations is a simple digital loopback demo.

Demonstration 1 - Running One Model using the QUARC Gumstix Verdex Target

This demonstration illustrates how to run a single model on the QUARC gumstix target. The model to be used in this section is the quarc_gumstix_target_demo_model_1.mdl Simulink diagram. It is basically a digital loopback example. You can refer to the QUARC Digital Loopback Demo for more information on this example.

Once in the model window, open the Configuration Parameters dialog box by pressing Ctrl+E or choosing the Simulation/Model Configuration Parameters... menu item.

Click on the Code Generation pane in the tree-view on the left. In the Target Selection section, browse through the TLC files and select the quarc_linux_verdex.tlc file as the System target file.

Model #1 Configuration Parameters Dialog

In the Interface section of the Code Generation pane, there is a parameter called the MEX-file arguments. This is where you explicitly define a model URI to be used. If you do not specify a model URI in this parameter's field, the default model URI will be used for the model. The default model URI has already been set using the QUARC Preferences dialog in the Configuring the Demonstration section. Therefore, for this model, tcpip://linux-verdex:17001 will be used as the model URI ("linux-verdex" should be replaced with the IP address of your gumstix board as mentioned earlier). For more information on the MEX-file arguments parameter, please refer to the MEX-file arguments reference section.

Navigate to the Solver pane. Change the Fixed-step size (fundamental sample time) parameter to 0.02 seconds. Depending on the Linux OpenEmbedded system timer resolution configured and running on the Verdex board, the maximum achievable sampling frequency will typically vary between 50Hz (i.e., default configuration at a 20-millisecond sampling interval) and 767Hz (i.e., 1.3 milliseconds).

To apply all the changes, Click on Apply and OK.

Double-click on the HIL Initialize block to open its parameters dialog. Change the Board type parameter to the gumstix model being used. Select the "verdex" board type, as the Verdex is currently the only gumstix board fully supported by QUARC. Do so from the Gumstix category using the drop-down list specific to the Board type parameter. Note that the gumstix is both a target (running a version of Linux) and a HIL card.

Next, navigate to the Digital Inputs pane and set the Digital input channels parameter to the Digital I/O pin being used as the input to the model. Repeat the same step for Digital output channels parameter in the Digital Outputs pane to set it to the Digital I/O pin being used as the output from the model. These two steps are needed to initialize the digital channels and their directions (input or output).

Double-click on the HIL Write Digital block and set the Channels parameter to the number specified for the digital output from the model.

Double-click on the HIL Read Digital block and set the Channels parameter to the number specified for the digital input to the model

Select Build from the QUARC menu of the diagram, or press 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 View/Diagnostic Viewer 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.

You can now use the QUARC console opened for the gumstix target to monitor the progress of the build process.

Double-click on the "Model #1 Scope" block to display the signal being input to the model from the gumstix output.

Click on the Connect to Target button or select Connect to Target from the Simulation menu of the diagram to connect to the model.

Start the model by clicking on the Run button or selecting Run from the Simulation menu of the diagram. The Start item of the QUARC menu may also be used to both connect and start the model in one operation.

The "Model #1 Scope" block will trace a signal similar to the following figure.

Scope

Also the QUARC Console should now show something similar to the figure below.

Console For All

Click on the Stop button or select Stop from the Simulation menu of the diagram to stop the model. The Stop item of the QUARC menu may also be used.

Demonstration 2 - Running Multiple Models using the QUARC Gumstix Verdex Target

This demonstration illustrates how to run multiple models on the QUARC gumstix target. We will use the quarc_gumstix_target_demo_model_1.mdl model as well as the quarc_gumstix_target_demo_model_2.mdl model for this demonstration.

Perform the steps mentioned in the Demonstration 1 - Running One Model Using the gumstix Target section to setup the quarc_gumstix_target_demo_model_1.mdl model.

For quarc_gumstix_target_demo_model_2.mdl, the Fixed-step size (fundamental sample time) and the System target file parameters should be set in the same way as the setting for these parameters in model #1.

Referring to the Configuring the Demonstration section, you have already set the default model URI for your gumstix target. One of your models will be using this model URI to communicate with the real-time code running on the target. The other model cannot use the same TCP/IP port number to communicate with its real-time code as ports cannot be shared between multiple connections. Therefore, you need to change the MEX-file arguments parameter of one of the models to explicitly define the model URI and change the port number. In this demonstration, this parameter is modified for model #2.

While in the Configuration Parameters dialog for model #2, navigate to the Code Generation pane and select the Interface section from the tree-view on the left of the dialog.

Add the following line segment to the MEX-file arguments parameter's field:

'tcpip://linux-verdex:17002'

The "linux-verdex" should be replaced with the IP address for your gumstix board. The IP address should be identical to the one set for the default model URI. Note that this string should be separated from the default string by a comma.

Configuration Parameters

Click on Apply and OK.

Select Build from the QUARC menu of each diagram, or press 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 View/Diagnostic Viewer 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.

You can now use the QUARC console opened for the gumstix target to monitor the progress of the build processes.

Double-click on "Model #1 Scope" and "Model #2 Scope" blocks to display the gumstix output signal and the sine wave respectively.

Click on the Connect to Target button or select Connect to Target from the Simulation menu of each of the diagrams to connect to the models.

Start the models by clicking on the Run button or selecting Run from the Simulation menu of each diagram. The Start item of the QUARC menu may also be used to both connect and start the model in one operation.

The Scope blocks will trace two signals similar to the following figures.

Model #1 Scope

Sine Wave Scope

Click on the Stop button or select Stop from the Simulation menu of the diagram to stop each model. The Stop item of the QUARC menu may also be used.

Each time you want to run an extra model on your gumstix machine, you have to define its model URI explicitly and have a different port number for the new model.