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 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, 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.

Contents

For MATLAB® versions R2019a and earlier, in the Simulink model, on the menu bar select: SimWB > Toolkit

SimWB Target menu item

For MATLAB versions R2019b and later, in the Simulink model, the MLToolkit GUI can be accessed as shown below:

SimWB Target menu item 2019 and later

Simulator Access Tab

The Graphical User Interface (GUI) will open on 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 username 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

Remember the most recently used real-time host name, username, 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.

Auto Login

Connects to and logs into the real-time host using the stored credentials. If the login data becomes obsolete, then use the editsimwbpref command to update the login information or turn off this option. For more information, type editsimwbpref at the MATLAB command prompt.

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 and user authentication with the real-time host. The connection status icon changes from:
not connection to connected

Note: Upon successful connection, Project Properties section of the GUI is enabled. The user can now select appropriate entries in the Access Group and the Project Folder dropdown menus.

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 placed in the selected Project Folder. The Project Folder list is configured using the Control Center GUI.

Split Model Tab

Use this tab to split a multi-level model into separate models. For more information regarding this tab, see this example.

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® model's source and sinks blocks that have mappings to the RTDB variables can access external hardware via the RTDB on the real-time host. Use any combination of the following mechanisms to map Simulink source and sink blocks to RTDB variables:

Using MLToolkit Blocks Only

Using Block Names

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

Note:
  • When using this option, inputs and outputs are extracted from only the root level (bdroot). All inputs and outputs within subsystems are ignored and will not be mapped to RTDB variables. The rationale for this rule is that converting deeper inputs and outputs to RTDB variables would interrupt the flow of data through the model.
  • Blocks with a space and other invalid C string characters in their names will be mapped to RTDB variables with these characters replaced by an underscore.

Using Regular Expressions in Block Names

This option specifies mapping those source and sink blocks to RTDB variables whose block names match specified regular expressions. 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 expressions exempts you from renaming blocks of interest, which was required in releases prior to SimWB 4.3.

Use this option when:

To map blocks with:

Note:
  • In case multiple blocks map to the same RTDB variable name, you must use the SIMulation Workbench Preferences GUI to choose whether to ignore that RTDB variable or throw an error.
  • Blocks with a space in the name cannot be mapped to RTDB variables.

For more information regarding searching a model using regular expression, type doc find_system at the MATLAB command prompt.

To generate a table of block names and the corresponding RTDB variables, see Generate List of Blocks that Map to RTDB Variables.

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 specified RTDB on the real-time host. To control the pattern used to name the RTDB variables, specify the appropriate options in the RTDB tab of the SIMulation Workbench Preferences GUI.

A signal.db file containing the RTDB variable definitions for this model is created in the current working directory for review.

If the RTDB already exists on the real-time host, then you can use one of the following options:

MLToolkit GUI Simulator Access Tab

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

Code Generator Tab

MLToolkit GUI Code Generator Tab

Map Blocks to RTDB Variables

Specify the model blocks to be replaced with RTDB variables. Use the same mechanism as Create RTDB Variables.

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 an 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.

The code is generated using the Generic Real-Time target (grt.tlc). The packaged code can be found in the RTW.Sources folder of the relevant project on the real-time host.

See Also