MLToolkit GUI

A Simulink model needs hardware-specific S-Function driver blocks to talk to external hardware. This means that an engineer may have to maintain two different models: one for simulation and one for code generation. For code generation, Simulink source and sink blocks need to be replaced with Input and Output hardware specific S-function blocks.

SimWB alleviates the need for hardware-specific S-function blocks by providing complete I/O independence through the Real-Time DataBase(RTDB). The RTDB holds the information necessary to configure I/O boards and data bus protocols. I/O boards are configured outside of the model programs, and data acquisition is performed via external I/O tasks which store and retrieve data values through the RTDB.

The MLToolkit GUI provides a workflow to easily create SimWB compliant RTW code from a Simulink model without having to insert hardware-specific S-function blocks in the model. SimWB-specific blocks are automatically inserted into the model during the code generation process to generate SimWB-complaint code. From the MLToolkit GUI you can connect to the real-time host, select a System Target File, automatically create an RTDB for your model, generate SimWB-compliant RTW(Simulink Coder) code, and create an executable for your model on the real-time host.

Simulator Access Tab

In the Simulink model, on the menu bar select SimWB > Toolkit GUI

SimWB Target menu item

The GUI will open to the Simulator Access tab.

MLToolkit GUI Simulator Access Tab

Host Name

Enter the real-time host name, i.e. a domain name or an IP address as a string in the form 192.168.0.1. If MATLAB/Simulink is running on the same computer as the real-time host, enter localhost to connect MATLAB/Simulink with SimWB. It is necessary that two way communication be possible between MATLAB and the real-time host. That is, each must be able to open ports on the other. VPN or firewall settings must not block the real-time host from opening transient ports listened to by the client programs.

User Name

Enter the user name of user authorized to access the SimWB real-time host. This is not the same as a Linux user on the real-time host.

Password

SIMulation Workbench user’s password.

Remember Me

Remembers the most recently used real-time host name, user name, and password across program invocations. These fields are only stored upon a successful connection to the real-time host. The saved password is cleared when this checkbox is unchecked.

Connect button

Connects to, and logs into, the real-time host using the supplied credentials. When the Simulink model is closed the connection between the MLToolkit GUI and the real-time host is terminated.

Upon successful connection to, and user authentication with, the real-time host the connection status icon will change from
to Also, the Project Properties section of the GUI will be enabled. Then user can now select the Access Group and the Project Folder.

Access Group

Authorized users are given access to resources on the real-time host and this access is restricted with groups. Users having access to a particular group can access only resources belonging to that group. Users may belong to multiple groups and the Access Group option allows them to share the RTDB and the generated code only with other users belonging to the selected group. The Project Folder list will be filtered based on the selected Access Group.

Project Folder

Authorized users are given access to resources on the real-time host and this access is restricted with groups. Users having access to a particular group can access only resources belonging to that group. The Project Folder is one such resource. Users may belong to multiple groups and each access group will have access to a set of project folders. The Project Folder list will be filtered based on the selected Access Group. The RTDB and the generated code created with the ML Toolkit will be place in the selected Project Folder. The Project Folder list is configured using the Control Center.

RTDB Creator Tab

MLToolkit GUI RTDB Creator Tab

Create RTDB Variables

These options specify which blocks in the Simulink model will be mapped to RTDB variables. The Simulink models source and sinks blocks that have mappings to the RTDB variables can access external hardware via the RTDB on the real-time host. Two mechanisms are provided in order to map Simulink source and sink blocks to RTDB variables.

Using Block Names

This option specifies mapping all the supported source and sink blocks to RTDB variables having the same name.

Note:   The Using Block Names option currently supports ten source blocks (Constant, Step, Sin, DiscretePulseGenerator, FromWorkspace, SignalGenerator, UniformRandomNumber, FromFile, Inport, and RandomNumber) and five sink blocks (Outport, ToFile, ToWorkspace, Scope, and Display). When using this option, inports and outports are picked up only from the root level(bdroot). All inports and outports within subsystems are ignored and will not be mapped to RTDB variables.
Blocks with a space and other invalid C string characters in the name will be mapped to RTDB variables with these characters replaced by an underscore.

Using Regular Expressions in Block Names

Feature update: This option specifies mapping source and sink blocks with matching regular expression in the block names to RTDB variables. This option is useful if you want only a few source and sink blocks in your Simulink model to map to RTDB variables. This option is also useful for mapping blocks which are not supported by the Using Block Names option to RTDB variables. You can use different regular expressions for sources and sinks. Project guidelines typically dictate the name of sources and sinks which are to be accessed externally. Using regular expression allows one to leverage this feature without having to rename the blocks which we had to do in releases prior to SimWB 4.3. An example;

Note:   Both options can be selected at the same time. The ten source blocks and five sink blocks supported by option 1 and other blocks with the regular expression will be mapped to RTDB variables. Special care has to be taken to ensure that two blocks in the model, even if they are in different subsystems, do not map to the same RTDB variable.
Blocks with a space in the name cannot be mapped to RTDB variables.

Please see the MATLAB documentation on searching with regular expression for more details. Link

RTDB

Name of the RTDB on the real-time host. Enter a new name or select an RTDB already existing on the real-time host.

Create and Upload RTDB button

This button creates the RTDB variable definitions from the Simulink model and uploads them to the named RTDB on the real-time host. The MLToolkit creates a hierarchical structure for the RTDB variables instead of a flat structure created prior to SimWB 4.3. The RTDB variable will be of the form

   modelname.subsystem1.blockname
   modelname.subsystem1.anothersubsystem.blockname

A signal.db file containing the RTDB variable definitions is created in the current working directory for review. Users can either Append or Overwrite the RTDB if it already exists on the real-time host.

MLToolkit GUI Simulator Access Tab

Append: Append the RTDB variables created for the Simulink model to an existing RTDB on the real-time host.

Overwrite: Overwrite an existing RTDB on the real-time host with the new RTDB variables created for the Simulink model. If there is no existing RTDB, a new one is created.

Note:   Only RTDB variable definitions which have been modified are overwritten in the RTDB on the real-time host and these overwritten RTDB variables loose their I/O mappings.

Code Generator Tab

MLToolkit GUI Code Generator Tab

Map Blocks to RTDB Variables

See Create RTDB Variables above.

System Target File

The MLToolkit uses the simwb_grt.tlc System Target file to generate SimWB-compliant code.

RTDB

Select an RTDB on the real-time host. Ideally this is the RTDB created from the Simulink model itself. At least one of the source or sink blocks in the Simulink model should map to a RTDB variable in the selected RTDB.

Compiler Options

Additional options to pass to the compiler. Examples: -g,-Wall, -I

Linker Options

Additional options to pass to the linker. Examples: -l,-s

Make Only Checkbox

When this option is checked only a Make command is issued to the real-time host. This option is useful when SimWB compliant code is already present on the real-time host and the code is to be re-made on the real-time host.

Generate, Export, and Make button

Generates code for the Simulink model, packages the source code into a .ZIP file, exports the .ZIP file along with the .MK file to the real-time host, and uses the GCC compiler to create a SimWB compliant executable on the real-time host.

Re-Make Only button

Re-Make the source code for the Simulink model on the real-time host to create a SimWB compliant executable.


© 2010-2015 Concurrent Computer Corporation
wiki.simwb.com