]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - doc/reports/report/report.t2t
ea9315b03e9398e003e9b7b23e868e5cbce31e1d
[pes-rpp/rpp-simulink.git] / doc / reports / report / report.t2t
1 Final Report
2 Carlos Jenkins
3 %%date(%B, %Y)
4
5 %!target: tex
6 %!style(xhtmls): media/themes/Clean/style.css
7 %!postproc(xhtmls): 'NEWPAGE' ''
8 %!nested(xhtmls): --libs syntaxhighlighter
9 %!options(tex): --enum-title --toc --toc-level 5
10 %!postproc(tex): '\.pdf\.png' '.pdf'
11 %!postproc(tex): 'NEWPAGE' '\\newpage'
12 %!nested(tex): --docclass {article} --pdf
13
14 %S = Table of contents =[table_of_contents]
15
16 %Table of contents
17 %%toc
18
19 NEWPAGE
20
21
22 = Introduction =[introduction]
23
24 This document describes the final results of the project ``Code generation for automotive rapid prototyping 
25 platform using Matlab/Simulink".
26
27 The general layout of this document is as follows:
28
29 - Project description, objetives and outcome. This section.
30 - Software and Hardware setup for development and repository layout.
31 - Extensive description for each of the four products delivered.
32 - Glossary.
33 - References.
34 - Appendices.
35
36
37 == Background ==[background]
38
39 %DONE
40
41 Back in the beginning of 2012 a leading automotive company requested the Czech Technical University 
42 to develop a Engine Control Unit (ECU) for automotive applications. Real-Time Systems group at the 
43 Department of Control Engineering from the Faculty of Electrical Engineering developed a hardware and 
44 Software platform to the needs of this industry. The hardware uses Texas Instruments TMS570LS3137 CPU 
45 and has was built with automotive standards and interfaces in mind. It uses a real-time operating 
46 system and was directly programmed in C.
47
48 Nevertheless, in accordance to company policies the Software developed for the engine control unit must be 
49 designed in a safe and auditable way. The company has the policy to implement the Software for their 
50 system using Model-Based Design:
51
52         Model-Based Design (MBD) is a mathematical and visual method of addressing 
53         problems associated with designing complex control, signal processing and 
54         communication systems. It is used in many motion control, industrial equipment, 
55         aerospace, and automotive applications. Model-based design is a methodology 
56         applied in designing embedded software.
57
58 In order to meet this requirement an interaction layer between the platform and the Software the company 
59 uses, Matlab/Simulink, must be implemented. This document describes the implementation of this interaction
60 system.
61
62 NEWPAGE
63
64 == Technologies involved ==[technologies_involved]
65
66 %DONE
67
68 + Matlab/Simulink data flow graphical programming language tool for modeling, simulating and analyzing 
69   multidomain dynamic systems.
70 + Standard ANSI C programming.
71 + FreeRTOS real-time operating system.
72 + Texas Instruments TI Code Generation Tools (CGT).
73 + RPP in-house automotive hardware board using Texas Instruments TMS570LS3137 CPU.
74
75 == Objectives ==[objectives]
76
77 %DONE
78
79 Main objectives of this project are:
80
81 + Allow C code generation from Matlab/Simulink models for custom made hardware platform.
82 + Implement model blocks for some of the peripheral units of the board for use in Simulink programming.
83
84
85 At the time of this writing the objectives of this project are considered successfully achieved.
86
87 == Benefits ==[benefits]
88
89 %DONE
90
91 Expected benefits of this project are:
92
93 + Enabling faster implementation and rapid-prototyping of Software components through the use of model-based 
94   programming.
95 + Enabling better and clearer visualization of Software implementations for the hardware board through models.
96 + Improve auditability of Software system for automotive applications.
97
98
99 At the time of this writing the benefits of this project are considered enabled.
100
101 == Final outcome ==[final_outcome]
102
103 The main products generated for this project are:
104
105 - Simulink RPP Target.
106 - RPP Library and API.
107 - Simulink RPP Block Library.
108 - Simulink Demo Library.
109
110
111 Each of this product is described deeply in the following sections.
112
113 = Project setup =[project_setup]
114
115 This sections describes the Software and Hardware setup for development. It also describes the layout of the project
116 repository.
117
118 == Development environment ==[development_environment]
119
120 This section describes the Software setup for development.
121
122 === Operating system ===[operating_system]
123
124 This project was developed on a GNU/Linux operating system. For development it is recommended to use a Debian based 
125 operating system for development as most of the tools are easily available from repositories. Relevant OS information 
126 is:
127
128 - Ubuntu 12.04.2 LTS AMD64.
129 - Kernel 3.2.0-48-generic.
130 - GCC version 4.6.3.
131
132
133 No test for cross-platform interoperability was performed on the code developed. Although care was taken to try to 
134 provide platform independent code and tools this are the elements that are know to be Linux dependent:
135
136 - LCM1 hardware control tool. @@
137   This tool is both GUI and command line capable, the following just affects the GUI part. 
138   Command line should be usable under Windows systems. @@
139   __Cause__: Serial port search algorithm is Linux dependent and Gtk 3.0 dynamic Python bindings aren't available on 
140   Windows operating systems.
141 - TI CGT support file for RPP Simulink Target ````target_tools.mk``". @@
142   __Cause__: Use UNIX path separator ``/``.
143 - Simulink RPP Target download script ````rpp_download.m``". @@
144   __Cause__: Use UNIX path separator ``/``.
145 - Simulink RPP Target install script ````rpp_setup.m``". @@
146   __Cause__: Use UNIX path separator ``/``.
147 - Simulink RPP Block Library block compilation script ````compile_blocks.m``". @@
148   __Cause__: Call Matlab MEX executable with Unix name.
149 - All CCS projects under ``<repo>/rpp/lib/apps/``. @@
150   __Cause__: Paths are configure using UNIX path separator ``/``.
151
152
153
154 === Version Control System ===[version_control_system]
155
156 The version control system used for this project is **git**. The repository of this project
157 contains all the files produced during development, including documentation, references, code and
158 graphics. Also the GUI application **gitk** was used to easily review changes. To install both
159 execute on a terminal:
160
161 {{{ bash
162 sudo apt-get install git gitk
163 }}}
164
165 === TI Code Composer Studio ===[ti_code_composer_studio]
166
167 Code Composer Studio (CCS) is the official integrated development environment for developing applications 
168 for Texas Instruments embedded processors. CCS is multiplatform Software based on Eclipse Open Source IDE.
169
170 === Matlab/Simulink ===[matlabsimulink]
171
172
173
174 === GtkTerm ===[gtkterm]
175
176
177
178 === Doxygen ===[doxygen]
179
180
181
182 === Nested ===[nested]
183
184
185
186 === LMC1 ===[lmc1]
187
188
189
190 == Hardware configuration ==[hardware_configuration]
191
192 Photo of the board
193
194 === Modules description ===[modules_description]
195
196 Image of hardware modules.
197
198 ==== Logic IO ====[logic_io]
199
200
201
202 ===== 16x digital input (DIN) =====[16x_digital_input_din]
203
204 - Read status via GPIO pin (configurable threshold).
205 - Read status via SPI pin (fixed threshold).
206 - Setting pin programmable via SPI.
207
208
209 ===== 8x digital outputs for loads up to 100 mA (LOUT) =====[8x_digital_outputs_for_loads_up_to_100_ma_lout]
210
211 - Set pin ON.
212 - Set pin OFF.
213 - Reading the SPI status excitation.
214
215 ===== 12x analog-to-digital converter =====[12x_analog_to_digital_converter]
216
217 - Reading values on all channels.
218
219 ===== 4x digital-to-analog converter =====[4x_digital_to_analog_converter]
220
221 - Set the required voltage on all channels.
222
223 ==== Power Output ====[power_output]
224
225
226
227 ===== 1x H-Bridge =====[1x_h_bridge]
228
229 - Setting the direction.
230 - Switch on, off.
231 - Communication with excitation by SPI.
232 - Enable PWM.
233
234
235 ===== 6x outputs for loads up to 2 A (MOUT) =====[6x_outputs_for_loads_up_to_2_a_mout]
236
237 - Set pin ON.
238 - Set pin OFF.
239 - Reading diagnostics values (DIAG).
240
241 ===== 6x output up to 10 A with PWM (HOUT) =====[6x_output_up_to_10_a_with_pwm_hout]
242
243 - Set pin ON.
244 - Set pin OFF.
245 - Reading analog values of current flowing (IFBK).
246 - Reading diagnostics values (DIAG).
247 - Detection of a fault condition.
248 - Turn on the PWM pin.
249
250 ==== Communication ====[communication]
251
252
253
254 ===== 3x CAN High speed =====[3x_can_high_speed]
255
256 - Sending and receiving messages between the CAN bus interfaces.
257 - Recover from error.
258 - Detection of network errors.
259
260 ===== 2x LIN =====[2x_lin]
261
262 - Testing least one LIN using a loop. The second connector is shared with serial interface, which is tested alone communicate with the computer. Detailed testing makes sense to be no support for access to diagnostics unit via Ethernet or other interface.
263
264 ===== 1x FlexRay =====[1x_flexray]
265
266 - Sending and receiving messages between two plates JRVA.
267
268
269 ===== 1x Serial Comm. Interface =====[1x_serial_comm_interface]
270
271
272
273 ===== 1x Ethernet =====[1x_ethernet]
274
275 - To send a packet.
276 - Code for testing Ethernet is the result of this thesis and is therefore not analyzed.
277
278 ==== Data storage/logging ====[data_storagelogging]
279
280
281
282 ===== External Memory SDRAM =====[external_memory_sdram]
283
284 - Determine the total capacity of the module fitted.
285 - Performing a memory test module using the entire address range.
286
287
288 ===== SD Card =====[sd_card]
289
290
291
292 === Development and test wiring ===[development_and_test_wiring]
293
294 How to wire the board for testing.
295
296 == Repository structure ==[repository_structure]
297
298
299 The repository is hosted on the server of the Real-Time Systems group at the Department
300 of Control Engineering
301
302 = Programming standards =[programming_standards]
303
304
305
306 == TLC files ==[tlc_files]
307
308
309
310 == RPP API ==[rpp_api]
311
312
313
314 == S-Functions ==[s_functions]
315
316
317
318 = Simulink RPP Target =[simulink_rpp_target]
319
320
321
322 == Description ==[description]
323
324
325
326 === Code generation process ===[code_generation_process]
327
328
329
330 == Repository branch description ==[repository_branch_description]
331
332
333
334 == Installation procedure ==[installation_procedure]
335
336
337
338 == Target Reference ==[target_reference]
339
340 RPP Target Options
341 Simulink model options
342
343 = RPP Library and API =[rpp_library_and_api]
344
345
346
347 == Description ==[description]
348
349 Talk about motivation, work done and compare against origin.
350
351 === Architecture ===[architecture]
352
353
354
355 === Modules ===[modules]
356
357
358
359 === OS interchangeable layer ===[os_interchangeable_layer]
360
361
362
363 === Development guidelines ===[development_guidelines]
364
365 - Documentation in headers.
366 - Non-doxygen documentation in source code is intended for developpers, not users.
367 - Standard datatypes for IO when possible. Use custom structs as last resort.
368 - Prefix based functions names.
369 - To be careful about symbol export.
370
371 == Repository branch description ==[repository_branch_description]
372
373
374
375 == Test Suite ==[test_suite]
376
377
378
379 == Static libraries ==[static_libraries]
380
381
382
383 == Base application ==[base_application]
384
385
386
387 == API generation ==[api_generation]
388
389
390
391 == API Reference ==[api_reference]
392
393
394
395 = Simulink RPP Block Library =[simulink_rpp_block_library]
396
397
398
399 == Description ==[description]
400
401
402
403 === C MEX S-Functions ===[c_mex_s_functions]
404
405 Anatomy
406 Compilation
407
408 === Target Language Compiler files ===[target_language_compiler_files]
409
410 Anatomy
411
412 == Repository branch description ==[repository_branch_description]
413
414
415
416 == Block Reference ==[block_reference]
417
418
419
420 = Simulink Demos =[simulink_demos]
421
422
423
424 == Description ==[description]
425
426 Parameters
427 What was tested, resumen.
428
429 == Repository branch description ==[repository_branch_description]
430
431
432
433 == Demos Reference ==[demos_reference]
434
435
436
437 NEWPAGE
438
439 = Glossary =[glossary]
440
441 : ADC
442   //Analog to Digital Converter.//
443   Hardware circuitry that converts a continuous physical quantity (usually voltage) to a
444   digital number that represents the quantity's amplitude.
445
446 : AIN
447   //Analog Input.//
448   Mnemonic to refer to or something related to the analog input (ADC) hardware module.
449
450 : AOUT
451   //Analog Output.//
452   Mnemonic to refer to or something related to the analog output (DAC) hardware module.
453
454 : CAN
455   //Controller Area Network.//
456   The CAN Bus is a vehicle bus standard designed to allow microcontrollers and devices to
457   communicate with each other within a vehicle without a host computer.
458   In this project it is also used as mnemonic to refer to or something related to the CAN
459   hardware module.
460
461 : CGT
462   //Code Generation Tools.//
463   Name given to the tool set produced by Texas Instruments used to compile, link, optimize,
464   assemble, archive, among others. In this project is normally used as synonym for 
465   ``Texas Instruments ARM compiler and linker."
466
467 : DAC
468   //Digital to Analog Converter.//
469   Hardware circuitry that converts a digital (usually binary) code to an analog signal
470   (current, voltage, or electric charge).
471
472 : DIN
473   //Digital Input.//
474   Mnemonic to refer to or something related to the digital input hardware module.
475
476 : ECU
477   //Engine Control Unit.//
478   A type of electronic control unit that controls a series of actuators on an internal combustion 
479   engine to ensure the optimum running.
480
481 : ETH
482   //Ethernet.//
483   Mnemonic to refer to or something related to the Ethernet hardware module.
484
485 : FR
486   //FlexRay.//
487   FlexRay is an automotive network communications protocol developed to govern on-board automotive
488   computing.
489   In this project it is also used as mnemonic to refer to or something related to the FlexRay
490   hardware module.
491
492 : HBR
493   //H-Bridge.//
494   Mnemonic to refer to or something related to the H-Bridge hardware module. A H-Bridge is
495   an electronic circuit that enables a voltage to be applied across a load in either direction.
496
497 : HOUT
498   //High-Power Output.//
499   Mnemonic to refer to or something related to the 10A, PWM, with current sensing, high-power
500   output hardware module.
501
502 : IDE
503   //Integrated Development Environment.//
504   An IDE is a Software application that provides comprehensive facilities to computer programmers 
505   for software development.
506
507 : LIN
508   //Local Interconnect Network.//
509   The LIN is a serial network protocol used for communication between components in vehicles.
510   In this project it is also used as mnemonic to refer to or something related to the LIN
511   hardware module.
512
513 : LOUT
514   //Logic Output.//
515   Mnemonic to refer to or something related to the digital output hardware module.
516   It is logic output (100mA), as opposed to power outputs (2A, 10A).
517
518 : MBD
519   //Model-Based Design.//
520   Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated 
521   with designing complex control, signal processing and communication systems.
522
523 : MEX
524   //Matlab Executable.//
525   Type of binary executable that can be called within Matlab. In this document the common term
526   used is `C MEX S-Function", which means Matlab executable written in C that implements a system 
527   function.
528
529 : MOUT
530   //(Motor) Power Output.//
531   Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
532
533 : RPP
534   //Rapid Prototyping Platform//.
535   Name of the automotive hardware board. Also generic term to define something related
536   to the board, like the RPP Library, RPP Layer, RPP API, etc.
537
538 : SCI
539   //Serial Communication Interface.//
540   Serial Interface for communication through hardware's UART using communication standard RS-232.
541   In this project it is also used as mnemonic to refer to or something related to the Serial
542   Communication Interface hardware module.
543
544 : SDC
545   //SD-Card.//
546   Mnemonic to refer to or something related to the SD-Card hardware module.
547
548 : SDR
549   //SD-RAM.//
550   Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
551
552 : TLC
553   //Target Language Compiler.//
554   Technology and language used to generate code in Matlab/Simulink.
555
556 : UART
557   //Universal Asynchronous Receiver/Transmitter.//
558   Hardware circuitry that translates data between parallel and serial forms.
559
560
561
562 NEWPAGE
563
564 = References =[references]
565
566 - Horn, M. (2013). //Software obsluhující periferie a flexray na automobilové rídicí jednotce//.
567   (Unpublished master's thesis, Czech Technical University in Prague, Prague, Czech Republic).
568
569 - //Model-based design//. (n.d.). In Wikipedia. 
570   Retrieved March 10, 2013, from http://en.wikipedia.org/wiki/Model-based_design
571
572
573 NEWPAGE
574
575 = Appendix A: Notes on FreeRTOS memory managment =[appendix_a_notes_on_freertos_memory_managment]
576
577 Write about heap implementation, FreeRTOSConfig.h heap size, C heap size, C stack size, Simulink memory, among others.
578