MATLAB REAL-TIME WORKSHOP EMBEDDED CODER - S Uživatelský manuál Strana 1

Procházejte online nebo si stáhněte Uživatelský manuál pro ne MATLAB REAL-TIME WORKSHOP EMBEDDED CODER - S. Evaluation of Automatic Code Generation Tools Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk

Shrnutí obsahu

Strany 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

Strany 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

Strany 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

Strany 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

Strany 5 - Acknowledgements

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

Strany 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

Strany 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.

Strany 8

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 14

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

Strany 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

Strany 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

Strany 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

Strany 20

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 26

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 33

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

Strany 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.

Strany 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

Strany 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

Strany 38

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

Strany 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

Strany 40

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

Strany 41

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

Strany 42 - 7.4 The Generated Files

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

Strany 43

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

Strany 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

Strany 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

Strany 46 - Test case 1:

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 55

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

Strany 57

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 66

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

Strany 67

IIIContent Acknowledgements... I 1 Introduction...

Strany 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

Strany 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.

Strany 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

Strany 71 - The Design

65 1. Pressure Controller With Coupling

Strany 73

67Transfrom

Strany 75

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

Strany 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

Komentáře k této Příručce

Žádné komentáře