ISSN 0280-5316 ISRN LUTFD2/TFRT--5793--SE Evaluation of Automatic Code Generation Tools Nora Ajwad Department of Automatic Control Lund University Ap
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
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
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
52 Automatic Code Generation Tools Manufacturers 2.1 dSPACE – Solutions for Control dSPACE develops and distributes integrated electronics and softw
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
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.
8 Variable Class Object Description Memory GLOBAL Normal global variables RAM CAL Global calibratable parameters ROM DISP Global observable varia
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
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
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
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
133.2.6 MISRA C, Platform Dependency and Different Microprocessors Support Real-Time Workshop Embedded Coder supports most of MISRA-C code standard
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
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
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
18
195 Haldex Traction Specific Requirements In this chapter specific Haldex Traction requirements are investigated in both TargetLink and Real-Time Wor
20supported by TargetLink: the user can either generate a separate structure for every parameter set or generate an array of structures containing al
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
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
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
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
24Data Dictionary Object Description Variable Defines the properties of a variable in the C code. All kinds of variables are supported: plain varia
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
266.2 Supported Simulink Blocks and Their Properties 6.2.1 TargetLink In a TargetLink subsystem the user can use TargetLink simulation blocks, Targe
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
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
29specific data information in the block untouched when running the automatic scaling tool. Output data type and output offset are examples of block
30
317 Miscellaneous 7.1 Own Experiences As a beginner working with TargetLink was easier than working with Real-Time Workshop Embedded Coder. TargetLin
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.
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
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
35<subsystem>.h Provides the declerations of global variables and functions defined in <subsystem>.c. The variables and the functions
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
378 Results A comparison between the simulation results in Simulink and the simulation results in the respective tool was done. Four different simul
38Test case 1: Figure 12: Test case 1- constant pressure set points and constant differential speed
39Test case 2: Figure 13: Test case 2- varying pressure set point and constant differential speed
40Test case 3: Figure 14: Test case 3- constant pressure set point and varying differential speed
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
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
42Test case 4: Figure 15: Test case 4- Extern VCS control with constant pressure set points and constant differential speed
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
44Test case 1: Figure 16: Test case 1 - handwritten code where actual pressure = 0.6MPa Figure 17: Test case 1 - TargetLink generated code, actu
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
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
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
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
49
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
51Reference [1] Haldex Traction AB (2007). Technical Information [www]. Information from <http://www.haldex-traction.com> 19/03/07 [2] dSPACE
52Appendix I: Notations Symbols Description Unit vcs Valve characteristic signal 3msPa ⋅ p Clutch pressure Pa bp Base pressure Pa spp Pressu
53Abbreviations HLSC Haldex Limited Slip Coupling RTW EC Real-Time Workshop Embedded Coder TL TargetLink MIL Model In the Loop SIL Softw
54Appendix II: TargetLink Blocks TargetLink has its own blocksets and some Simulink supported blocks. All the blocks below are supported in code gen
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
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
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
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
59Sublibrary Block Fixed-Point Support Code Generation Support Signal Routing Bus Creator X X Bus selector X X Bus Assignment X X Data Stor
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
61Support Generation Support Increment/ Decrement Increment Real World X X (C4) Decrement real World X X (C4) Increment Stored Integer X X (C
IIIContent Acknowledgements... I 1 Introduction...
62for more optimal code generation. In certain cases, grouping can be achieved by configuring the masked subsystem block to execute as an atomic unit
63Appendix IV: Pressure Controller – The Design The tested model is a design of a pressure controller that is used in Haldex Traction base software.
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
65 1. Pressure Controller With Coupling
663. PID Controller
67Transfrom
IV6.3.1 TargetLink....... 28 6.3.2 Real-Time Workshop
11 Introduction 1.1 Background Haldex Traction AB is part of the Haldex Group, which consists of four product divisions: Haldex Brake Systems, Haldex
Kommentare zu diesen Handbüchern