Matlab Simulink DLL in CANape

Post on 20-Feb-2015

1.384 views 45 download

Transcript of Matlab Simulink DLL in CANape

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

V2.92 2007-08-08

Matlab/Simulink DLLs in CANape 6.5

Vector Informatik GmbH

Dipl.- Ing. Andreas Patzer

Dipl.- Ing.(FH) Gernot König

2

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information>

3

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Version / Software Information

❑ The Matlab/Simulink Target for CANape supports

❑ Matlab/Simulink Version 7.0, 7.1, 7.2 (R2006a), 7.3 (R2006b), 7.4 (R2007a)

❑ Microsoft C++ Compiler 6.0, 7.1 (Visual Studio 2003) and 8.0 (Visual Studio 2005)

❑ Microsoft C++ Compiler 8.0 needs Matlab Simulink 7.2 (R2006a) atleast

❑ The current CANape Realtime Target 6.2.0 or above is necessary.

❑ To use Simulink DLLs CANape Graph Version 5.0 or above is necessary (CANape 6.5 is recommended).

This documentation is based on Matlab/Simulink 7.4 (R2007a), CANape 6.5and CANape Realtime Target 6.2.2

4

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target>

Version / Software Information

5

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Installation of CANape Realtime Target

❑ Install the CANape Real-Time Target (DLL) for the Matlab/Simulink Real Time Workshop.

❑ The CANape Real-Time Target is included in the CANape MATLAB Integration Package that comes with CANape.

❑ Please find further information in Readme.htm which will be displayed after the installation.

6

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab>

Installation of CANape Realtime Target

Version / Software Information

7

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Configuration of Matlab

❑ Choose your preferred compiler in Matlab by using the command: >> mex –setup

❑ Answer the question:Would you like mex to locate installed compilers [y] /n? with "yes" and make your decision

❑ The Matlab search path (File -> Set Path…) will be set automatically. If your model couldn´tbe created be sure that the following entries are on top of the list

8

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model>

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

9

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink model

❑ Create a new model in Matlab ❑ Start the Library browser

Step 1: new model

10

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink model

❑ The Library Browser displays all available blocksets. For the CANape target there are additional I/O blocksets in "Vector CANape".

❑ Blocksets could be inserted into the model using drag&drop:

❑ Each model should have one input block and one output block at least.

Step 2: Library Browser

11

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink model

❑ Define the symbolic names of the I/O’s in the model via a double click (these names are used by CANape to connect to real measurements/parameters or global variables)

❑ Insert your algorithm

❑ Of course, it is possible toinsert multiple Input-/Output-Blocks

Step 3: Names for I/O´s

In CANape 6.5, the mapping between the model and real signals inCANape can be done by naming conventions. If the same name of an IO in the model and in e.g. an A2L- or DBC-file is used, CANape can map them automatically.

12

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model>

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

13

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink ModelOverview

Simulink Model

Realtime Workshopwith

CANape Target

DLL

❑ The next slides will show how a Simulink DLL is created using the Realtime Workshop with CANape Target.

❑ Then the integration of the Simulink DLL into CANape is shown.

A2L MAP

INI EMFEMFEMF

INI:Model Description file

EMF: Pictures of the model hierarchy

14

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink Model

1. Open an existing model or create one (see chapter "create a simulinkmodel").

2. Select the CNP target in the RealTime Workshop

3. Select fixed step for the running mode of the DLL

4. Select the end time

5. Select and define inline parameters

6. Build the DLL

7. Integrate the DLL into the measurement list of CANape

8. Define the time raster and the synchronization between the signals and the Simulink DLL

HowTo

15

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink Model

Tools->RealTime Workshop->Options

Select CANape (cnp.tlc)Target

Select CANape Target

16

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink Model

Define Output Directory

Select CNP code generation options

Define Output Directory

17

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink ModelTime synchronization between CANape and the model DLL

In the Real Time Workshop a time raster can be defined for the model

❑ Alternative 1:

❑ The Simulink DLL has a time raster defined in the Real Time Workshop options. The DLL gets the actual time from CANape. The DLL itself calculates in the defined time raster.

❑ Alternative 2:

❑ In CANape the time raster of the DLL is defined in the measurement list and is independent from the Real Time Workshop based raster

In both cases CANape and the Simulink DLL are working time synchronized together.

To realize fast communication (time raster below 10ms) between CANape and the model DLL please set the following CANape option:

Tools -> Options-> Driver ->

Make sure that a CANcardXL is used in the system!

18

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink Model

Select “Fixed-Step”

Select “inf” inf means “No stop time”

Select the preferred algorithm

Define time rate of the model 0.1 means: The model is running in a 100ms raster.

“SingleTasking”the DLL is running in one task

Solver options

19

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink Model

Select “Inline parameters” for generating an ASAP2 file (*.A2L)

Inline parameters

20

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Create a Simulink DLL from a Simulink ModelBuild model

Generate the Simulink DLL (Ctrl + B)

The generated files (DLL, A2L, map file and source files) are located under:<model name>_cnp_rtw

21

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters>

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

22

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

❑ Measurement signals and parameters of Simulink blocks that should be accessible by CANape have to be defined as Simulink Data Objects in the MATLAB Workspace with:

X = ASAP2.Parameter or X = ASAP2.Signal

The target will automatically generate an ASAP2 file for the model. Additional information needed in the ASAP2 file has to be added to the Simulink data objects:

Matlab Version 7x.Value = xxxxx.Min = xxxx.Max = xxx

Matlab Version 6x.Value = xxxx.PhysicalMin_ASAP2 = xxxx.PhysicalMax_ASAP2 = xxx

Defining Signals and Parameters

23

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Defining Signals and Parameters

StorageClass„ExportedGlobal“

❑ Signals and Parameters must have Storage Class „Exported Global“

Define range of values

Important:Define a start value e. g. ‘1’

Defining Parameters

24

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Defining Signals and Parameters

1.) Double Click on line2.) Give the line a name

Defining Signals

25

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Defining Signals and Parameters

Define Min, Max

If needed, definea unit for the signal

StorageClass„ExportedGlobal“

Defining Signals

26

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Defining Signals and Parameters

/begin MEASUREMENT

/* Name */ Signal_1

/* Long identifier */ ""

/* Data type */ FLOAT64_IEEE

/* Conversion method */ COMPU_METHOD_1

/* Resolution (Not used) */ 0

/* Accuracy (Not used) */ 0

/* Lower limit */ -100.0

/* Upper limit */ 100.0

ECU_ADDRESS 0

/begin IF_DATA CANAPE_EXT

100

LINK_MAP "Signal_1" 0x0 0x0 0 0x0 0 0x0 0x0

/end IF_DATA

/end MEASUREMENT

Entry in the A2L File

27

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape>

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

28

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

Open the measurement list

29

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

1.) Insert new Simulink model into the measurement list

2.) Select the DLL

3.) The IOs of the model are shown automatically

30

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

Select a device for the automatic link (=map by name).

Link manually the IO’s that couldn’t be linked automatically

31

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

In this case, the input of the model is mapped to a signal ‘channel1’ of the ECU ‘XCPsim’. This signal can be measured in different modes. The selection is done here.

32

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

The output ports of the model are mapped to parameters ‘testword0’ and ‘testword1’ of the ECU XCPsim. The values can be calibrated in different modes. In XCPsim there is only one STIM (stimulation) mode. It’s called ‘FilterBypassSt’. The selection is done here.

With this configuration, a bypassing is establihed.

33

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANapeTime Synchronization between CANape and the Simulink DLL

By selecting the measurement mode of the input signals (in this case ‘channel1’), the model itself will be called by CANape in the same mode (‘on XCPsim 10ms’ event of the ECU).

To measure a signal out of the model, an event in the model can be used. It’s called ‘<modelname> calculated’. This event occurs, after the model is ready with the calculation cycle.

34

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

ECU

XCPsimCANape

Simulink DLL

asap2demo_test1

Cyclic on ECU event ‘10 ms’channel1

testword0testword1

Cyclic on ECU event “10 ms”

Time Synchronization

Download mode

35

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

1. Integrate the model as a device into CANape

2. Select A2L file of the model.

36

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

CANape reads the A2L file and tries to go online with the device. If this does not work, stay offline and open ‘Driver parameters’

37

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

1. Bus type must be ‘USER_DEFINED’

Bus interface ‘<Browse DLL>´

2. Press Configuration and select

3. Select the model.DLL

38

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

Be aware, that the addresses in the A2L file are all initialized with 0000. Make sure that you update your addresses before starting measurement and calibration of the model.

Select the appropriatemap file format

MAP

39

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

Now the DLL is integrated as a Device in CANape, with XCP over DLL port

40

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

Right mouse button, select “Matlab/Simulink window”

With the integration of the Simulink DLL into the measurement list, the DLL is up and running.

Optional:To visualize the Simulink DLL a special window is available. It doesn’t have to be used.

41

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Integrate Simulink DLL into CANape

1.) Select the Simulinkmodel INIfile

2.) Select the device, described with the model A2L

This can be used to show the model in the ‘old’ style

A2L

INI

42

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer>

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

43

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model Explorer

❑ This description based on the functionality of the code generation with RealTime Workshop and the usage of the CANape Target.

❑ In the make process, there is a Matlab call: VSaveModel(‘<modelname>’) to generate the model description file and the EMF files of the model.

❑ If you does not use the CANape Target or even not the RealTimeWorkshop for code generating, you can use the Model Explorer anyway in CANape.

❑ The next slide shows, how to use VSaveModel ()

44

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model Explorer

� Model is developed in Simulink

� Type in Matlab Command Window:

� VSaveModel (‘<Modelname>’)

� (VSaveModel is a Matlab Script developed by Vector which is part of the Matlab Integration Package)

❑ EMF-Files from the model and its subsystems and a description file (INI) are generated, e.g.:

Generate Data Without CANape Target and Realtime Workshop

45

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model ExplorerExample

The Model Explorer shows the Simulink model in nearly the same way like Simulink. To generate the description file and the EMF files, a Matlab / Simulink is necessary.

For the usage of the Model Explorer in CANape, the user does not need an own Matlab / Simulink license.

46

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model ExplorerNavigation

Simple click into subsystem (mouse pointer is shown as a hand) brings you down into the subsystem

Double Click into subsystem brings you up to the higher level hierarchy

47

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model ExplorerNavigation

When a parameter in a block is defined as a A2L parameter, a tooltip occurs.

By double click into the block, the parameter windows come up.

Even the CANape measurements is running, you can open and close the parameter windows.

48

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model Explorer

With extended tool tip, all Simulink

parameters are shown

The standard tool tip, shoes the A2L-File parameters

Navigation

Right mouse click into Explorer:

Zoom in and out

49

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model Explorer

Right mouse click onto an object, offers the possibility to find the object in the model.

Drag the object and drop it into an already existing window or into CANape to open a new window.

Navigation

50

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model ExplorerNavigation

Insert search string

Type, name and path will be shown directly

Right mouse click onto the object let you jump directly to the right page and the object will flash 3 times to show the position

51

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Model Explorer

� To find the object in the model, select the object in the tree with a right mouse click and select ‘Display in the graphic’.

� The explorer will show the right hierarchy layer and the object will slowly flash 3 times.

� Just the other way round: Right mouse click on the object in the picture and the object is highlighted in the tree.

Flashing!

52

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement>

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

53

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Right mouse button, select “Insert measurement signal”

The DLL can be used in the online mode as mentioned before.

Use Case 1: Simulink DLL during Online Measurement

54

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 1: Simulink DLL during Online Measurement

Alternative 1:

❑ The output is assigned to an adjustable parameter

❑ By inserting the DLL as a signal, the time raster will be shown.

55

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 1: Simulink DLL during Online Measurement

Alternative 2:

❑ The output is assigned to "function result"

❑ By inserting the DLL as a signal, the result of the Simulink DLL is displayed

56

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 1: Simulink DLL during Online MeasurementSignal measurement out of the Model

Model

CANape

ECU

‘XCPsim’

DAQ:channel1channel2

flag_subsystem1

Event:‘10ms’

channel1channel2flag_subsystem1

Model will be called, every time, the input signals are available

Input

Output

STIM:testword0testword1testword2testwod3

Event:‘FilterBypassS’

57

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 1: Simulink DLL during Online MeasurementRepresentation in the Model Configuration

58

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 1: Simulink DLL during Online MeasurementRepresentation in the Measurement list

The model itself is called with the event of the input signals

The internal signal is measured after the model is completely calculated

The stimulated signal is measured with the stimulation event (only available with XCP)

59

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool>

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

60

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Example: Two signals from the file “Canape.MDF”

Right mouse button into the window

Select “Insert virtual file channel …”or press Shift+F7

Use Case 2: Simulink DLL as an Offline Analyzing Tool

61

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Select “Matlab DLL”

Select the DLL

Use Case 2: Simulink DLL as an Offline Analyzing Tool

62

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Select the signals from the file and map them to the In-/Outputs of the model or link them automatically

The disc symbol shows that thesource of the signal is a file.

Select a time raster. Normally the fastest time raster of one of the input signals fits best.

Select time range of the calculation. You can eitheruse an explicit time range.

Use Case 2: Simulink DLL as an Offline Analyzing Tool

63

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Now an additional signal is integrated. The signal is calculatedthrough the Simulink DLL.

Use CasesUse Case 2: Simulink DLL as an Offline Analyzing Tool

64

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

1.) right mouse button ->“Save signals”

2.) Select time range and store signals in new file

Use Case 2: Simulink DLL as an Offline Analyzing Tool

65

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL

Use Case 3: Bypassing with XCP>

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

66

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

Bypassing can be realized by making use of Synchronous Data Acquisition and Synchronous Data Stimulation simultaneously.

ECU

1. 2.1. Synchronous Data AcQuisition (DAQ)2. Synchronous Data Stimulation (STIM)

67

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

ECU.A2L

Use Case 3: Bypassing with XCP

1.

Simulink DLL2.

3.

4.

PC

Signal path1. Receiving signals from the ECU (DAQ)2. Sending the signals as an input into the DLL3. Sending the results back to CANape4. Sending the results back to the ECU (STIM)Calibration path5. Calibration of the ECU (XCP)6. Calibration of the DLL like an ECU with XCP

Model.A2L6.

5.

ECU

XCP

Communication flow for a bypassing use case

68

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

Definition of the Stimulation Event for:4. Sending the results back to the ECU (STIM)

Use events channels with STIM capability only!

This event channel cannot be used for bypassing

therefore:

69

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

Model I/O-name ECU-I/O-nameSum_in1 channel1Sum_in2 channel2Sum_out limit

70

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

ECU

XCPsim

SimulinkDLL

“m_sum”

Cyclic on ECU event “10 ms”channel1channel2

limit

Cyclic on ECU event “10 ms”

The „stimulate“ mode is available in version 5.6and above.

71

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

Data from CANape to the ECU

Data from ECU to CANape

72

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

Using bypassing, the normal standard PC is the platform for the running model. In the example, the measurement was running 6 h!

Time Delay

0

50000

100000

150000

200000

250000

300000

350000

400000

450000

Time

/ ms

0,20

480,

4096

0,61

440,

8192

1,02

4

1,22

881,

4336

1,63

841,

8432

2,04

82,

2528

2,45

762,

6624

2,86

72

3,07

2

3,27

68

Time Delay

Bypassing time measured in the ECU!

Latency range: 0,4 – 1,6ms

tn1 tn2∆t = n1 tn2

ECU.A2L

1.

2.

3.

4.

PC

Model.A2L6.

5.

ECU

XCP

ECU.A2L

1.

Simulink DLL2.

3.

4.

PC

Model.A2L6.

5.

ECU

XCP

73

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 3: Bypassing with XCP

on RS 232

slaveslave

SxI

ETH ETH

DPRAM

ETH

RS 232

CAN

slave

Ethernet

CAN

slave

USB

USB

DLL

slave

on ##

on CANon USB

on SxI

on Etherneton Etherneton Ethernet

slave slave slave

LIN

LIN

on LIN

F

L

X

on FlexRay

FlexRay

slave

74

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Agenda

Use Case 4: Generate CAN Messages with Simulink DLL>

Use Case 3: Bypassing with XCP

Use Case 2: Simulink DLL as an Offline Analyzing Tool

Use Case 1: Simulink DLL during Online Measurement

Model Explorer

Integrate Simulink DLL into CANape

Defining Signals and Parameters

Create a Simulink DLL from a Simulink Model

Create a Simulink model

Configuration of Matlab

Installation of CANape Realtime Target

Version / Software Information

75

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

❑ Integrate a new Device

❑ Select “CAN” as the driver type

❑ Select a matching DBC file as the database

Use Case 4: Generate CAN Messages with Simulink DLL

76

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Map the output value of the DLL to the signal in the DBC

Use Case 4: Generate CAN Messages with Simulink DLL

Start measurement in CANape. By changing the value of the selected signal ‘Kanal1’, CANape will generate a new message and send it to the bus.

77

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Use Case 4: Generate CAN Messages with Simulink DLL

This message was generated by CANape, cause the DLL changed the value of the signal ‘Kanal1’

78

© 2007. Vector Informatik GmbH. All rights reserved. Any distribution or copying is subject to prior written approval by Vector.

Slide:

Thank you for your attention.

For detailed information about Vector

and our products please have a look at:

www.vector-informatik.com

Author:

andreas.patzer@vector-informatik.de

gernot.koenig@vector-informatik.de

Vector Informatik GmbH

Ingersheimerstr. 24

70499 Stuttgart

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, Embedded MATLAB, and PolySpace are trademarks of The

MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders.