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
14 %S = Table of contents =[table_of_contents]
22 = Introduction =[introduction]
24 This document describes the final results of the project ``Code generation for automotive rapid prototyping
25 platform using Matlab/Simulink".
27 The general layout of this document is as follows:
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.
37 == Background ==[background]
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.
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:
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.
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
64 == Technologies involved ==[technologies_involved]
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.
75 == Objectives ==[objectives]
79 Main objectives of this project are:
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.
85 At the time of this writing the objectives of this project are considered successfully achieved.
87 == Benefits ==[benefits]
91 Expected benefits of this project are:
93 + Enabling faster implementation and rapid-prototyping of Software components through the use of model-based
95 + Enabling better and clearer visualization of Software implementations for the hardware board through models.
96 + Improve auditability of Software system for automotive applications.
99 At the time of this writing the benefits of this project are considered enabled.
101 == Final outcome ==[final_outcome]
103 The main products generated for this project are:
105 - Simulink RPP Target.
106 - RPP Library and API.
107 - Simulink RPP Block Library.
108 - Simulink Demo Library.
111 Each of this product is described deeply in the following sections.
113 = Project setup =[project_setup]
115 This sections describes the Software and Hardware setup for development. It also describes the layout of the project
118 == Development environment ==[development_environment]
120 This section describes the Software setup for development.
122 === Operating system ===[operating_system]
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
128 - Ubuntu 12.04.2 LTS AMD64.
129 - Kernel 3.2.0-48-generic.
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:
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 ``/``.
154 === Version Control System ===[version_control_system]
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:
162 sudo apt-get install git gitk
165 === TI Code Composer Studio ===[ti_code_composer_studio]
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.
170 === Matlab/Simulink ===[matlabsimulink]
174 === GtkTerm ===[gtkterm]
178 === Doxygen ===[doxygen]
182 === Nested ===[nested]
190 == Hardware configuration ==[hardware_configuration]
194 === Modules description ===[modules_description]
196 Image of hardware modules.
198 ==== Logic IO ====[logic_io]
202 ===== 16x digital input (DIN) =====[16x_digital_input_din]
204 - Read status via GPIO pin (configurable threshold).
205 - Read status via SPI pin (fixed threshold).
206 - Setting pin programmable via SPI.
209 ===== 8x digital outputs for loads up to 100 mA (LOUT) =====[8x_digital_outputs_for_loads_up_to_100_ma_lout]
213 - Reading the SPI status excitation.
215 ===== 12x analog-to-digital converter =====[12x_analog_to_digital_converter]
217 - Reading values on all channels.
219 ===== 4x digital-to-analog converter =====[4x_digital_to_analog_converter]
221 - Set the required voltage on all channels.
223 ==== Power Output ====[power_output]
227 ===== 1x H-Bridge =====[1x_h_bridge]
229 - Setting the direction.
231 - Communication with excitation by SPI.
235 ===== 6x outputs for loads up to 2 A (MOUT) =====[6x_outputs_for_loads_up_to_2_a_mout]
239 - Reading diagnostics values (DIAG).
241 ===== 6x output up to 10 A with PWM (HOUT) =====[6x_output_up_to_10_a_with_pwm_hout]
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.
250 ==== Communication ====[communication]
254 ===== 3x CAN High speed =====[3x_can_high_speed]
256 - Sending and receiving messages between the CAN bus interfaces.
257 - Recover from error.
258 - Detection of network errors.
260 ===== 2x LIN =====[2x_lin]
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.
264 ===== 1x FlexRay =====[1x_flexray]
266 - Sending and receiving messages between two plates JRVA.
269 ===== 1x Serial Comm. Interface =====[1x_serial_comm_interface]
273 ===== 1x Ethernet =====[1x_ethernet]
276 - Code for testing Ethernet is the result of this thesis and is therefore not analyzed.
278 ==== Data storage/logging ====[data_storagelogging]
282 ===== External Memory SDRAM =====[external_memory_sdram]
284 - Determine the total capacity of the module fitted.
285 - Performing a memory test module using the entire address range.
288 ===== SD Card =====[sd_card]
292 === Development and test wiring ===[development_and_test_wiring]
294 How to wire the board for testing.
296 == Repository structure ==[repository_structure]
299 The repository is hosted on the server of the Real-Time Systems group at the Department
300 of Control Engineering
302 = Programming standards =[programming_standards]
306 == TLC files ==[tlc_files]
310 == RPP API ==[rpp_api]
314 == S-Functions ==[s_functions]
318 = Simulink RPP Target =[simulink_rpp_target]
322 == Description ==[description]
326 === Code generation process ===[code_generation_process]
330 == Repository branch description ==[repository_branch_description]
334 == Installation procedure ==[installation_procedure]
338 == Target Reference ==[target_reference]
341 Simulink model options
343 = RPP Library and API =[rpp_library_and_api]
347 == Description ==[description]
349 Talk about motivation, work done and compare against origin.
351 === Architecture ===[architecture]
355 === Modules ===[modules]
359 === OS interchangeable layer ===[os_interchangeable_layer]
363 === Development guidelines ===[development_guidelines]
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.
371 === Futher improvements ===[futher_improvements]
373 - Change name of GPIO MOUT1_EN to MOUT1_DIAG
374 - Change name of GPIO MOUT1_IN to MOUT1_EN
377 == Repository branch description ==[repository_branch_description]
381 == Test Suite ==[test_suite]
385 == Static libraries ==[static_libraries]
389 == Base application ==[base_application]
393 == API generation ==[api_generation]
397 == API Reference ==[api_reference]
401 = Simulink RPP Block Library =[simulink_rpp_block_library]
405 == Description ==[description]
409 === C MEX S-Functions ===[c_mex_s_functions]
414 === Target Language Compiler files ===[target_language_compiler_files]
418 == Repository branch description ==[repository_branch_description]
422 == Block Reference ==[block_reference]
426 = Simulink Demos =[simulink_demos]
430 == Description ==[description]
433 What was tested, resumen.
435 == Repository branch description ==[repository_branch_description]
439 == Demos Reference ==[demos_reference]
445 = Glossary =[glossary]
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.
454 Mnemonic to refer to or something related to the analog input (ADC) hardware module.
458 Mnemonic to refer to or something related to the analog output (DAC) hardware module.
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
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."
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).
480 Mnemonic to refer to or something related to the digital input hardware module.
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.
489 Mnemonic to refer to or something related to the Ethernet hardware module.
493 FlexRay is an automotive network communications protocol developed to govern on-board automotive
495 In this project it is also used as mnemonic to refer to or something related to the FlexRay
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.
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.
509 //Integrated Development Environment.//
510 An IDE is a Software application that provides comprehensive facilities to computer programmers
511 for software development.
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
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).
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.
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
536 //(Motor) Power Output.//
537 Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
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.
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.
552 Mnemonic to refer to or something related to the SD-Card hardware module.
556 Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
559 //Target Language Compiler.//
560 Technology and language used to generate code in Matlab/Simulink.
563 //Universal Asynchronous Receiver/Transmitter.//
564 Hardware circuitry that translates data between parallel and serial forms.
570 = References =[references]
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).
575 - //Model-based design//. (n.d.). In Wikipedia.
576 Retrieved March 10, 2013, from http://en.wikipedia.org/wiki/Model-based_design
581 = Appendix A: Notes on FreeRTOS memory managment =[appendix_a_notes_on_freertos_memory_managment]
583 Write about heap implementation, FreeRTOSConfig.h heap size, C heap size, C stack size, Simulink memory, among others.