]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - doc/presentation/publish/xhtmls/presentation.html
Final version of the presentation. Forgot to remove media images.
[jenkicar/rpp-simulink.git] / doc / presentation / publish / xhtmls / presentation.html
1 <?xml version="1.0"
2       encoding="UTF-8"
3 ?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head>
7     <title>Simulink coder target for automotive rapid prototyping platform</title>
8     <meta name="generator" content="http://nestededitor.sourceforge.net/" />
9     <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
10     <link rel="stylesheet" type="text/css" href="media/themes/Clean Presentation/style.css" />
11 <script type="text/javascript" src="media/libraries/jquery/jquery.min.js"></script>
12 <link rel="stylesheet" type="text/css" href="media/themes/Clean Presentation/style.css" />
13 <script type="text/javascript" src="media/themes/Clean Presentation/scripts.js"></script>
14 </head>
15 <body>
16
17 <div class="header" id="header">
18 <h1>Simulink coder target for automotive rapid prototyping platform</h1>
19 <h2>Carlos Jenkins</h2>
20 <h3>June, 2013</h3>
21 </div>
22
23 <div class="body" id="body">
24
25 <div id="section1" class="section">
26 <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">
27 <p>
28 Simulink Coder<sup>(TM)</sup> target for automotive rapid prototyping platform
29 </p>
30 </div>
31 <p>
32 <img style="display: block;margin: 0 auto 0 auto;" width="400" src="media/images/logos.png" alt=""/>
33 </p>
34 </div>
35
36 <div id="section2" class="section">
37
38 <h1 id="agenda">Agenda</h1>
39
40 <ul>
41 <li>Background.
42 <p></p>
43 </li>
44 <li>About Simulink.
45 <p></p>
46 </li>
47 <li>Things developed.
48 <p></p>
49  <ul>
50  <li>C Support Library.
51  </li>
52  <li>Simulink Coder Target.
53  </li>
54  <li>Simulink Block Set.
55  </li>
56  <li>Demos.
57  <p></p>
58  </li>
59  </ul>
60 </li>
61 <li>Questions.
62 </li>
63 </ul>
64
65 </div>
66
67 <div id="section3" class="section">
68
69 <h1 id="background">Background</h1>
70
71 <p>
72 Back in the beginning of 2012 a leading automotive company (Porsche) requested the Czech Technical 
73 University to develop a Engine Control Unit (ECU) for automotive applications. 
74 </p>
75 <p>
76 Real-Time Systems group at the Department of Control Engineering from the Faculty of Electrical 
77 Engineering (a.k.a <em>next door</em>) developed a hardware and Software platform to the needs of this 
78 industry (a.k.a <em>RPP</em> for Rapid Prototyping Platform).
79 </p>
80 <p>
81 The hardware uses Texas Instruments TMS570LS3137 (pretty nifty CPU for automotive applications) and 
82 is built with automotive standards and interfaces in mind. 
83 </p>
84 <p>
85 It uses a real-time operating system and is (was) directly programmed in C.
86 </p>
87 </div>
88
89 <div id="section4" class="section">
90
91 <h1 id="background_cont">Background (cont.)</h1>
92
93 <p>
94 <img style="display: block;margin: 0 auto 0 auto;" width="400" src="media/images/board.png" alt=""/>
95 </p>
96 </div>
97
98 <div id="section5" class="section">
99
100 <h1 id="background_cont_i">Background (cont. I)</h1>
101
102 <p>
103 Nevertheless, hand written C code is:
104 </p>
105
106 <ul>
107 <li>Hard to produce, sometimes very low-level.
108 </li>
109 <li>Hard to debug. Yes, 1 bit took us 4 hours.
110 </li>
111 <li>Requires good knowledge of the underlying hardware.
112 </li>
113 <li>Most of the time is non-portable or hard to port between platforms.
114 </li>
115 <li>Hard to audit and certify. 
116 </li>
117 </ul>
118
119 </div>
120
121 <div id="section6" class="section">
122
123 <h1 id="background_cont_ii">Background (cont. II)</h1>
124
125 <p>
126 Because of this the company has the policy to implement the Software for their system using 
127 <strong>Model-Based Design</strong>, which is a way to address these problems:
128 </p>
129 <div style=" text-align: center; font-style: italic;margin: 0 10% 0 10%;">
130 <p>
131 "Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated 
132 with designing complex control, signal processing and communication systems. It is used in many 
133 motion control, industrial equipment, aerospace, and automotive applications. Model-based design 
134 is a methodology applied in designing embedded software."
135 </p>
136 </div>
137 <p>
138 Or in other words, they use the Software <strong>Simulink</strong> for implementing their systems.
139 </p>
140 </div>
141
142 <div id="section7" class="section">
143
144 <h1 id="about_simulink">About Simulink</h1>
145
146 <div style=" text-align: center; font-style: italic;margin: 0 10% 0 10%;">
147 <p>
148 "Simulink, developed by MathWorks, is a data flow graphical programming language tool for modeling,
149 simulating and analyzing multidomain dynamic systems. Simulink is part of Matlab."
150 </p>
151 </div>
152 <p>
153 In other words, Simulink is a Software that allows to you create algorithms (systems) by connecting 
154 boxes. Each box is  like a function, with inputs and outputs (with data type and arity).
155 </p>
156 </div>
157
158 <div id="section8" class="section">
159
160 <h1 id="about_simulink_cont">About Simulink (cont.)</h1>
161
162 <p>
163 Oversimplifying, it is composed by two things:
164 </p>
165
166 <ul>
167 <li><strong>Diagramming environment</strong>: Were you draw your algorithm. No more different that UML or 
168   standard diagramming tools.
169 <p></p>
170 </li>
171 <li><strong>Block libraries</strong>: a library with lots of blocks that do something: 
172 <p></p>
173  <ul>
174  <li><em>Operations</em>: for example logical operations (OR, NOT, AND, etc), data type conversion, 
175    integration, sum, product (remember arity), etc.
176  <p></p>
177  </li>
178  <li><em>Sources</em>: generate data for the model, like and pulse generator, signal repeater, wave 
179    generator, etc.
180  <p></p>
181  </li>
182  <li><em>Skins</em>: blocks that outputs the results of the model. Few examples, like oscilloscope or 
183    XY gratification.
184  </li>
185  </ul>
186 </li>
187 </ul>
188
189 </div>
190
191 <div id="section9" class="section">
192
193 <h1 id="about_simulink_cont_i">About Simulink (cont. I)</h1>
194
195 <p>
196 <img style="display: block;margin: 0 auto 0 auto;" width="800" src="media/images/simulink_gui.png" alt=""/>
197 </p>
198 </div>
199
200 <div id="section10" class="section">
201
202 <h1 id="about_simulink_cont_ii">About Simulink (cont. II)</h1>
203
204 <p>
205 The program or system developed with Simulink is referred as a <strong>model</strong>. 
206 </p>
207 <p>
208 The models can be "compiled" to C code (code generation) using the <em>Simulink Coder</em> product.
209 </p>
210 </div>
211
212 <div id="section11" class="section">
213
214 <h1 id="things_developed">Things developed</h1>
215
216 <ul>
217 <li><strong>C Support Library</strong>: <br />
218   Define the API to communicate with the board. Include drivers and operating system.
219 <p></p>
220 </li>
221 <li><strong>Simulink Coder Target</strong>: <br />
222   Allows Simulink model's code generation, compilation and download for the board.
223 <p></p>
224 </li>
225 <li><strong>Simulink Block Set</strong>: <br />
226   Set of blocks that allows Simulink models to use board IO and communication peripherals.
227 <p></p>
228 </li>
229 <li><strong>Demos</strong>: <br />
230   Just a bunch of examples of control application in form of Simulink models.
231 </li>
232 </ul>
233
234 </div>
235
236 <div id="section12" class="section">
237
238 <h2 id="c_support_library">C Support Library</h2>
239
240 <p>
241 Characteristics:
242 </p>
243
244 <ul>
245 <li>Include drivers and operating system (FreeRTOS).
246 </li>
247 <li>Exposes a high-level user-oriented API for controlling the board.
248 </li>
249 <li>Static library, as part of the compilation each Simulink model link against this.
250 </li>
251 </ul>
252
253 </div>
254
255 <div id="section13" class="section">
256
257 <h3 id="library___layers">Library - Layers</h3>
258
259 <p>
260 <img style="display: block;margin: 0 auto 0 auto;" width="500" src="media/images/layers.png" alt=""/>
261 </p>
262 </div>
263
264 <div id="section14" class="section">
265
266 <h3 id="library___modules">Library - Modules</h3>
267
268 <p>
269 <img style="display: block;margin: 0 auto 0 auto;" width="500" src="media/images/blocks.png" alt=""/>
270 </p>
271 </div>
272
273 <div id="section15" class="section">
274
275 <h3 id="library___modules_implemented">Library - Modules implemented</h3>
276
277 <p>
278 Modules in the scope of this project:
279 </p>
280
281 <ul>
282 <li><strong>DIN</strong> : Digital Input.
283 </li>
284 <li><strong>LOUT</strong>: Digital Output.
285 </li>
286 <li><strong>AIN</strong>: Analog Input.
287 </li>
288 <li><strong>AOUT</strong>: Analog Output.
289 </li>
290 <li><strong>HBR</strong>: H-Bridge.
291 </li>
292 <li><strong>MOUT</strong>: Power outputs (2A).
293 </li>
294 <li><strong>SCI</strong>: SD-RAM logging.
295 </li>
296 <li><strong>SCI</strong>: Serial Communication Interface.
297 </li>
298 </ul>
299
300 </div>
301
302 <div id="section16" class="section">
303
304 <h2 id="simulink_target">Simulink Target</h2>
305
306 <p>
307 Allows Simulink model's code generation, compilation and download to the board.
308 </p>
309 <p>
310 It is composed by:
311 </p>
312
313 <ul>
314 <li>Installation script.
315 </li>
316 <li>Target descriptor.
317 </li>
318 <li>Template to generate a Makefile for source compilation.
319 </li>
320 <li>Template to generate the C <em>main</em> file (entry point).
321 </li>
322 <li>Script to download the compiled model binary to the board.
323 </li>
324 <li>Other minor control and support files.
325 </li>
326 </ul>
327
328 <p>
329 Simulink generates code for almost all the standard blocks. But the model needs a way to output 
330 the results or input data so new blocks for board IO needed to be implemented.
331 </p>
332 </div>
333
334 <div id="section17" class="section">
335
336 <h2 id="simulink_block_set">Simulink Block Set</h2>
337
338 <p>
339 <img style="display: block;margin: 0 auto 0 auto;" width="600" src="media/images/block_library.png" alt=""/>
340 </p>
341 </div>
342
343 <div id="section18" class="section">
344
345 <h3 id="simulink_block_set___anatomy">Simulink Block Set - Anatomy</h3>
346
347 <p>
348 Each block is composed by:
349 </p>
350
351 <ul>
352 <li>C-MEX S-Function. Fancy way to say:
353  <ul>
354  <li>C : Implemented in C language. Other options are Fortran and Matlab language itself.
355  </li>
356  <li>MEX: Matlab Executable. Yes, it can be executed in Matlab, that's all. They are compiled by 
357    Matlab GCC wrapper called MEX.
358  </li>
359  <li>S-Function: System Function, as opposed to standard functions, or user functions.
360  <p></p>
361  </li>
362  </ul>
363 </li>
364 <li>TLC (Target Language Compiler) file for code generation for that block.
365 </li>
366 </ul>
367
368 </div>
369
370 <div id="section19" class="section">
371
372 <h3 id="simulink_block_set___c_mex_s_function">Simulink Block Set - C-MEX S-Function</h3>
373
374 <p>
375 C file that uses the S-Function API to describe what the block does:
376 </p>
377
378 <ul>
379 <li>Number of inputs and outputs. Just like a function.
380 </li>
381 <li>Datatype of each input and output. Can be static or dynamic (block context).
382 </li>
383 <li>Arity of each input and output. Scalar (single value), 1-D (array), 2-D (matrix). <br />
384   Matlab supports crazy things as dynamic n-dimensional dynamically typed matrices :O.
385 </li>
386 <li>Number of parameters (different from inputs), used to configure the block.
387 </li>
388 <li>Validation of parameters (things like range and datatype).
389 </li>
390 </ul>
391
392 <p>
393 It can be used also for the block to do something within Simulink. Right now they are just 
394 descriptors.
395 </p>
396 </div>
397
398 <div id="section20" class="section">
399
400 <h3 id="simulink_block_set___tlc_file">Simulink Block Set - TLC file</h3>
401
402 <p>
403 File that defines how to generate code for that block (term is <em>inline</em>).
404 </p>
405 <p>
406 Defines template C code and rules that will be used on code generation for:
407 </p>
408
409 <ul>
410 <li>Initialization of the block (required headers, calls to initialization functions, etc).
411 </li>
412 <li>The step function, the one that is called at each step to update the model. <br />
413   "The function that is called in the main loop".
414 </li>
415 <li>Model termination. Like free manually allocated memory. Not used in our context.
416 </li>
417 </ul>
418
419 <p>
420 TLC files can be viewed as wrappers for the C library API.
421 </p>
422 </div>
423
424 <div id="section21" class="section">
425
426 <h3 id="simulink_block_set___process">Simulink Block Set - Process</h3>
427
428 <p>
429 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/tlc_process.png" alt=""/>
430 </p>
431 </div>
432
433 <div id="section22" class="section">
434
435 <h2 id="demos">Demos</h2>
436
437 <p>
438 12 demos for things like:
439 </p>
440
441 <ul>
442 <li>Control analog output using analog input. Same for digital.
443 </li>
444 <li>Control H-Bridge (motor speed and direction) using analog input.
445 </li>
446 <li>Print a message. Echo all bytes received via SCI.
447 </li>
448 <li>Software generate a nice sinewave of analog outputs.
449 </li>
450 <li>Log each second the data read on one analog input.
451 </li>
452 <li>Others.
453 </li>
454 </ul>
455
456 </div>
457
458 <div id="section23" class="section">
459
460 <h3 id="demos___h_bridge_analog_control">Demos - H-Bridge Analog Control</h3>
461
462 <p>
463 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/demo_hbridge_analog_control.png" alt=""/>
464 </p>
465 </div>
466
467 <div id="section24" class="section">
468
469 <h1 id="questions">Questions?</h1>
470
471 <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">
472 <p>
473 Thank you
474 </p>
475 </div>
476 </div>
477 </div>
478 </body></html>