+ All Categories
Home > Documents > Live&Debugging&of&Stateflow&ChartsWhile& Running&on&ECU · September(2015(I 1...

Live&Debugging&of&Stateflow&ChartsWhile& Running&on&ECU · September(2015(I 1...

Date post: 08-Jul-2018
Category:
Upload: builiem
View: 218 times
Download: 0 times
Share this document with a friend
27
September 2015 I 1 Property of Valeo. Duplication prohibited September 2015 Property of Valeo. Duplication prohibited Live Debugging of Stateflow Charts While Running on ECU Amjad Elshenawy & Mohammad Raouf Mathworks Automotive Conference 2015 Stuttgart, Sep., 24 th 2015 GEEDS Group Electronics Expertise and Development Services
Transcript

September 2015 I 1Property of Valeo. Duplication prohibited

September 2015

Property of Valeo. Duplication prohibited

Live Debugging of Stateflow Charts While Running on ECU

Amjad Elshenawy & Mohammad Raouf

Mathworks Automotive Conference 2015Stuttgart, Sep., 24th 2015

GEEDS -­ Group Electronics Expertise and Development Services

September 2015 I 2Property of Valeo. Duplication prohibited

Table of contents

Testing & Debugging Techniques in MBD

Focus on « Simulink External Mode »

Valeo Solution in Details

Conclusion

1

2

4

3

3

12

17

25

September 2015 I 3Property of Valeo. Duplication prohibited

Testing & Debugging Techniques in MBD

Focus on « Simulink External Mode »

Valeo Solution in Details

Conclusion

1

2

4

3

3

12

17

25

September 2015 I 4Property of Valeo. Duplication prohibited

Testing in Model Based Design

Model-­In-­the-­LoopTest

Controller Model

Plant Model or Stimulion PC

Software-­In-­the-­LoopTest

C-­Code on Host PC

Plant Model or Stimulion PC

Processor-­In-­the-­LoopTest

C-­Code on Target μController

Plant Model or Stimulion PC

Hardware-­In-­the-­LoopTest

C-­Code on ECU

Plant Modelon HIL Simulator

On VehicleTest

C-­Code on ECU

What happens if a test case fails?

How to debug in X-­In-­the-­Loop testing?

How to debug on Vehicle?

September 2015 I 5Property of Valeo. Duplication prohibited

Debugging in Model-­In-­the-­Loop (MIL) Testing

Signal Analysis

Scopes and Signal ViewersSignal Loggingetc …

Simulink Blocks Stateflow ChartsStateflow Chart Animation

Stateflow Breakpoints and Watch Data

September 2015 I 6Property of Valeo. Duplication prohibited

Debugging in Software-­In-­the-­Loop (SIL) & Processor-­In-­the-­Loop (PIL) Testing

Signal Analysis

Scopes and Signal ViewersSignal Loggingetc …

Simulink Blocks Stateflow ChartsStateflow Chart Animation in “External Mode”

Chart local data can be viewed on signal viewers by designating them to be test points

Some Limitations Exist forinternal Signal Logging

September 2015 I 7Property of Valeo. Duplication prohibited

Debugging in Hardware-­In-­the-­Loop (HIL) & On Vehicle Testing

Design phase

Identify debugging variablesDeclare debugging variables as “Global Variables” (they will have Fixed Memory Address)

Validation phase

ECU

Generated Code from Model

xCP / CCP Driver

CAN Driver

Debug Monitor

TestTool

Data Measurement

xCP / CCP Driver

CAN Driver

Parameter Tuning

CAN Communication

September 2015 I 8Property of Valeo. Duplication prohibited

Debugging in Hardware-­In-­the-­Loop (HIL) & On Vehicle Testing

Data acquisition and signal plotting

Parameter tuning

Simulink BlocksRegime_moteur

tr/min

15 21 27 33 39 45 51 57 63 69 75

2960

2529

2098

1667

1236

805

Temps : 58.52Regime_moteur : 2492

Temps : 34.22Regime_moteur : 2603

Temps : 43.79Regime_moteur : 2450

Vitesse_vehicule

km/h

15 21 27 33 39 45 51 57 63 69 75

121

97

73

48

24

0

Temps : 58.52Vitesse_vehicule : 70

Temps : 34.22Vitesse_vehicule : 33

Temps : 43.79Vitesse_vehicule : 49

Avance_finale

øVil

15 21 27 33 39 45 51 57 63 69 75

57

34

11

-­11

-­34

-­57

Temps : 58.52Avance_finale : 31.125

Temps : 34.22Avance_finale : 47.25

Temps : 43.79Avance_finale : 51.75

Engine_load Av_dr_deg_rendement_totale

% %

15 21 27 33 39 45 51 57 63 69 75

100

80

60

40

20

0

100

80

60

40

20

0

Temps : 58.52Engine_load : 61.952547Av_dr_deg_rendement_totale : 0

Temps : 34.22Engine_load : 35.390991Av_dr_deg_rendement_totale : 1

POL_3011.AQC V:WWAR 077212 POLLU 04/11/30 09:09

September 2015 I 9Property of Valeo. Duplication prohibited

Manually create a debugging variable representing chart statesStateflow Charts – The Classical Way

Debugging in Hardware-­In-­the-­Loop (HIL) & On Vehicle Testing

September 2015 I 10Property of Valeo. Duplication prohibited

Visualize the value of the state variable using the test tool

Run the test case and monitor the state variable

Stateflow Charts – The Classical Way

Debugging in Hardware-­In-­the-­Loop (HIL) & On Vehicle Testing

September 2015 I 11Property of Valeo. Duplication prohibited

Debugging in Hardware-­In-­the-­Loop (HIL) & On Vehicle Testing

Drawbacks of the Classical Way of Debugging Stateflow Charts

Manually Define State VariablesExtra development effort is requiredAdditional memory consumption

Poor Visualization of Statecharts;; No Statechart Animation

Isn’t there a better way to debug Stateflow charts running on ECU?

Valeo solution with visualization and animation of Stateflow models based on “Simulink External Mode” will be presented

Stateflow Charts – The Classical Way

September 2015 I 12Property of Valeo. Duplication prohibited

Testing & Debugging Techniques in MBD

Focus on « Simulink External Mode »

Valeo Solution in Details

Conclusion

1

2

4

3

3

12

17

25

September 2015 I 13Property of Valeo. Duplication prohibited

In “External Mode”, Simulink algorithm is executed outside Simulink environment. Simulink is merely a GUI for:

Visualizing DataAcquiring SignalsTuning Parameters (Provided that parameters are not inlined)

External Mode Interface

TCP/IP or serial

Overview of Simulink External Mode

Simulink Model(The Client)

External Executable(The Server)

September 2015 I 14Property of Valeo. Duplication prohibited

Configure Code Generation in External Mode

In the model «Code Generation» configuration, configure:

« System target file » as « ert.tlc »« Interface » as « External Mode »« Transport Layer » as « tcpip » or « RS-­232 (serial) »

September 2015 I 15Property of Valeo. Duplication prohibited

Steps to start External Mode communication

Build the Target Executable

Both code and external executable are generated

Run the External Executable

Select Simulink simulation as“External” Mode

Connect to the Target

Start Simulation in External Mode

1

2

3

4

5

September 2015 I 16Property of Valeo. Duplication prohibited

External Mode Remarks

External mode uses “Code Instrumentation”Includes extra header filesAdds code for data exchange and for transport layerAdds extra variables

ERT supports only two transport layers, namely, TCP/IP and RS-­232 (serial).No direct support for automotive communication protocols.

September 2015 I 17Property of Valeo. Duplication prohibited

Testing & Debugging Techniques in MBD

Focus on « Simulink External Mode »

Valeo Solution in Details

Conclusion

1

2

4

3

3

12

17

25

September 2015 I 18Property of Valeo. Duplication prohibited

Valeo Solution in Details

To prepare environment, 3 steps are needed

ECU(running inthe car)

Generated code from Stateflow

Model

CAN Bus Interface

Visualization / Animation

September 2015 I 19Property of Valeo. Duplication prohibited

Model State info on ECU

Use Embedded Coder (ert.tlc) to generate a Global structure “DW_<modelName>”, containing active state of each state machine.

typedef struct ...uint8_T is_StateChart_1; /* ... */uint8_T is_StateChart_2; /* ... */uint8_T is_StateChart_3; /* ... */uint8_T is_StateChart_4; /* ... */... DW_<modelName>;

ECU(running inthe car)

Generated code from Stateflow

Model

No need for code instrumentation on Target !

September 2015 I 20Property of Valeo. Duplication prohibited

CAN Bus Interface

1st Step: Exchanging Model States Info from ECU to PC

ECU(running inthe car)

Generated code from Stateflow

Model

XCP / CCPDriver

CANDriver

StateflowModel

CAN Driver

XCP / CCP DriverVa

leo To

ol

Configurations:-­‐ Baud Rate-­‐-­‐ XCP/CCP

-­‐-­‐ CAN/LIN/FlexRay-­‐-­‐ Struct Memory address

Add XCP/CCP and CAN drivers on laptop

Configure reception of data in Valeo Tool

September 2015 I 21Property of Valeo. Duplication prohibited

Modify generated External-­Mode files:

2nd Step: Exchange Received States Info to Simulink Model

ECU(running inthe car)

Generated code from Stateflow

Model

XCP / CCPDriver

CANDriver

StateflowModel

CAN Driver

XCP / CCP Driver

Valeo To

olModified

External-­‐Mode

CAN Bus Interface

September 2015 I 22Property of Valeo. Duplication prohibited

2nd Step: Exchange Received States Info to Simulink Model

StateflowModel

CAN Driver

XCP / CCP Driver

Valeo To

olModified

External-­‐Mode

Modifications in details:

Comments all direct assignation to the states valuesGenerates additional C files that directly update the states value with the values received from ECU

September 2015 I 23Property of Valeo. Duplication prohibited

3rd Step: Final Setup

ECU(running inthe car)

Generated code from Stateflow

Model

XCP / CCPDriver

CANDriver

StateflowModel

« Simulink-­‐to-­‐ECUCommunication »

EXE

Valeo To

ol

Generate executable “Simulink-­to-­ECU Communication”:

CAN Bus Interface

September 2015 I 24Property of Valeo. Duplication prohibited

Exchanges value for animation

Then, launch Stateflow Debugging ActivityUser Valeo Tool Simulink Model Simulink-­to-­ECU

Communication EXE ECU

Starts EXE

Requests to start External Mode Communication

Initiates CommunicationRequests States Value

Sends States Value

Requests States Value

Sends States ValueExchanges value for animation

Request to stop Comm.Kill EXE

……

Request to start Comm.

September 2015 I 25Property of Valeo. Duplication prohibited

Testing & Debugging Techniques in MBD

Focus on « Simulink External Mode »

Valeo Solution in Details

Conclusion

1

2

4

3

3

12

17

25

September 2015 I 26Property of Valeo. Duplication prohibited

Conclusion

Using “Simulink External Mode”,and with our in-­house tool, wewere able to read Statechartinformation in real-­time fromthe ECU and accordinglyanimate Stateflow chartson PC.

This technique facilitates a lotdebugging of Statecharts for on-­vehicle tests.

Next step is to support FlexRay and LIN communication protocols.

September 2015 I 27Property of Valeo. Duplication prohibited


Recommended