Lab1 RapidProtot Build

background image

1

Automatic implementation of a Simulink block diagram on real-time hardware

Automatyczna implementacja modeli Simulink’a na sprzęcie czasu rzeczywistego.



1)

The laboratory stand / Stanowisko laboratoryjne































Camera

Frame Grabber

DS1003

PHS BUS

Computer

PC

ISA

BUS

dSPACE

Modular dSPACE
hardware

Bischke 100A

Software:
ControlDesk/
Matlab/Simulink

ISA

PHS BUS

background image

2

„

Camera Bischke CCD100A.

Technical data CCD-100 camera Bischke

Model

CCD 100

Image converter

2/3" CCD-Chip

Standard TV

CCIR , 625 lines, 50Hz

Output video

1Vss/ 75 Ω

Minimal illumination

0,4Lux / F1,2

The ratio of signal to noise ratio

46 dB

Function AGC

20 dB

Gamma correction

0,45-1

Resolution 582(V)x500(H)
Synchronization wew/zew
Fixing the object

C

Power supply

11-16 DC, 220 A

Operating temp.

-10˚C do 50˚C

Power consumption.

2,7 W

Resistance to shocks and vibrations

50G /8G

Dimensions 57x48x119

mm

Weight 350g

background image

3

„

FrameGrabber board

Key feature of the frame grabber board are:

9

256 levels (8 bites) during the analogue-to-digital conversion separately for every

channel,

9

25 pictures per second (TV standard) acquisition capability,

9

picture is divided into square pixels, in order to retain the geometrical shape of

objects,

9

acquisition of the central part of a picture with proportions 1:1 (512 x 512 pixels),

9

vision data are organised for reading in 32-bit words (4 x 8-bit pixels),

9

controlling system is designed for LSI processing, to enable possible future
adjustments,

9

user programmable LUT decoder is placed between CCD and a memory,

9

interrupt controller with 8 interrupt inputs,

9

compatible with the dSPACE PHS-bus.





















Images received from a camera are converted in frame-grabber module to a two-dimensional matrix representing
discrete quantized values of brightness function. The frame grabber board is specifically designed for vision data
acquisition from camera for further processing on dSPACE DSP boards (DS1003).
The designed FG board can be accessed via PHS bus interface.
In general vision data is organised in 3 separate blocks (every block contains 512x512 byte for one monochromatic
channel or colour signal). It enables to read data from arbitrary chosen colour channel or monochromatic camera.
Each of the three blocks is organised as 32-bit memory in order to avail 32-bit PHS-bus transfer. It means that in
every PHS-bus reading cycle 4 pixels (4 x 8-bit) are transferred simultaneously — four pixels are packed into 32-bit
word (8-bit x 4 pixels). Data from the camera are sampled with the frequency of 14.74 MHz (time step is 67.8 ns)
what allows the size of every frame to be 512 x 512 pixels (for standard video signal of 25 frames per second).
Bandwidth of PHS bus enables to send an entire image in 9.6ms (9.6 x 3= 28.8ms for all three channels). The
signal conversion from analog to digital is realised with 8-bit resolution (256 levels). These 256 grades of grey (8
bites/pixel) during the analogue-to-digital conversion determines upper limit of accurancy of pictorial elements
representation for real-time systems. Between analog to digital converter and the FG board main memory there is
user programmable LookUpTable. The vision data before is written into FG memory goes through LUT conversion
independent for each of three channels. The LUT can be arbitrary programmed from the level of PHS-bus

A/D

LUT_R

A/D

LUT_G

A/D

LUT_B

R

G

B

MUX

MEM

MEM

MEM

MEM

PHSbus

PHSbus

8 bits

8 bits

8 bits

8 bits

8 bits

8 bits

8 bits

8 bits

8 bits

8 bits

FPGA

8 bits

8 bits

8 bits

8 bits

COUNTERS

PHSbus

CONTROL

LOAD/START

START

START

INTRQ

I8259

background image

4

Pr

o

je

k

to

w

a

ni

e

i symu

lacja

o

ff

-lin

e

Im

p

lem

en

ta

cja

uk

ład

u

st

er

o

w

an

ia

E

ksper

ym

en

t

n

a ob

iekcie

Kod źródłowy

języka C

Ładowanie

kodu

Dan

e z

po

m

ia

rów

MATLAB

Simulink

RTW

Mlib\Mtrace

RTI

Kompilacja

kodu C

Program C

dla kart dSPACE

DSP

ControlDesk

Zmiana parametrów

Sterowanie

Monitorowanie

Parame

try

zm

ie

n

n

e

CLIB

Pa

ra

m

e

tr

y

Sterowany

obiekt

background image

5

Automatic implementation of a Simulink block diagram on real-time hardware /

Budowa aplikacji czasu rzeczywistego.



1) Run ControlDesk and Matlab






2) Develop Simulink S-function in C language
2.1. Compile it as MEX-files (create dynamical library) using

mex command




3) Develop Simulink Model using S-function Block Diagram
3.5. Build real-time application





4) Use ControlDesk –a virtual instrument to change parameters and monitor signals





5) Use MLIB to access from the Matlab to real-time processor hardware

.




6) ControlDesk management




background image

6

Ad1)
1. Run ControlDesk and Matlab

Ad2)
2. Develop S-function as MEX–file written in C language - create template
file in C language containing frame-grabber’s driver and image
preprocessing procedures.

Look at template file:

sfuntmpl_basic.c or sfuntmpl_doc.c

matlabroot/simulink/src/sfuntmpl_basic.c

All procedures (image pre-processing and frame-grabber programming) are written as Simulink S-function in C
language. An S-function is a computer language description of a dynamic system, and allows to add algorithms to
Simulink models. C language S-functions are compiled as MEX-files and are dynamically linked into Matlab when
needed.

(Use

ControlDesk

to create template in C-Language S-function file)


background image

7




Part of code

Explanation



#define S_FUNCTION_NAME

histogram

#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
#include "math.h"
#include "string.h"

#define PHS 0x80500000L

#

define FG 0x00000000L

#define KANAL 0x00L










#define NR_WIERSZY (

0L

<<16 ) + (

0L

<<8 ) +

0L

#define NR_WIERSZY1 (

0L

<<16 ) + (

1L

<<8 ) +

0L


#define IL_KOLUMN 400

#define IL_WIERSZY 400


#define IL_PIXELI IL_KOLUMN*IL_WIERSZY
#define STOP_SZAROSCI 256

static volatile unsigned long *fg_rej = (unsigned long *) PHS;


S-function definition (name) and load of proper
libraries

Preprocessor directives - a way of making text
processing with your C program before they are
actually compiled.

Definition of values
The base address of FG registers on PHS BUS
Active channel (00,01,02) for reading of pixels










Image resolution settings:

Starting line & column Number, f.e:
(

128L

<<16 ) + (

0L

<<8 ) +

64

L – >

64 row&128column and I field


Number of columns
Number of rows(lines)


Total number of pixels
Gray level resolution

Pointer to base address of the FG registers on
PHS-bus
static volatile unsigned long *fg_rej = (unsigned long)
PHS + (unsigned long) FG

#define MDL_INITIALIZE_SIZES
#if defined(MDL_INITIALIZE_SIZES)
static void mdlInitializeSizes(SimStruct *S)

{

ssSetNumSFcnParams(S, 1);

ssSetNumContStates(S, 0);
ssSetNumDiscStates(S, 0);

if(!ssSetNumInputPorts(S, 0))return;

if(!ssSetNumOutputPorts(S, 1))return;


ssSetOutputPortWidth(S, 0, IL_PIXELI); //400*400

//ssSetOutputPortWidth(S, 0, 258);

ssSetNumSampleTimes(S, 1);
ssSetOptions(S, 0);

}

#endif


Definition of model parameters.


Number of expected parameters: 1


set the number of input ports: no inputs port

set the number of output ports - Set output
port dimensions for each output port index

starting at 0.

Outputport size = IL_PIXELI

Definition of communication with FG
registers by PHS bus.
The FG board is provided with PHS-bus
interface and appears on the PHS-bus as a
set of 32-bit random access registers.

The name must be the same

as the name on S-Function

block diagram

A way of reading vision data,

K2 – K8 keep the number of starting column with accuracy of 4,

W0 – W7 is line number,

P is half frame number (0 – first one and 1 – is the second).


D31 D24 D23

D16 D15

D8 D7

D0

K8 K7 K6 K5 K4 K3 K2

0 0

P

W7 W6 W5 W4 W3 W2 W1 W0

histogram

background image

8


static void mdlInitializeSampleTimes(SimStruct *S)

{
ssSetSampleTime(S, 0, -1);

ssSetOffsetTime(S, 0, 0.0);

}

#define MDL_INITIALIZE_CONDITIONS
#if defined(MDL_INITIALIZE_CONDITIONS)

static void mdlInitializeConditions(SimStruct *S)


{

#ifndef MATLAB_MEX_FILE


long i;

fg_rej[9]=0x00;

for (i=0;i<256;i++)

{

fg_rej[8]=((i<<16)|(i<<8)|i);
}

fg_rej[5] = 0x01;

#endif

}

#endif

Definition of sampling time



Sets the initial values of the state variables of

the S-function.

It is executed once when the simulation is
started.



Programmable LookUpTable.

Variable declaration


f.e logarithm:
l o n g t m p ;

f g _ r e j [ 9 ] = 0 x 0 0 ;

f o r ( i = 0 ; i < 2 5 6 ; i + + )

{ t m p = ( l o n g ) l o g ( i + 1 ) ;

f g _ r e j [ 8 ] = ( ( t m p < < 1 6 ) | ( t m p < < 8 ) | t m p ) ;

} = >

L U T ( i ) = t m p

Mode status register :fg_rej[5]= 0x01

single acquisition of one frame, new frame
will overwrite the old one, bit N is set to zero.

#define MDL_START

#if defined(MDL_START)
static void mdlStart(SimStruct *S) { }

#endif

Contains the initialization code of the S-

function, which is executed once when
simulation is started. You can use it for I/O

initialization


static void mdlOutputs(SimStruct *S, int_T tid)

{

#ifndef MATLAB_MEX_FILE

real_T *y= ssGetOutputPortRealSignal(S, 0);
//real_T *y1=ssGetOutputPortRealSignal(S, 1);

unsigned long prog;
unsigned long data,hist[256];

unsigned long *tab;

unsigned int r,j;
int_T w,m,n,i,x;

prog = *mxGetPr(ssGetSFcnParam(S,0));

tab=(unsigned long*)malloc((IL_PIXELI)*sizeof(unsigned

long));

fg_rej[5]=0x01L;


H

ERE: IMAGE PREPROCESSING ALGORITHMS


Determination of the access to the I/O
devices.

y - Indicate memory place for output port







Access to the S-function parametr



Mode status register :fg_rej[5]= 0x01
single acquisition of one frame, new frame will
overwrite the old one, bit N is set to zero.

Y=LUT(X)=X,

Pointer to the
beginning of LUT

background image

9


x= 0;

for (i = 0 ; i < IL_WIERSZY/2 ; i++){
fg_rej[KANAL] = (NR_WIERSZY + i);


for (r = x ;r<(x+IL_KOLUMN); r=r+4){

data = fg_rej[3];


tab[r] = (data & 0x000000ffL);

tab[r+1] = (data & 0x0000ff00L) >> 8;

tab[r+2] = (data & 0x00ff0000L) >> 16;
tab[r+3] = (data & 0xff000000L) >> 24;

}
x=x+2*IL_KOLUMN;

}

x=IL_KOLUMN ;

for (i = 0; i < IL_WIERSZY/2 ; i++){
fg_rej[KANAL] = (NR_WIERSZY1 + i);


for (r = x ;r<(x+IL_KOLUMN); r=r+4){

data = fg_rej[3];

tab[r] = (data & 0x000000ffL);

tab[r+1] = (data & 0x0000ff00L) >> 8;
tab[r+2] = (data & 0x00ff0000L) >> 16;

tab[r+3] = (data & 0xff000000L) >> 24;


}

x=x+2*IL_KOLUMN;


}





First image Field Reading (odd)

















Second image Field Reading (even)

for(r=0;r<256;r++)

{
hist[r]=0;

}


for(r=0;r<IL_PIXELI;r++)

{

hist[tab[r]]++;
}

for(i=0;i<IL_PIXELI;i++)
{

if (tab[i]>prog)

{
y[i]= tab[i]

}

else
{

y[i]=0;

}
}


Histogram









Binarization

background image

10


static void mdlTerminate(SimStruct *S)

{

}

#ifdef MATLAB_MEX_FILE

#include "simulink.c"
#else

#include "cg_sfun.h"

#endif


End of S-function.

called when the simulation is terminated.
* In this function, you should perform any

actions that are necessary

* at the termination of a simulation. For
example, if memory was allocated

* in mdlInitializeConditions, this is the place

to free it.




2.1 Compile C language S-function :

histogram.c

as MEX-files (to be

dynamically linked into Matlab when needed..


Complie histogram.c to obtain histogram.dll - From Matlab command line by
means commamd mex :
(note: you can use switch –v:

mex histogram.c –v

)

>> mex histogram.c

Check it

>> ls

As a result a dynamically linked library

histogram.dll

should be obtained

Runs with fixed step
size – ptk.3.4a

Is executed once when
simulation is started.

background image

11


2.2.

Purpose of the C Methods

An S-function consists of a fixed set of mdl<...>() methods that are
called by the Mdl<...>() model functions, which Real-Time Workshop
generates from the overall model. The set of mdl<...>() methods in
an S-function can be considered as a model within the model.
mdlStart() Contains the initialization code of the S-function, which
is executed once when simulation is started. You can use it for I/O
initialization, for example dsXYZ_init() or dsXYZ_range_set().
mdlInitializeConditions() Sets the initial values of the state
variables of the S-function. It is executed once when the simulation is
started. If the S-Function block lies in an enabled subsystem that is
configured as “reset states when enabled”, it is also executed
whenever the subsystem becomes enabled. Therefore, this method is
generally not suitable for I/O initialization code
mdlInitializeSizes() Defines the size characteristics of the
S-function, such as the number of inputs, outputs, states and sample
times. Simulink reads the characteristics to configure the S-Function
block.
mdlInitializeSampleTimes() Defines the sample times for the
S-function.
mdlOutputs() Contains the code for calculating the block outputs
of the S-function. You can use it for read/write access of I/O devices.
mdlUpdate() Contains the algebraic code for calculating the
discrete states of the S-function.
mdlDerivatives() Contains the code for calculating the derivatives
of time-continuous state variables within the integration routine.
mdlTerminate() Contains the termination code of the S-function,
which is executed once when simulation is stopped. You can use it for
writing the termination values to the output devices.

background image

12

Ad3)

3) Develop Simulink Model based on S-function Block

S-functions are incorporated into Simulink models by using the S-Function block in the
Nonlinear Block sublibrary. Such block provides access to S-functions from a block diagram . An
advantage of using S-functions is possibility to build a general purpose block, which can be

used many times in a model, varying parameters with each instance of the block.

From Nonlinear Block sublibrary



3.1 Create New S-function Block

background image

13



3.2 Create S-function Name

(

remember !

– the S-Function Block’s name must be the

same as in body of C S-function source file

: #define S_FUNCTION_NAME

histogram

)



3.2.1 If needed adjust S-function parameter initial value



background image

14


3.3. Save Simulink model


3.3.1. Simulink model and C language S-functions should be in the same
directory


add terminator

background image

15



3.4 Simulation parameters settings
a)


b)

depends on
applicatrion !

background image

16


c)

on

off

background image

17


3.5. Build real-time application




Push buton”Build”
or Carl+B

rti1003.tlc This is the system
target file. It controls the
generation of the model code
and the RTI-specific files.

rti1003.tmf

This is the

template makefile. It contains
all commands to compile and
link a model or submodel for a
certain dSPACE processor
board.

Make command When creating a
new model, RTI automatically
specifies the correct make
command, which you do not need
to change.

background image

18

As a result





















background image

19

Example:

----------------------------------------------------------------------
Starting build procedure with RTI 4.4 (RTI1003, 17-Mar-2003)
Model: "binaryzacja_simulink" (C:\SW2008\Gr1b\binaryzacja_simulink.mdl)
----------------------------------------------------------------------
*** Working directory: "C:\SW2008\Gr1b"
*** Optional User System Description File binaryzacja_simulink_usr.sdf not available
*** Initializing code generation
### Starting Real-Time Workshop build procedure for model: binaryzacja_simulink
### Generating code into build directory: .\binaryzacja_simulink_rti1003
Warning: Source block 'binaryzacja_simulink/S-Function' specifies that its sample time (-1) should be back-inherited from the
block(s) it drives. You should explicitly specify the sample time of source blocks.
### Invoking Target Language Compiler on binaryzacja_simulink.rtw
*** Generating Variable Description File binaryzacja_simulink.trc
*** Optional User Variable Description File binaryzacja_simulink_usr.trc not available
*** Found User-Code File binaryzacja_simulink_usr.c from 01-Jan-2002 01:05:44
*** Found User Makefile binaryzacja_simulink_usr.mk from 01-Jan-2002 01:05:44
### Creating project marker file: rtw_proj.tmw
### Creating binaryzacja_simulink.mk from c:\dspace\matlab\rti1003\m\rti1003.tmf
### Building binaryzacja_simulink: dsmake -f binaryzacja_simulink.mk

BUILDING APPLICATION (Single Timer Task Mode)

WORK DIRECTORY "C:\SW2008\Gr1b"
BUILD DIRECTORY "C:\SW2008\Gr1b\binaryzacja_simulink_rti1003"
TARGET COMPILER "C:\C3xTools" (Vs 4.x)

COMPILING binaryzacja_simulink.c

{c file compilation }

;

C:\C3xTools\cg30.exe -v40 -q -i -a C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink.opt

C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink.asm C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_si
"C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink.asm", line 6: WARNING - LINE TRUNCATED


No Errors, 1 Warning
COMPILING binaryzacja_simulink_data.c

;

C:\C3xTools\cg30.exe -v40 -q -i -a C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink_data.opt

C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink_data.asm C:\DOCUME~1\ds1003\USTAWI~1\Temp\bina
"C:\DOCUME~1\ds1003\USTAWI~1\Temp\binaryzacja_simulink_data.asm", line 6: WARNING - LINE TRUNCATED


No Errors, 1 Warning

COMPILING C:\dSPACE\MATLAB\RTI1003\C\rti_sim_engine.c
COMPILING C:\dSPACE\MATLAB\RTI1003\C\rti_init_c.c
COMPILING C:\dSPACE\MATLAB\RTI1003\C\rti_external_sim.c
COMPILING C:\MATLAB6p5\rtw\c\src\rt_sim.c
COMPILING ..\bin.c
COMPILING C:\dSPACE\MATLAB\RTI1003\C\rti_assert.c

USING LIBRARY "C:\dSPACE\MATLAB\RTI1003\C\Lib\rtwlib_r13_0_ds1003_ti47.lib"

LINKING

APPLICATION

...

{linking}

LINKING FINISHED

LOADING APPLICATION "binaryzacja_simulink.sdf"

...

{loading}

[#1] ds1003 - RTI:

Initializing ... (720)

[#2] ds1003 - RTI:

Initialization completed (721)

[#3] ds1003 - RTI:

Simulation state: RUN (700)

LOADING FINISHED

MAKE PROCESS SUCCEEDED

### Successful completion of Real-Time Workshop build procedure for model: binaryzacja_simulink
*** Finished RTI build procedure for model binaryzacja_simulink

More information- look at: pp.31 (ad 3.5)

background image

20

4) ControlDesk (

ControlDesk.pdf

)–

provides a virtual instrument panel that enables you to change parameters
and monitor signals – without regenerating the code. ControlDesk also
displays the time histories of any variable used by your application.

Frame-Grabber

DS1003 Board
with TMS320C40

S-function
parameters are
available here

background image

21

background image

22

5) MLIB (

MLIB.pdf

)- Access from the Matlab to real-time processor

hardware.

Mlib belongs to the MATLAB-dSPACE Interface Libraries that give you access to dSPACE
real-time processor hardware from the MATLAB workspace.

Parameters modification and data visualisation using integrated ControlDesk tools and
Mlib module



MLIB/MTRACE functions can be called from the MATLAB Command Window or from MATLAB M-files. Thus the powerful
numerical tools running under MATLAB can be used in combination with MLIB/MTRACE for:

_

analyzing real-time data

_

test automation

_

optimizing control algorithms


MLIB/MTRACE provides basic functions for reading and writing data to dSPACE processor boards and other functions for
generating interrupts, setting the processor state, and getting processor status information.
MLIB / MTRACE provides real-time data capture capabilities including the following features:

_

free-running or level-triggered mode

_

pre- and post-trigger

- selection between single_shot and continuous mode

_

simultaneous start of multiple data captures

_

distinction between double, float and integer (signed and

unsigned) variables

_

adjustable trace capture sampling rate (downsampling)

_

direct data transfer to the MATLAB workspace

_

data storage on the hard disk drive in continuous mode (optional)

_

specification of data capture parameters by property/values pairs.








background image

23

Example 1 - This example shows the online real-time data acquisition – Histogram

(m-file: figHist.m)




















>>figHist

background image

24

Example 2. Tresholding

>>figImage

background image

25

Run m-file titled: figImage.m from Matlab command line


>> figImage

mlibini;

Row = 400;
Col = 400;

%to obtain adress

addr1_r = mlib(

'GetTrcVar'

,

'Model Root/B:S-Function(1)'

);

addr_vec_r = mlib(

'SetVarProperty'

,addr1_r,

'length'

, Row*Col);



figure(gcf);
figure(1);


set(gca,

'drawmode'

,

'fast'

);


set(gca,

'ylim'

,[1 Row],

'xlim'

,[1 Col]);

set(gcf,

'Position'

,[380 100 400 400])

set(gcf,

'NumberTitle'

,

'off'

,

'Name'

,

'Red'

)


while

1


tic;

%To read data directly from the real-time processor.

%data length: Col*Row

fig_r = mlib(

'ReadDirect'

, addr_vec_r);



fig_r = reshape(fig_r,[Row,Col]);


fig_r = fig_r';

imagesc(fig_r);

colormap(gray)

drawnow;

shown_time = toc;

end



Ilość wierszy i kolumn pobierana z kamery
(przekłada się to na rozmiar okna do wyświetlania obrazu)

Zadanie danej do śledzenia
(zapisywana do addr1_r),
zapisanie pod pobrany adres
odpowiedniej wartości
parametru 'length',
pobranie długości wektora

Utworzenie okna (gcf wskazuje na aktywne
okno), w którym pokazywany będzie uzyskany
obraz

Ustawienie wartości parametrów obiektów:
'gca' – dotyczy osi w aktywnym oknie,
'gcf' – dotyczy aktywnego okna,
Ustawiane są: rozmiar osi i tryb rysowania oraz pozycja i rozmiar
okna i własności związane z paskiem tytułowym okna.

Początek pętli

Koniec pętli

Odczyt danej o długości Col*Row

Zmiana rozmiaru macierzy

Transpozycja macierzy fig_r

Skalowanie obrazu

Ustawienie mapy kolorów na skalę szarości

Odświeżenie ekranu

background image

26

6) ControlDesk management

6.1.Create new Layout












background image

27

6.1.Create new Slider


















background image

28


6.2. Add parameter to modify threshold value (image binarization)


















background image

29



6.3.Add parameter (threshold) – Aninate it


















background image

30


6.4. Add parameter (threshold) – Aninate it then adjust the threshold and
observe results


Move it

background image

31


Ad 3.5)

Based on „RTIRef.pdf”

File Overview

Many files are created and involved in the build and download process
for a model:

Simulink files (see page 93)

Files generated by Real-Time Workshop (see page 93)

Files generated by RTI and RTI-MP (see page 94)

Files controlling the build and download process (see page 95)

Executable real-time object and system description files (seepage 97)

Variable access files for ControlDesk, MLIB and CLIB (see page 99)

Simulink Files

The following file is used by Simulink.

<[sub]model>.mdl The MDL file contains the main Simulink
model. With RTI-MP, the CPU-specific <submodel>.mdl file contains the
Simulink model for a submodel running on the specified CPU. The
submodel is automatically extracted from the main RTI-MP model
during the build process.

Files Generated by Real-Time Workshop

The following files are generated by Real-Time Workshop. For further
information on these files, refer to Target Language Compiler by The
MathWorks.

<[sub]model>.rtw This intermediate file contains all the
information of the graphical Simulink model that is relevant to code
generation. The MathWorks’ Target Language Compiler uses it as a
basis for code generation. It is deleted after the code generation
process if the Retain .rtw file checkbox in the Simulation Parameters
dialog is cleared. With RTI-MP, the file is CPU-specific.


<[sub]model>.c This file represents the code for a Simulink model
or submodel. With RTI-MP, it is CPU-specific.

<[sub]model>[_common].h These files contain the header
information for a Simulink model or submodel. With RTI-MP, they are
CPU-specific.

<[sub]model>_reg.h This file contains the registration function for
a Simulink model or submodel. With RTI-MP, it is CPU-specific.

<[sub]model>_prm.h This file contains the parameter structure
definition for a Simulink model or submodel. With RTI-MP, it is
CPU-specific.

<[sub]model>_dt.h This file contains the data type transition
tables that are necessary for the external simulation of a Simulink
model or submodel. With RTI-MP, it is CPU-specific.

background image

32

Files Generated by RTI and RTI-MP

The following files are generated by Real-Time Interface.

<[sub]model>_th.c This file is generated by RTI and defines the
different tasks of the (sub)model. It is used to initialize the dSPACE
Real-Time Kernel with the desired tasks. With RTI-MP, it is
CPU-specific.

<[sub]model>_rti.c This file is generated by RTI and contains
definitions and declarations that are mainly related to the I/O
functionality of the model or submodel. With RTI-MP, it is
CPU-specific.

<[sub]model>_usr.c RTI generates this template file for the
User-Code if it does not already exist. You can place user-written
C code in the file. The code is included in the simulation. With RTI-MP,
it is CPU-specific.
.
<submodel>_simeng.c This CPU-specific file is generated by
RTI-MP and controls the simulation for the corresponding submodel.

<submodel>_ipc.c This file is generated by RTI-MP and included in
the <submodel>_simeng.c and <submodel>.c files. It contains all the
functions, variables and macros needed for interprocessor
communication (IPC).

<[sub]model>_bss.h RTI generates this header file for the DS1102
and DS1003 boards. For larger models it contains preprocessor
directives that define the memory sections in which the compiler must
place specific global model variables.

Files Controlling the Build and Download Process

The following files control the build and download process.

<model>_tp.m During the build process, RTI-MP maps the logical
IPC channels to the network topology, which is described in this file.
Whenever you change the Gigalink connections of a system, you have
to update the file via RTI-MP’s Multiprocessor Topology Setup dialog.
See Multiprocessor Topology Setup Dialog on page 76 for further
information.

rtimp_<model>_info.txt In each build process, RTI-MP stores
information about the CPU IDs, the topology of the multiprocessor
system and the mapping of the IPC channels for that topology. You
might need this information for debugging because some messages
contain only the IDs of the affected CPUs.

rti[mp]<xxxx>.tlc This is the system target file. It controls the
generation of the model code and the RTI-specific files.

rti[mp]<xxxx>.tmf This is the template makefile. It contains all
commands to compile and link a model or submodel for a certain
dSPACE processor board. The hardware-specific template makefile
(rti[mp]<xxxx>.tmf) provides the basis to automatically implement a
C-coded Simulink model for real-time execution. It contains all the
commands to compile and link a model or submodel for a certain
dSPACE system. When generating new code for a model or submodel,
Real-Time Workshop derives the application-specific makefile
<[sub]model>.mk

from the template makefile. With RTI-MP, the

application-specific makefile is CPU-specific.
See also <[sub]model>.mk on page 96, User Makefile (USR.MK File) on
page 106.

background image

33


<[sub]model>.mk Real-Time Workshop derives this
application-specific makefile from the template makefile, and inserts
model-specific macro variables, like the integration algorithm for the
submodel and the names of the S-functions that are used. With
RTI-MP, it is CPU-specific.
See also rti[mp]<xxxx>.tmf on page 95, User Makefile (USR.MK File)
on page 106.

<[sub]model>_rti.mk RTI generates this model-specific include
makefile. It is incorporated into the <[sub]model>.mk file.

<[sub]model>_usr.mk This is the user makefile. It lets you modify
the standard build process via a set of make macros. You can define
extra search paths (for S-functions or user-defined C source code),
user libraries, etc.
See User Makefile (USR.MK File) on page 106 for further information.

<[sub]model>_rti.prj RTI uses this model-specific project marker
file to determine whether the source files need to be recompiled.

<[sub]model>.lk The linker command file describes the
assignment of memory sections to the memory banks of the
corresponding processor.
See Linker Command File (LK File) on page 109 for further
information.

Executable Real-Time Object and System Description Files

The following files are the real-time object files that are executed on
your real-time hardware. In addition, there is the system description
file that binds the object file(s) and variable description file(s) together
for easy access in ControlDesk.

<[sub]model>.obj RTI generates this file during the build process.
It is the executable object file for the DS1102 and DS1003 boards
(C31 / C40 DSP processor). After the build process is finished, the file
can be downloaded to the dSPACE real-time hardware.

<model>.sdf This file (called the system description file) is
generated during each build process. It contains information about the
CPU name(s), the corresponding object file(s) to be downloaded and
the corresponding variable description file(s).

ControlDesk/MLIB/

The following files allow you to access variables of the real-time
simulation.

<[sub]model>.trc RTI generates this variable description file,
which contains the description of all signals and parameters of the
model or submodel. The signals and parameters are ordered according
to the hierarchical structure of the (sub)model. The file is referenced by
the SDF file of the real-time application to allow access to the signals
and parameters of the application, for example, via dSPACE’s
ControlDesk and MLIB/MTRACE. With RTI-MP, it is CPU-specific.
See Variable Description File (TRC File) on page 112 for further
information. For a description of the file syntax, refer to Syntax of the
TRC File

in the ControlDesk Reference.

<[sub]model>_usr.trc This is the user variable description file,
which you can create yourself. If it exists, it is automatically inserted
into the variable description file (<[sub]model>.trc) during the build
process. It lets you specify additional variables that are available for

background image

34

ControlDesk. It may contain entries for internal variables of S-functions
or user-defined libraries. With RTI-MP, it is CPU-specific. You can also
manually merge this file into the <[sub]model>.trc file using the
rti_usrtrcmerge

command (see page 121).

See User Variable Description File (USR.TRC File) on page 120 for
further information. For a description of the file syntax, refer to Syntax
of the TRC File

in the ControlDesk Reference.

<[sub]model>.map The linker generates this linker map file, which
describes the memory layout of a model or submodel. ControlDesk
and MLIB/MTRACE use it to retrieve variable addresses. With RTI-MP, it
is CPU-specific.



Wyszukiwarka

Podobne podstrony:
lab1 12 id 258878 Nieznany
lab1 VHDL
O'Reilly How To Build A FreeBSD STABLE Firewall With IPFILTER From The O'Reilly Anthology
bioinformatyczneBD lab1
Ćw lab1 Gleb wilg gleby OŚ
Architekrura Systemów Lab1
lab1
Lab1 szular
FCKU1 lab1(6na6) id 169034 Nieznany
dsp lab1 id 144058 Nieznany
Spr 1, AGH IMIR Mechanika i budowa maszyn, III ROK, Elementy automatyki przemysłowej, EAP lab1
Lab1 12 odp
Lab1(1)
Build Your Money Muscle EFT version
How to build a Raised Formal Pool
Mekton Zeta Build Sheet
Lab1 PA podstawy PSCAD v2
AKiSO lab1 id 53765 Nieznany
LAB1 4 id 258893 Nieznany

więcej podobnych podstron