]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - doc/reports/report1/publish/tex/report1.tex
1e9f733a51db498fcb725d293699b46743e00119
[pes-rpp/rpp-simulink.git] / doc / reports / report1 / publish / tex / report1.tex
1 \newcommand{\superscript}[1]{\ensuremath{^{\textrm{\small#1}}}}
2 \newcommand{\subscript}[1]{\ensuremath{_{\textrm{\small#1}}}}
3
4 \documentclass{article}
5
6 \usepackage{graphicx} % images and graphics
7 \usepackage{paralist} % needed for compact lists
8 \usepackage[normalem]{ulem} % needed by strike
9 \usepackage{listings} % required for code blocks
10 \usepackage[urlcolor=blue,colorlinks=true,hyperfootnotes=false]{hyperref} % links
11 \usepackage[utf8]{inputenc}  % char encoding
12 \usepackage[bottom]{footmisc} % footnotes
13
14 % header
15 \usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
16 \usepackage{float} % To fix images position
17
18 % Prettify code documentation
19 \usepackage{color}
20 \definecolor{gray97}{gray}{.97}
21 \definecolor{gray75}{gray}{.75}
22 \definecolor{gray45}{gray}{.45}
23 \lstset{ frame=Ltb,
24      framerule=0pt,
25      aboveskip=0.5cm,
26      framextopmargin=3pt,
27      framexbottommargin=3pt,
28      framexleftmargin=0.4cm,
29      framesep=0pt,
30      rulesep=.4pt,
31      backgroundcolor=\color{gray97},
32      rulesepcolor=\color{black},
33      %
34      stringstyle=\ttfamily,
35      showstringspaces = false,
36      basicstyle=\small\ttfamily,
37      commentstyle=\color{gray45},
38      keywordstyle=\bfseries,
39      %
40      numbers=left,
41      numbersep=15pt,
42      numberstyle=\tiny,
43      numberfirstline = false,
44      breaklines=true,
45      xleftmargin=20px,
46    }
47
48 % Spacing
49 \addtolength{\parskip}{\baselineskip} % Paragraph spacing
50 \linespread{1.15} % Lines spacing
51 \setlength{\plitemsep}{0.5\baselineskip} % List items spacing
52 \definecolor{deepblue}{RGB}{0,0,61}
53 \hypersetup{linkcolor=deepblue,}
54
55 % Table of content depth
56 \setcounter{tocdepth}{4}
57
58 % Landscape pages
59 \usepackage{lscape}
60 \usepackage{pdflscape}
61
62 % Change page
63 \usepackage{changepage}
64
65 % Font options
66 % Sans-serif
67 % \renewcommand{\familydefault}{\sfdefault}
68 % Better PDF font
69 \usepackage{lmodern}
70
71 % Multiple columns
72 \usepackage{multicol}
73
74 \begin{document}
75
76 % Title
77 \newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
78
79 \begin{titlepage}
80 \begin{center}
81
82 % Upper part of the page
83 \includegraphics[width=0.70\textwidth]{media/images/logos.png}\\[1cm]
84 \textsc{\LARGE Costa Rica Institute of Technology}\\[0.5cm]
85 \textsc{\LARGE Czech Technical University in Prague}\\[1.5cm]
86 \textsc{\Large Undergraduate project}\\[0.5cm]
87
88
89 % Document title
90 \HRule \\[0.4cm]
91 { \huge \bfseries Progress report 1}\\[0.4cm]
92 \HRule \\[1.5cm]
93
94
95 % Author
96 \emph{Author:}\\
97 Carlos \textsc{Jenkins}\\
98
99 \vfill
100
101 % Bottom of the page
102 {\large \today}
103
104 \end{center}
105 \end{titlepage}
106 % Title end
107
108 \tableofcontents
109
110 \newpage
111
112 \hypertarget{introduction}{}
113 \section{Introduction}
114
115 This document describes the first progress report for the project ``Code generation for automotive 
116 rapid prototyping platform using Matlab/Simulink" executed on the first semester of 2013 at the 
117 Department of Control Engineering, Faculty of Electrical Engineering, Czech Technical University, 
118 as part of the specialty practice for applying for the Computer Engineering Bachelor degree at the 
119 Costa Rica Institute of Technology.
120
121 This report aims to outline the context, risks, goals and scope of the project and to describe
122 the system to develop.
123
124 \hypertarget{project_context}{}
125 \section{Project context}
126
127 This section describes the institution where the project is held and the background of the project.
128
129 \hypertarget{institution}{}
130 \subsection{Institution}
131
132 The project is being held at the Real-Time Systems group, Department of Control Engineering,
133 Faculty of Electrical Engineering from the Czech Technical University in Prague.
134
135 The head of the department is Dr. Zdeněk Hanzálek, Director Industrial Informatics Group, 
136 Department of Control Engineering, Faculty of Electrical Engineering, Czech Technical University 
137 in Prague.
138
139 Professor Assistant Ing. Michal Sojka Ph.D., Department of Control Engineering, Faculty of 
140 Electrical Engineering, Czech Technical University in Prague, will held as supervisor of the 
141 project.
142
143 \hypertarget{background}{}
144 \subsection{Background}
145
146 Back in the beginning of 2012 a leading automotive company requested the Czech Technical University
147 to develop a Engine Control Unit (ECU) for automotive applications. Real-Time Systems group at the
148 Department of Control Engineering from the Faculty of Electrical Engineering developed a hardware
149 and Software platform to the needs of this industry. The hardware uses Texas Instruments
150 TMS570LS3137 CPU and is built with automotive standards and interfaces in mind. It uses a real-time
151 operating system and was directly programmed in C.
152
153 As will later be described, the automotive company needs to program such board in a different
154 environment.
155
156 \hypertarget{problem_description}{}
157 \section{Problem description}
158
159 This section describes the problem faced with this project and the solution aimed.
160
161 \hypertarget{problem_statement}{}
162 \subsection{Problem statement}
163
164 The board is programmed using hand written C code. This approach faces the following problems about 
165 the code:
166
167 \begin{compactitem}
168 \item It is hard to produce, sometimes very low-level.
169 \item It is hard to debug. Yes, 1 bit took us 4 hours.
170 \item It requires good knowledge of the underlying hardware.
171 \item Most of the time is non-portable or hard to port between platforms.
172 \item It is hard to audit and certify. 
173 \end{compactitem}
174
175 In consequence, the automotive company established policies that stipulate that the Software 
176 developed for the engine control unit must be designed in a safe and auditable way. The company has 
177 the policy to implement the Software for their system using Model-Based Design:
178
179         \begin{quotation}
180 Model-Based Design (MBD) is a mathematical and visual method of addressing
181 problems associated with designing complex control, signal processing and
182 communication systems. It is used in many motion control, industrial equipment,
183 aerospace, and automotive applications. Model-based design is a methodology
184 applied in designing embedded software.
185         \end{quotation}
186
187 In order to meet this requirement an interaction layer between the platform and the Software the
188 company uses, Matlab/Simulink, must be implemented.
189
190 \hypertarget{solution_statement}{}
191 \subsection{Solution statement}
192
193 The solution for project problem is to implement and Simulink target that allows models to generate 
194 code for the board. Such models needs to interact with board peripherals and in consequence driver 
195 blocks need to be implemented too. Finally, driver blocks need to generate code on top of a well 
196 tested C support library that include drivers and Operating System for the board.
197
198 \hypertarget{project_stackeholders}{}
199 \subsection{Project stackeholders}
200
201 Main project stackeholders are:
202
203 \begin{enumerate}
204 \item Dr. Zdeněk Hanzálek. Director Industrial Informatics Group, Department of Control Engineering, 
205   Faculty of Electrical Engineering, Czech Technical University in Prague. As director of the 
206   department, Dr. Hanzálek has no direct responsibility on the project but has direct 
207   responsibility on the success oof the main project. \newline{}
208   Main interest of Dr. Hanzálek is the success of the project in order to enable the success of the
209   mother project (board development for automotive applications) and to maintain the high prestige
210   and confidence the industry has over the department and the university.
211
212 \item Ing. Michal Sojka Ph.D. Professor Assistant, Department of Control Engineering, Faculty of 
213   Electrical Engineering, Czech Technical University in Prague. CVUT project supervisor, 
214   co-responsible for grade the student. \newline{}
215   Ing. Sojka main interest in the project is the success and implementation of the solution.
216
217 \item Prof. Jeff Schmidt Peralta. Computer Engineering Professor, Faculty of Computer Engineering,
218   Costa Rica Institute of Technology. ITCR project supervisor, co-responsible for grade the 
219   student. \newline{}
220   Prof. Schmidt main interest is the success of the project in order to enable student to opt-out 
221   for Bachelor degree and to maintain and develop the high prestige the university currently held.
222 \end{enumerate}
223
224 \hypertarget{summary_of_needs_and_expectations}{}
225 \subsection{Summary of needs and expectations}
226
227 Project needs are summarized as:
228
229 \begin{compactenum}
230 \item To have a fully automatic and tested system for Simulink models code generation, build and code 
231   download to the hardware board.
232 \item To have a fully tested C support library for those models to link to.
233 \item To have a set of Simulink driver blocks that allows models to interact with the hardware 
234   peripherals.
235 \end{compactenum}
236
237 Expected benefits of this project are:
238
239 \begin{compactenum}
240 \item Enabling faster implementation and rapid-prototyping of Software components through the use of
241   model-based programming.
242 \item Enabling better and clearer visualization of Software implementations for the hardware board
243   through models.
244 \item Improve auditability of Software system for automotive applications.
245 \end{compactenum}
246
247 \hypertarget{perspective_assumptions_and_product_dependencies}{}
248 \subsection{Perspective, assumptions and product dependencies}
249
250 The main assumptions for the project are:
251
252 \begin{compactitem}
253 \item Drivers work and are tested.
254 \item Hardware works and is tested.
255 \end{compactitem}
256
257 Main dependencies for the system to develop are:
258
259 \begin{compactitem}
260 \item A functional board.
261 \item For each deliverable previous deliverable is required to work and be tested in order to implement
262   the new deliverable. This dependency over the previous product makes the project very dificult to 
263   develop in parallel. The following arrows show system dependency: \newline{}
264   Demos \noindent$\rightarrow$ Block Library \noindent$\rightarrow$ Target \noindent$\rightarrow$ Support Library.
265 \end{compactitem}
266
267 \hypertarget{non_functional_requirements}{}
268 \subsection{Non-functional requirements}
269
270 Two main requirements are stipulated according automotive safety policies:
271
272 \begin{compactitem}
273 \item The use of a real-time Operating System is mandatory.
274 \item Application should be real-time and guarantee to respond in one Operating System tick time.
275 \item All memory should be statically allocated, there should never be dynamically allocated memory.
276 \end{compactitem}
277
278 \hypertarget{risk_analysis}{}
279 \section{Risk analysis}
280
281 This section describes the risk that could be encountered during the execution of the project
282 and the containment and evasion strategies considered.
283
284 \hypertarget{unkown_development_environment_and_tools}{}
285 \subsection{Unkown development environment and tools}
286
287 This is the most important risk for the project and involves the lack of technical knowledge and
288 the introduction of the student to a completely new environment, API, processes, tools, hardware 
289 and code base. The student is has never being exposed to any of the tools in the environment with 
290 exception of C embedded development.
291
292 \begin{compactitem}
293 \item \textbf{Category:} people.
294 \item \textbf{Possible cause}: lack of technical knowledge.
295 \item \textbf{Impact for the project}: 100.
296 \item \textbf{Probability to happen}: 1.0.
297 \item \textbf{Exposition to risk}: 100 * 1.0 = 100\%.
298 \item \textbf{Evasion strategy}:
299  \begin{compactitem}
300  \item This risk cannot be evaded.
301  \end{compactitem}
302 \item \textbf{Mitigation strategy}: 
303  \begin{compactitem}
304  \item Read technical documentation about tools.
305  \item Read existing code base.
306  \item Learn to use new development tools.
307  \item Document every aspect of the use.
308  \item Learn to use, manipulate and understand the hardware.
309  \end{compactitem}
310 \end{compactitem}
311
312 \newpage
313
314 \hypertarget{board_malfunction}{}
315 \subsection{Board malfunction}
316
317 \begin{compactitem}
318 \item \textbf{Category:} infrastructure.
319 \item \textbf{Possible cause}: hardware error, mishandling or environment.
320 \item \textbf{Impact for the project}: 80.
321 \item \textbf{Probability to happen}: 0.5.
322 \item \textbf{Exposition to risk}: 80 * 0.5 = 40\%.
323 \item \textbf{Evasion strategy}:
324  \begin{compactitem}
325  \item Board should always be handled in a safe manner, using anti-static methods.
326  \item Connection 
327  \item Power supply connections will always be double checked.
328  \item Environment around the board and board connections will be checked twice before powering on the 
329    board.
330  \end{compactitem}
331 \item \textbf{Mitigation strategy}: 
332  \begin{compactitem}
333  \item Ask to supervisor to check the problem.
334  \item Replace development board to another available board. Very expensive choice.
335  \end{compactitem}
336 \end{compactitem}
337
338 \hypertarget{goals_and_system_scope}{}
339 \section{Goals and system scope}
340
341 This section describes the goals and scope of the project.
342
343 \hypertarget{objectives}{}
344 \subsection{Objectives}
345
346 Main objectives of this project are:
347
348 \begin{compactenum}
349 \item Allow C code generation from Matlab/Simulink models for custom made hardware platform.
350 \item Implement model blocks for some of the peripheral units of the board for use in Simulink 
351   programming.
352 \end{compactenum}
353
354 \hypertarget{specific_objectives}{}
355 \subsection{Specific objectives}
356
357 Specific objectives of this project are:
358
359 \begin{compactenum}
360 \item Implementation of a C support library that defines an API that can be called by Simulink blocks.
361   The support library should include a test suite that allows to test and confirm the correct 
362   behavior of the library.
363 \item Implementation of a Simulink Coder Target for the RPP board that uses the CGT compiler.
364 \item Implementation of a Simulink Block Library that includes the main block drivers for the RPP 
365   board.
366 \item Implementation of a set of demos that illustrates the use of the system and confirms the correct 
367   behavior of the implementation.
368 \end{compactenum}
369
370 \hypertarget{system_scope}{}
371 \subsection{System scope}
372
373 For the C support library, the test suite of such library and the block library should limit to
374 the following hardware modules:
375
376 \begin{multicols}{2}
377
378 \begin{compactitem}
379 \item DIN.
380 \item LOUT.
381 \item AIN.
382 \item AOUT.
383 \item HBR.
384 \item MOUT.
385 \item SCI.
386 \item SDR.
387 \end{compactitem}
388
389 \end{multicols}
390
391 \hypertarget{development_inputs}{}
392 \section{Development inputs}
393
394 This section describes conceptual inputs for development.
395
396 \hypertarget{use_case_diagram}{}
397 \subsection{Use case diagram}
398
399 This project is focused in embedded Software development in a non-object oriented programming
400 language and thus is not driven with a Use Case methodology. In consequence, this section does not 
401 apply.
402
403 \hypertarget{use_cases_specification}{}
404 \subsection{Use cases specification}
405
406 This project is focused in embedded Software development in a non-object oriented programming
407 language and thus is not driven with a Use Case methodology. In consequence, this section does not 
408 apply.
409
410 \hypertarget{domain_conceptual_model}{}
411 \subsection{Domain conceptual model}
412
413 \begin{figure}[H]\begin{center}
414
415 \noindent\includegraphics[width=400px]{media/images/tlc_process.png}
416 \caption{Conceptual code generation process.}\end{center}\end{figure}
417
418 \newpage
419
420 \hypertarget{glossary}{}
421 \subsection{Glossary}
422
423 \begin{description}
424 \item[ADC]
425   \textit{Analog to Digital Converter.} \newline{}
426   Hardware circuitry that converts a continuous physical quantity (usually voltage) to a
427   digital number that represents the quantity's amplitude.
428
429 \item[AIN]
430   \textit{Analog Input.} \newline{}
431   Mnemonic to refer to or something related to the analog input (ADC) hardware module.
432
433 \item[AOUT]
434   \textit{Analog Output.} \newline{}
435   Mnemonic to refer to or something related to the analog output (DAC) hardware module.
436
437 \item[CAN]
438   \textit{Controller Area Network.} \newline{}
439   The CAN Bus is a vehicle bus standard designed to allow microcontrollers and devices to
440   communicate with each other within a vehicle without a host computer.
441   In this project it is also used as mnemonic to refer to or something related to the CAN
442   hardware module.
443
444 \item[CGT]
445   \textit{Code Generation Tools.} \newline{}
446   Name given to the tool set produced by Texas Instruments used to compile, link, optimize,
447   assemble, archive, among others. In this project is normally used as synonym for
448   ``Texas Instruments ARM compiler and linker."
449
450 \item[DAC]
451   \textit{Digital to Analog Converter.} \newline{}
452   Hardware circuitry that converts a digital (usually binary) code to an analog signal
453   (current, voltage, or electric charge).
454
455 \item[DIN]
456   \textit{Digital Input.} \newline{}
457   Mnemonic to refer to or something related to the digital input hardware module.
458
459 \item[ECU]
460   \textit{Engine Control Unit.} \newline{}
461   A type of electronic control unit that controls a series of actuators on an internal combustion
462   engine to ensure the optimum running.
463
464 \item[ETH]
465   \textit{Ethernet.} \newline{}
466   Mnemonic to refer to or something related to the Ethernet hardware module.
467
468 \item[FR]
469   \textit{FlexRay.} \newline{}
470   FlexRay is an automotive network communications protocol developed to govern on-board automotive
471   computing.
472   In this project it is also used as mnemonic to refer to or something related to the FlexRay
473   hardware module.
474
475 \item[GPIO]
476   \textit{General Purpose Input/Output.} \newline{}
477   Generic pin on a chip whose behavior (including whether it is an input or output pin) can be
478   controlled (programmed) by the user at run time.
479
480 \item[HBR]
481   \textit{H-Bridge.} \newline{}
482   Mnemonic to refer to or something related to the H-Bridge hardware module. A H-Bridge is
483   an electronic circuit that enables a voltage to be applied across a load in either direction.
484
485 \item[HOUT]
486   \textit{High-Power Output.} \newline{}
487   Mnemonic to refer to or something related to the 10A, PWM, with current sensing, high-power
488   output hardware module.
489
490 \item[IDE]
491   \textit{Integrated Development Environment.} \newline{}
492   An IDE is a Software application that provides comprehensive facilities to computer programmers
493   for software development.
494
495 \item[LCT]
496   \textit{Legacy Code Tool.} \newline{}
497   Matlab tool that allows to generate source code for S-Functions given the descriptor of a C 
498   function call.
499
500 \item[LIN]
501   \textit{Local Interconnect Network.} \newline{}
502   The LIN is a serial network protocol used for communication between components in vehicles.
503   In this project it is also used as mnemonic to refer to or something related to the LIN
504   hardware module.
505
506 \item[LOUT]
507   \textit{Logic Output.} \newline{}
508   Mnemonic to refer to or something related to the digital output hardware module.
509   It is logic output (100mA), as opposed to power outputs (2A, 10A).
510
511 \item[MBD]
512   \textit{Model-Based Design.} \newline{}
513   Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated
514   with designing complex control, signal processing and communication systems.
515
516 \item[MEX]
517   \textit{Matlab Executable.} \newline{}
518   Type of binary executable that can be called within Matlab. In this document the common term
519   used is `C MEX S-Function", which means Matlab executable written in C that implements a system
520   function.
521
522 \item[MOUT]
523   \textit{(Motor) Power Output.} \newline{}
524   Mnemonic to refer to or something related to the 2A push/pull power output hardware module.
525
526 \item[PWM]
527   \textit{Pulse-width modulation.} \newline{}
528   Technique for getting analog results with digital means. Digital control is used to create a
529   square wave, a signal switched between on and off. This on-off pattern can simulate voltages
530   in between full on and off by changing the portion of the time the signal spends on versus
531   the time that the signal spends off. The duration of ``on time" is called the pulse width or
532   \textit{duty cycle}.
533
534 \item[RPP]
535   \textit{Rapid Prototyping Platform.} \newline{}
536   Name of the automotive hardware board. Also generic term to define something related
537   to the board, like the RPP Library, RPP Layer, RPP API, etc.
538
539 \item[SCI]
540   \textit{Serial Communication Interface.} \newline{}
541   Serial Interface for communication through hardware's UART using communication standard RS-232.
542   In this project it is also used as mnemonic to refer to or something related to the Serial
543   Communication Interface hardware module.
544
545 \item[SDC]
546   \textit{SD-Card.} \newline{}
547   Mnemonic to refer to or something related to the SD-Card hardware module.
548
549 \item[SDR]
550   \textit{SD-RAM.} \newline{}
551   Mnemonic to refer to or something related to the SD-RAM hardware module for logging.
552
553 \item[TLC]
554   \textit{Target Language Compiler.} \newline{}
555   Technology and language used to generate code in Matlab/Simulink.
556
557 \item[UART]
558   \textit{Universal Asynchronous Receiver/Transmitter.} \newline{}
559   Hardware circuitry that translates data between parallel and serial forms.
560 \end{description}
561
562 \newpage
563
564 \hypertarget{work_schedule}{}
565 \section{Work schedule}
566
567 \begin{center}\begin{tabular}{|c|c|l|}
568 \hline \textbf{Date} & \textbf{Deliverable} & \textbf{Priority} \\
569 \hline \multicolumn{1}{|l|}{15.4.2013} & \multicolumn{1}{|l|}{C support library and test suite.} & \multicolumn{1}{|c|}{1} \\
570 \hline \multicolumn{1}{|l|}{01.5.2013} & \multicolumn{1}{|l|}{Simulink Coder target for RPP board.} & \multicolumn{1}{|c|}{2} \\
571 \hline \multicolumn{1}{|l|}{01.6.2013} & \multicolumn{1}{|l|}{Simulink Block library. S-Functions and TLC files.} & \multicolumn{1}{|c|}{3} \\
572 \hline \multicolumn{1}{|l|}{07.6.2013} & \multicolumn{1}{|l|}{Simulink Demo  library.} & \multicolumn{1}{|c|}{4} \\
573 \hline \multicolumn{1}{|l|}{21.6.2013} & \multicolumn{1}{|l|}{Finish documentation of the developed product.} & \multicolumn{1}{|c|}{5} \\
574 \hline \end{tabular}\end{center}
575
576 \end{document}