Setup necessary to use dSPACE MiniBoxes
In order to run programs on the dSPACE hardware you need to add a few things to your .cshrc file and create a new directory. See below:
mkdir citfiles
cp /usr/local/dsp_cit/citfiles/chkerr31.cfg citfiles/.
/usr/local/dsp_cit/bin /usr/local/c30tools
For example, if the path statement looked like this:
set path = (. ~ ~/bin /usr/ucb /usr/bin)
Add to the path like this: (no line break though)
set path = (. ~ ~/bin /usr/ucb /usr/bin /usr/local/dsp_cit/bin /usr/local/c30tools)
The trace software works in Open Windows and X-Windows. To use X-Windows, the OIT_WMGR environment variable needs to be set to OTHER. To use Open Windows, it should be set to OPENLOOK. You can run one or the other but not both unless you change the OIT_WMGR variable! The following lines assume you are using X-Windows.
Add the following lines to the .cshrc file:
setenv CITFILES root_path/citfiles
setenv OIT_PATH /usr/local/dsp_cit/bin
setenv OIT_WMGR OTHER
setenv MATLABPATH /usr/local/dsp_cit/matlab/dslib:/usr/local/dsp_cit/matlab/loadsave
Note:The previous two lines should be on a single line with a space between them in the .cshrc file and there should be NO SPACE after the colon in the previous statement!
Also, if you already have a MATLABPATH set, just add the above line to it, separating each directory path with a colon like above.
mkdir dspace
/usr/local/dsp_cit/demo1102/std/pt2.c
At this point your account is setup and you are ready to download a program to the dSPACE Minibox.
The shell-script down31 invokes the C compiler, assembler, and linker and then downloads the resulting object module to the DS1102 controller board using the ld31 program loader. This script makes the downloading process very easy.
Following is the command necessary to download a program to the dspace box from the suns:
down31 c_filename -c dspace_name
If you are unsure of the name of the dSPACE MiniBox you want to use, see the list of dSPACE names and addresses. This list also contains the respective sun workstation names and all the relevant IP addresses.
TRACE (trace31) is a utility that runs on the Sun workstation while a program is running on the dSPACE MiniBox. It allows the Sun to have access to the dSPACE memory. The value of variables in the running program can saved in a text or MATLAB format by TRACE. It can also plot the variables versus time as the program is running.
where dspace_name is the name of the dSPACE box.
The variables are:
(reference: "Addendum to TRACE for Windows User's Guide", pg.1)
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.

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.

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.