Real-Time Workshop User's Guide | ![]() ![]() |
Parameter Tuning and Monitoring
You can change program parameters from the host and monitor data with Scope blocks while the program executes using Simulink external mode. You can also monitor program outputs using the StethoScope data analysis tool.
Using Simulink external mode and/or StethoScope in combination allows you to change model parameters in your program, and to analyze the results of these changes, in real time.
External Mode
Simulink external mode provides a mechanism to download new parameter values to the executing program and to monitor signals in your model. In this mode, the external link MEX-file sends a vector of new parameter values to the real-time program via the network connection. These new parameter values are sent to the program whenever you make a parameter change without requiring a new code generation or build iteration.
You can use the BlockIOSignals code generation option to monitor signals in VxWorks. See Interfacing Parameters and Signals for further information and example code.
The real-time program (executing on the VxWorks target) runs a low priority task that communicates with the external link MEX-file and accepts the new parameters as they are passed into the program.
Communication between Simulink and the real-time program is accomplished using the sockets network API. This implementation requires an Ethernet network that supports TCP/IP. See Chapter 5, External Mode for more information on external mode.
Changes to the block diagram structure (for example, adding or removing blocks) require generation of model and execution of the build process.
Configuring VxWorks to Use Sockets
If you want to use Simulink external mode with your VxWorks program, you must configure your VxWorks kernel to support sockets by including the INCLUDE_NET_INIT
, INCLUDE_NET_SHOW
, and INCLUDE_NETWORK
options in your VxWorks image. For more information on configuring your kernel, see the VxWorks Programmer's Guide.
Before using external mode, you must ensure that VxWorks can properly respond to your host over the network. You can test this by using the host command
ping <target_name>
Configuring Simulink to Use Sockets
Simulink external mode uses a MEX-file to communicate with the VxWorks system. The MEX-file is
matlabroot
/toolbox/rtw/ext_comm.*
where *
is a host-dependent MEX-file extension. See Chapter 5, External Mode for more information.
To use external mode with VxWorks, specify ext_comm
as the MEX-file for external interface in the External Target Interface dialog box (accessed from the External Mode Control Panel). In the MEX-file arguments field you must specify the name of the VxWorks target system and, optionally, the verbosity and TCP port number. Verbosity can be 0 (the default) or 1 if extra information is desired. The TCP port number ranges from 256 to 65535 (the default is 17725). If there is a conflict with other software using TCP port 17725, you can change the port that you use by editing the third argument of the MEX-file for external interface on the External Target Interface dialog box. The format for the MEX-file arguments field is
'target_network_name
' [verbosity] [TCP port number]
For example, this picture shows the External Target Interface dialog box configured for a target system called halebopp
with default verbosity and the port assigned to 18000.
StethoScope
With StethoScope, you can access the output of any block in the model (in the real-time program) and display this data on a host. Signals are installed in StethoScope by the real-time program using the BlockIOSignals
data structure (See Interfacing Parameters and Signals for information on BlockIOSignals
), or interactively from the WindSh
while the real-time program is running. To use StethoScope interactively, see the StethoScope User's Manual.
To use StethoScope you must specify the proper options with the build command. See Code Generation Options for information on these options.
![]() | Run-Time Architecture Overview | Run-Time Structure | ![]() |