SIMulation      Workbench
  • Main Links
    • Concurrent Real-Time
    • Catalog
    • License Center
  • SIMulation Workbench
    • About
    • Real-Time Introduction
    • Architecture
    • Demos & Videos
    • White Papers
    • FAQ
    • Install
    • Download
    • Installation
    • Release Highlights
    • Overview
    • Control Center GUI
    • MLToolkit
    • PYToolkit
    • Supported I/O
    • Supported Third-Party Tools
    • Fault Insertion
  • Success Stories
  • Search
Jump to: navigation, search

SIMulation Workbench Toolkit

Contents

  • 1 Overview
  • 2 SimWB MLToolkit GUI for MATLAB
    • 2.1 Simulator Access Tab
      • 2.1.1 SimWB MLToolkit GUI Simulator Access Tab
        • 2.1.1.1 Host Name
        • 2.1.1.2 User Name
        • 2.1.1.3 Password
        • 2.1.1.4 Remember Me
        • 2.1.1.5 Connect button
      • 2.1.2 RTDB Creator Tab
        • 2.1.2.1 Create RTDB Variables
        • 2.1.2.2 Access Group
        • 2.1.2.3 RTDB
        • 2.1.2.4 Create and Upload RTDB button
      • 2.1.3 Code Generator Tab
        • 2.1.3.1 Map Blocks to RTDB Variables
        • 2.1.3.2 Access Group
        • 2.1.3.3 System Target File
        • 2.1.3.4 RTDB
        • 2.1.3.5 Compiler Options
        • 2.1.3.6 Linker Options
        • 2.1.3.7 Make Only Checkbox
        • 2.1.3.8 Generate, Export, and Make button
        • 2.1.3.9 Re-Make Only button
  • 3 SimWB Toolkit API for MATLAB

Overview

The SIMulation Workbench™ MLToolkit for MATLAB provides support for integrating MATLAB/Simulink models seamlessly into the SimWB environment. The MLToolkit is installed as a part of the MATLAB/Simulink environment and provides access to real-time host from within Simulink via the MLToolkit GUI and within MATLAB via the SimWB API. This MLToolkit GUI and the command line API provide an easy workflow which facilitates the generation of SimWB compliant code from Real-Time Workshop® (RTW) a.k.a. Simulink Coder(MATLAB R2011b and later). Simulink model parameters are automatically extracted from the RTW model and mapped into the RTDB so they can be accessed at run-time.

In order for a Simulink model to talk to external hardware, it needs hardware-specific S-function driver blocks in the model. 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 SimWB 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 SimWB 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.

Simwbtoolkit.png

Image: SimWB MLToolkit architecture

Singlesystemsol.png

Image: Single system solution

SimWB MLToolkit GUI for MATLAB

Simulator Access Tab

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

Simwbmenu.png

Image: SimWB menu in Simulink

This will open to the Simulator Access tab.

SimWB MLToolkit GUI Simulator Access Tab

Simulatoraccesstab.png

Image: Simulator Access tab in the SimWB MLToolkit GUI

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 SimWB 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

Connectionno.png to Connectionyes.png

Image: Connection status

RTDB Creator Tab

Rtdbcreatortab.png

Image: RTDB Creator tab in the SimWB MLToolkit GUI

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 in the name cannot be mapped to RTDB variables.
Using "SW" Prefixed Block Names
This option specifies mapping source and sink blocks with "SW" prefixing in the block names to RTDB variables. The RTDB variables have the same name as the blocks. 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. For example if you have Signal Builder block and you want to associate it with the RTDB variable long_moment, then rename the Signal Builder block to SWlong_moment. The RTDB variable will be saved as SWlong_moment. Only blocks with "SW" prefix will be mapped to their corresponding RTDB variables. Using this option, inports and outports with the SW prefix are picked up irrespective of which subsystem they are in within the model.
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 "SW" prefix 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.

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 only with other users belonging to the selected group.

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

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

Codegeneratortab.png

Image: Code Generator tab in the SimWB MLToolkit GUI

Map Blocks to RTDB Variables

See Create RTDB Variables above.

Access Group

See Access Group above.

System Target File

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

RTDB

Select a 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.

MATLAB and Simulink are registered trademarks of The MathWorks, Inc. Other product or brand names may be trademarks or registered trademarks of their respective holders. 

SimWB Toolkit API for MATLAB

Please refer to the SimWB MLToolkit documentation in MATLAB for details.

Retrieved from "https://wiki.simwb.com/swbwiki/index.php?title=SIMulation_Workbench_Toolkit&oldid=1561"
  • Privacy policy
  • About SIMulation Workbench
  • Disclaimers
  • Log in
  • Powered by MediaWiki Powered by BootStrapSkin

SIMulation Workbench © All Rights Reserved