MATLAB REAL-TIME WORKSHOP EMBEDDED CODER - S Instrukcja Użytkownika

Przeglądaj online lub pobierz Instrukcja Użytkownika dla Nie MATLAB REAL-TIME WORKSHOP EMBEDDED CODER - S. Evaluation of Automatic Code Generation Tools Instrukcja obsługi

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj

Podsumowanie treści

Strona 1 - Code Generation Tools

ISSN 0280-5316 ISRN LUTFD2/TFRT--5793--SE Evaluation of Automatic Code Generation Tools Nora Ajwad Department of Automatic Control Lund University Ap

Strona 2

2A tool for automatic generation of code is desirable to save time and avoid programming errors that can be made by the programmer. 1.2 Purpose The

Strona 3 - SE-221 00 Lund Sweden

3 Figure 2: A simple model built in TargetLink TargetLink generates C code for the model shown above in just one click giving the C code shown belo

Strona 4

4 Other C- and h-files are generated for the model to specify a header-file, the base types, e.g. Int32, and the data types, e.g. CONTINUOUS in the

Strona 5 - Acknowledgements

52 Automatic Code Generation Tools Manufacturers 2.1 dSPACE – Solutions for Control dSPACE develops and distributes integrated electronics and softw

Strona 6

62.2.1 Support The MathWorks in Stockholm has been very supportive during this work. A contact person was assigned to help throughout testing and eva

Strona 7 - Content

73 Code generation 3.1 TargetLink TargetLink makes it easy to generate code since everything related to the code generation is gathered in one place.

Strona 8

8 Variable Class Object Description Memory GLOBAL Normal global variables RAM CAL Global calibratable parameters ROM DISP Global observable varia

Strona 9 - 1 Introduction

93.1.5 External Function Calls and S-function Support Function calls to hardware are sometimes replaced with a subsystem in the simulation model whi

Strona 10 - 1.3 Target Group

103.2 Real-Time Workshop Embedded Coder Real-Time Workshop Embedded Coder is a well integrated tool in Simulink. To generate code for fixed-point a

Strona 11

11 Figure 3: Subsystem parameter dialog pane 3.2.3 Code Interface Real-Time Workshop Embedded Coder cannot offer the user full control over the gene

Strona 13 - Manufacturers

12 Figure 4: RTW EC - non-reusable code options for release 2007a 3.2.4 Simulation Using the Generated Code To compare between a fixed-point simula

Strona 14

133.2.6 MISRA C, Platform Dependency and Different Microprocessors Support Real-Time Workshop Embedded Coder supports most of MISRA-C code standard

Strona 16

154 Analysis of the Generated Code 4.1 Memory Usage RAM, ROM and Execution Time To make a comparison between the generated code and the hand written

Strona 17

16TargetLink: C__I16FITI32_SAT is a function called in more than one place in the code. Real-Time Workshop Embedded Coder: In the process one t

Strona 18

174.2 Readability and Traceability 4.2.1 TargetLink The generated code is well documented and follows the model designed in TargetLink. Any block i

Strona 20

195 Haldex Traction Specific Requirements In this chapter specific Haldex Traction requirements are investigated in both TargetLink and Real-Time Wor

Strona 21 - Stockholm

20supported by TargetLink: the user can either generate a separate structure for every parameter set or generate an array of structures containing al

Strona 22

215.2 Real-Time Workshop Embedded Coder No parameter set approach is available in RTW EC yet. After discussing the idea with Roger Aarenstrup, senio

Strona 23

Document name MASTER THESIS Date of issue April 2007 Lund University Department of Automatic Control Box 118 SE-221 00 Lund Sweden Document Number IS

Strona 24

22 In another file, which is not generated from the model above, the following code can be used to specify the parameter sets: Calibratable par

Strona 25

236 Simulation and Modelling 6.1 Usability How easy and how practical it is to use the code generation tools is investigated in this chapter. Simul

Strona 26

24Data Dictionary Object Description Variable Defines the properties of a variable in the C code. All kinds of variables are supported: plain varia

Strona 27 - Requirements

25If a TargetLink license is not available a model can still be run in Model In the Loop mode, which means that the model runs with floating-point. T

Strona 28

266.2 Supported Simulink Blocks and Their Properties 6.2.1 TargetLink In a TargetLink subsystem the user can use TargetLink simulation blocks, Targe

Strona 29

27 Some blocks have overflow protection. Blocks like Gain block can saturate the output if the latter increases or decreases the desired maximum or m

Strona 30

28value. To solve this kind of problem a conversion rule is made to use the entire number range provided by an integer and to be able to shift this r

Strona 31 - 6 Simulation and Modelling

29specific data information in the block untouched when running the automatic scaling tool. Output data type and output offset are examples of block

Strona 33

317 Miscellaneous 7.1 Own Experiences As a beginner working with TargetLink was easier than working with Real-Time Workshop Embedded Coder. TargetLin

Strona 35 - 6.3 Fixed-Point Support

32The other approach was to manually exchange the function call in the generated code. The function call is made in one place only in the whole code.

Strona 36 - OxSx +⋅= ´

33 Another issue that was a problem in both TargetLink and Real-Time Workshop Embedded Coder was the definition of the base data types. Depending on

Strona 37

34 Figure 11: Multiplication block in RTW EC with the right options 7.2 Generated Warnings Both TargetLink and Real-Time Workshop Embedded Coder give

Strona 38

35<subsystem>.h Provides the declerations of global variables and functions defined in <subsystem>.c. The variables and the functions

Strona 39 - 7 Miscellaneous

36 rtwtypes.h Defines data types, structures and macros required by Real-Time Workshop Embedded Coder generated code. ert_main.c This file is gen

Strona 40

378 Results A comparison between the simulation results in Simulink and the simulation results in the respective tool was done. Four different simul

Strona 41

38Test case 1: Figure 12: Test case 1- constant pressure set points and constant differential speed

Strona 42 - 7.4 The Generated Files

39Test case 2: Figure 13: Test case 2- varying pressure set point and constant differential speed

Strona 43

40Test case 3: Figure 14: Test case 3- constant pressure set point and varying differential speed

Strona 44

41The above figures show the simulations for different inputs for the system. It is clear that the controller acts in the same in all simulations, wh

Strona 45 - 8 Results

IAcknowledgements During this work many people have helped and supported me and I would like to thank all of them. First I want to express my grati

Strona 46 - Test case 1:

42Test case 4: Figure 15: Test case 4- Extern VCS control with constant pressure set points and constant differential speed

Strona 47 - Test case 2:

43TargetLink and RTW EC give the same result in the simulation for test case 4. As shown in Figure 16 for test case 4, the result is a signal which d

Strona 48 - Test case 3:

44Test case 1: Figure 16: Test case 1 - handwritten code where actual pressure = 0.6MPa Figure 17: Test case 1 - TargetLink generated code, actu

Strona 49

45 Figure 18: Test case 1- Real-Time Workshop Embedded Coder generated code, actual pressure=0.6MPa Test case 2: Figure 19: Test case 2 - handwri

Strona 50 - Test case 4:

46 Figure 20: Test case 2 - TargetLink generated code, actual pressure = 1.2MPa Figure 21: Test case 2 - Real-Time Workshop Embedded Coder code, a

Strona 51

47actual pressure will follow the set points. The actual pressure is not changed during this test because it is a predefined value that the user sets

Strona 52

489 Conclusions This work was aimed at comparing two automatic code generating tools and find which of these tools is more suitable for Haldex Tracti

Strona 54

5010 Further Studies In this work only code generation has been evaluated and tested. However more studies can be done related to integration with a

Strona 55

51Reference [1] Haldex Traction AB (2007). Technical Information [www]. Information from <http://www.haldex-traction.com> 19/03/07 [2] dSPACE

Strona 57

52Appendix I: Notations Symbols Description Unit vcs Valve characteristic signal 3msPa ⋅ p Clutch pressure Pa bp Base pressure Pa spp Pressu

Strona 58 - 10 Further Studies

53Abbreviations HLSC Haldex Limited Slip Coupling RTW EC Real-Time Workshop Embedded Coder TL TargetLink MIL Model In the Loop SIL Softw

Strona 59 - Reference

54Appendix II: TargetLink Blocks TargetLink has its own blocksets and some Simulink supported blocks. All the blocks below are supported in code gen

Strona 60 - Appendix I: Notations

55 Data Store Write X X Data Store Memory X X Data Store Read X X Custom Code Block X X Merge X X Sink X X Bus Inport X X Bus Outpor

Strona 61 - Abbreviations

56 To Workspace X X From X X Goto Tag Visibility X X Goto X X Data Type Conversion X X Model Info X X Configurable Subsystem X X Switch

Strona 62

57Appendix III: Real-Time Workshop Embedded Coder Blocks All blocks that can generate code and support fixed-point are marked with X under the corres

Strona 63

58Math Operations Abs X X Assignment X X (N2) Complex to Real-Imag X X Dot Product X X Gain X X Math Function (magnitude^2) X X Math Functi

Strona 64

59Sublibrary Block Fixed-Point Support Code Generation Support Signal Routing Bus Creator X X Bus selector X X Bus Assignment X X Data Stor

Strona 65 - Embedded Coder Blocks

60 Saturation Dynamic X X (C4) Wrap To Zero X X (C5) Sublibrary Block Fixed-Point Support Code Generation Support Lookup Tables Lookup Table X

Strona 66

61Support Generation Support Increment/ Decrement Increment Real World X X (C4) Decrement real World X X (C4) Increment Stored Integer X X (C

Strona 67

IIIContent Acknowledgements... I 1 Introduction...

Strona 68

62for more optimal code generation. In certain cases, grouping can be achieved by configuring the masked subsystem block to execute as an atomic unit

Strona 69

63Appendix IV: Pressure Controller – The Design The tested model is a design of a pressure controller that is used in Haldex Traction base software.

Strona 70

64Appendix V: Simulink Model The PID controller described in Appendix IV is easy to build in Simulink. Every part of the controller is built in a se

Strona 71 - The Design

65 1. Pressure Controller With Coupling

Strona 73

67Transfrom

Strona 75

IV6.3.1 TargetLink....... 28 6.3.2 Real-Time Workshop

Strona 76

11 Introduction 1.1 Background Haldex Traction AB is part of the Haldex Group, which consists of four product divisions: Haldex Brake Systems, Haldex

Komentarze do niniejszej Instrukcji

Brak uwag