dSPACE Online Manual

Curt Crane (MSEE 1995)

Last Updated: 20 April 1995


Downloading Simulink models to the dSPACE hardware in real time

MATLAB can be used to directly download a program to the dSPACE minibox. This is accomplished in Simulink. Once you have modeled the system in Simulink, create a new Simulink document and cut and paste the part to be downloaded to this new document. It can contain no output devices such as scopes, etc.

This first figure is a simple Simulink block diagram. It reads a signal on A/D channel (ADC) 1 and outputs the same signal on D/A channel (DAC) 1. Note the times ten amd divide by ten blocks. These are necessary because the DS1102 ADC performs a divide by ten and the DAC performs a multiply by ten internally.

Simulink Block Diagram

The scopes and function generator are Simulink blocks needed to run the simulation. They must be removed before downloading to the dSPACE hardware. When downloaded, these are external connections to the actual hardware. The easiest way to do this is to copy the part to be downloaded and paste it into a new Simulink window. The inputs and outputs are then connected to Simulink "plugs", which tell Simulink that they are external connections. The figure below is all ready to be downloaded.

Simulink Block Diagram

To get the SIMULINK Block Library, in MATLAB type: simulink
To get the dSPACE Board Library, in MATLAB type: dslib

Before downloading the model to the dSPACE minibox, a few parameters must first be set in the Real-Time Options Dialog Box. To get this dialog box, in the open simulink model window, choose Code-Real-time Options... and the box will appear. Make the following changes:

where dspace_name is the name of the dSPACE Minibox you are using.

There are two ways to download the model to the dSPACE Minibox. They both accomplish the same thing so you can use either one:

Your model will be converted to code, compiled, and downloaded to the specified dSPACE Minibox. Simulink will also create the necessary .trc file for use with TRACE so it can be run immediatedly after downloading a file to the dSPACE box.