Depending on the system you purchased, you may have received an integration model specific to your hardware configuration; it was designed to interact with the hardware included in your simulator. Each system is delivered with a special model that uses all I/Os available on your simulator.
The model used in this guide may be different from the one you received, but the general components and instructions are similar.
1: Create a new project based on the integration model
- Click the File menu, then click Import.
- In the Import window, select RT-LAB/Existing RT-LAB Project:
Importing project window
- Click Browse and select the root directory of your existing project on your computer or on the DVD provided.
- Select the project that appears in the Projects section.
- Click to select the Copy projects into workspace option.
- Click Finish.
Import project
2: Open the model in Simulink
Right-click on the model, select Edit with and then click to choose your MATLAB version. MATLAB will open with your model.
Editing the model
In the root layer (expand the model directory) of your Simulink model, you will find two subsystems: SM_[name] and SC_[name]:
SM_ [name] stands for subsystem master. This is where all the real-time simulation will occur. This is the only subsystem that will be run on the simulator and that contains I/Os.
The SM_[name] subsystem is a block from the OPAL-RT library that controls I/Os.
Depending on your system, you may see the following blocks:
- Analog input (Ain) and output blocks (Aout),
- Static digital input (Din) and output blocks (Dout),
- PWM input (PWMin) and output blocks (PWMout), and,
- Event detector (TSDin) and Event generator blocks (TSDout).
SC_[name] stands for subsystem console. This will be an asynchronous subsystem that will run on your host computer and will act as a user interface. No critical mathematical logic should be included in this subsystem.
Note: Some components of the model will be in both SM (computation) and SC (interface) subsystems (computation components are only in the SM subsystem).
Each of the simulator I/O configurations are described in “SystemDescription_[Customer Name]_[Project Number].pdf” included in the DVD. The I/O model will read and simulate all of your system’s I/Os.
3: Build the model
- Drag the integration model onto your target to preconfigure it.
- Since you have already configured the build process, simply click the Build toolbar button and wait a few seconds while the model is compiled.
4: Verify the configuration
Since this model uses I/Os, some additional steps are required.
- Go to the Assignation tab and ensure that the XHP box is checked (on).
5: Load and execute the model
- Click the Load toolbar button and wait for the load process to be completed. Click the Execute button. A new console window appears. Your I/Os are up and running! You can now change constant blocks to control analog and digital output signals and observe analog and digital input signals using the various scope blocks Figure 17):
Sample of possible interactions with the running model
6. See external I/Os
The specific I/O configurations for your simulator are provided in the SystemDescription_[Customer Name]_[Project Number].pdf document of your Integration Binder (in section B – Mapping I/O Blocks to signal conditioning).
- This is also, and most importantly, where you will find the pin assignments of each I/O channel.
- To see external signals, you can use an oscilloscope to probe analog and digital output of the simulator.
- The integration model is already simulating all output signals with either a square or a sine wave signal.
- Note that the digital output board must be powered by an external source between 5V and 32V on the Vuser* and have a ground in Vrtn pins. See the System Description documents to locate those pins.
* For more information about the use of Vuser and Vrtn pleaser refer to this article in the OPAL-RT knowledge base : How to power the different DB37 boards for digital outputs.