]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - doc/reports/report/report.t2t
Fixed MOUT driver. Everything is working just niceee.
[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 === Futher improvements ===[futher_improvements]
372
373 - Change name of GPIO MOUT1_EN to MOUT1_DIAG
374 - Change name of GPIO MOUT1_IN to MOUT1_EN
375 This are misleading.
376
377 == Repository branch description ==[repository_branch_description]
378
379
380
381 == Test Suite ==[test_suite]
382
383
384
385 == Static libraries ==[static_libraries]
386
387
388
389 == Base application ==[base_application]
390
391
392
393 == API generation ==[api_generation]
394
395
396
397 == API Reference ==[api_reference]
398
399
400
401 = Simulink RPP Block Library =[simulink_rpp_block_library]
402
403
404
405 == Description ==[description]
406
407
408
409 === C MEX S-Functions ===[c_mex_s_functions]
410
411 Anatomy
412 Compilation
413
414 === Target Language Compiler files ===[target_language_compiler_files]
415
416 Anatomy
417
418 == Repository branch description ==[repository_branch_description]
419
420
421
422 == Block Reference ==[block_reference]
423
424
425
426 = Simulink Demos =[simulink_demos]
427
428
429
430 == Description ==[description]
431
432 Parameters
433 What was tested, resumen.
434
435 == Repository branch description ==[repository_branch_description]
436
437
438
439 == Demos Reference ==[demos_reference]
440
441
442
443 NEWPAGE
444
445 = Glossary =[glossary]
446
447 : ADC
448   //Analog to Digital Converter.//
449   Hardware circuitry that converts a continuous physical quantity (usually voltage) to a
450   digital number that represents the quantity's amplitude.
451
452 : AIN
453   //Analog Input.//
454   Mnemonic to refer to or something related to the analog input (ADC) hardware module.
455
456 : AOUT
457   //Analog Output.//
458   Mnemonic to refer to or something related to the analog output (DAC) hardware module.
459
460 : CAN
461   //Controller Area Network.//
462   The CAN Bus is a vehicle bus standard designed to allow microcontrollers and devices to
463   communicate with each other within a vehicle without a host computer.
464   In this project it is also used as mnemonic to refer to or something related to the CAN
465   hardware module.
466
467 : CGT
468   //Code Generation Tools.//
469   Name given to the tool set produced by Texas Instruments used to compile, link, optimize,
470   assemble, archive, among others. In this project is normally used as synonym for 
471   ``Texas Instruments ARM compiler and linker."
472
473 : DAC
474   //Digital to Analog Converter.//
475   Hardware circuitry that converts a digital (usually binary) code to an analog signal
476   (current, voltage, or electric charge).
477
478 : DIN
479   //Digital Input.//
480   Mnemonic to refer to or something related to the digital input hardware module.
481
482 : ECU
483   //Engine Control Unit.//
484   A type of electronic control unit that controls a series of actuators on an internal combustion 
485   engine to ensure the optimum running.
486
487 : ETH
488   //Ethernet.//
489   Mnemonic to refer to or something related to the Ethernet hardware module.
490
491 : FR
492   //FlexRay.//
493   FlexRay is an automotive network communications protocol developed to govern on-board automotive
494   computing.
495   In this project it is also used as mnemonic to refer to or something related to the FlexRay
496   hardware module.
497
498 : HBR
499   //H-Bridge.//
500   Mnemonic to refer to or something related to the H-Bridge hardware module. A H-Bridge is
501   an electronic circuit that enables a voltage to be applied across a load in either direction.
502
503 : HOUT
504   //High-Power Output.//
505   Mnemonic to refer to or something related to the 10A, PWM, with current sensing, high-power
506   output hardware module.
507
508 : IDE
509   //Integrated Development Environment.//
510   An IDE is a Software application that provides comprehensive facilities to computer programmers 
511   for software development.
512
513 : LIN
514   //Local Interconnect Network.//
515   The LIN is a serial network protocol used for communication between components in vehicles.
516   In this project it is also used as mnemonic to refer to or something related to the LIN
517   hardware module.
518
519 : LOUT
520   //Logic Output.//
521   Mnemonic to refer to or something related to the digital output hardware module.
522   It is logic output (100mA), as opposed to power outputs (2A, 10A).
523
524 : MBD
525   //Model-Based Design.//
526   Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated 
527   with designing complex control, signal processing and communication systems.
528
529 : MEX
530   //Matlab Executable.//
531   Type of binary executable that can be called within Matlab. In this document the common term
532   used is `C MEX S-Function", which means Matlab executable written in C that implements a system 
533   function.
534
535 : MOUT
536   //(Motor) Power Output.//
537   Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
538
539 : RPP
540   //Rapid Prototyping Platform//.
541   Name of the automotive hardware board. Also generic term to define something related
542   to the board, like the RPP Library, RPP Layer, RPP API, etc.
543
544 : SCI
545   //Serial Communication Interface.//
546   Serial Interface for communication through hardware's UART using communication standard RS-232.
547   In this project it is also used as mnemonic to refer to or something related to the Serial
548   Communication Interface hardware module.
549
550 : SDC
551   //SD-Card.//
552   Mnemonic to refer to or something related to the SD-Card hardware module.
553
554 : SDR
555   //SD-RAM.//
556   Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
557
558 : TLC
559   //Target Language Compiler.//
560   Technology and language used to generate code in Matlab/Simulink.
561
562 : UART
563   //Universal Asynchronous Receiver/Transmitter.//
564   Hardware circuitry that translates data between parallel and serial forms.
565
566
567
568 NEWPAGE
569
570 = References =[references]
571
572 - Horn, M. (2013). //Software obsluhující periferie a flexray na automobilové rídicí jednotce//.
573   (Unpublished master's thesis, Czech Technical University in Prague, Prague, Czech Republic).
574
575 - //Model-based design//. (n.d.). In Wikipedia. 
576   Retrieved March 10, 2013, from http://en.wikipedia.org/wiki/Model-based_design
577
578
579 NEWPAGE
580
581 = Appendix A: Notes on FreeRTOS memory managment =[appendix_a_notes_on_freertos_memory_managment]
582
583 Write about heap implementation, FreeRTOSConfig.h heap size, C heap size, C stack size, Simulink memory, among others.
584