]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - doc/presentation/presentation.t2t
Final version of the presentation. Forgot to remove media images.
[jenkicar/rpp-simulink.git] / doc / presentation / presentation.t2t
1 Simulink coder target for automotive rapid prototyping platform
2 Carlos Jenkins
3 %%date(%B, %Y)
4
5 %!target: xhtmls
6 %!style(xhtmls): media/themes/Clean Presentation/style.css
7 %!postproc(xhtmls): '->' '→'
8 %!nested(xhtmls): --libs jquery
9 %!nested(tex): --docclass {article}
10
11 %S = Home =[home]
12
13 %xhtmls% ''' <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">
14 Simulink Coder^^(TM)^^ target for automotive rapid prototyping platform
15
16 %xhtmls% ''' </div>
17
18
19 [400-logos.png]
20
21 = Agenda =[agenda]
22
23 - Background.
24
25 - About Simulink.
26
27 - Things developed.
28
29  - C Support Library.
30  - Simulink Coder Target.
31  - Simulink Block Set.
32  - Demos.
33
34 - Questions.
35
36 = Background =[background]
37
38 Back in the beginning of 2012 a leading automotive company (Porsche) requested the Czech Technical 
39 University to develop a Engine Control Unit (ECU) for automotive applications. 
40
41 Real-Time Systems group at the Department of Control Engineering from the Faculty of Electrical 
42 Engineering (a.k.a //next door//) developed a hardware and Software platform to the needs of this 
43 industry (a.k.a //RPP// for Rapid Prototyping Platform).
44
45 The hardware uses Texas Instruments TMS570LS3137 (pretty nifty CPU for automotive applications) and 
46 is built with automotive standards and interfaces in mind. 
47
48 It uses a real-time operating system and is (was) directly programmed in C.
49
50 = Background (cont.) =[background_cont]
51
52 [400-board.png]
53
54 = Background (cont. I) =[background_cont_i]
55
56 Nevertheless, hand written C code is:
57
58 - Hard to produce, sometimes very low-level.
59 - Hard to debug. Yes, 1 bit took us 4 hours.
60 - Requires good knowledge of the underlying hardware.
61 - Most of the time is non-portable or hard to port between platforms.
62 - Hard to audit and certify. 
63
64
65
66 = Background (cont. II) =[background_cont_ii]
67
68 Because of this the company has the policy to implement the Software for their system using 
69 **Model-Based Design**, which is a way to address these problems:
70
71 %xhtmls% ''' <div style=" text-align: center; font-style: italic;margin: 0 10% 0 10%;">
72 "Model-Based Design (MBD) is a mathematical and visual method of addressing problems associated 
73 with designing complex control, signal processing and communication systems. It is used in many 
74 motion control, industrial equipment, aerospace, and automotive applications. Model-based design 
75 is a methodology applied in designing embedded software."
76
77 %xhtmls% ''' </div>
78
79 Or in other words, they use the Software **Simulink** for implementing their systems.
80
81 = About Simulink =[about_simulink]
82
83 %xhtmls% ''' <div style=" text-align: center; font-style: italic;margin: 0 10% 0 10%;">
84 "Simulink, developed by MathWorks, is a data flow graphical programming language tool for modeling,
85 simulating and analyzing multidomain dynamic systems. Simulink is part of Matlab."
86
87 %xhtmls% ''' </div>
88
89 In other words, Simulink is a Software that allows to you create algorithms (systems) by connecting 
90 boxes. Each box is  like a function, with inputs and outputs (with data type and arity).
91
92
93
94 = About Simulink (cont.) =[about_simulink_cont]
95
96 Oversimplifying, it is composed by two things:
97
98 - **Diagramming environment**: Were you draw your algorithm. No more different that UML or 
99   standard diagramming tools.
100
101 - **Block libraries**: a library with lots of blocks that do something: 
102
103  - //Operations//: for example logical operations (OR, NOT, AND, etc), data type conversion, 
104    integration, sum, product (remember arity), etc.
105
106  - //Sources//: generate data for the model, like and pulse generator, signal repeater, wave 
107    generator, etc.
108
109  - //Skins//: blocks that outputs the results of the model. Few examples, like oscilloscope or 
110    XY gratification.
111
112
113
114 = About Simulink (cont. I) =[about_simulink_cont_i]
115
116 [800-simulink_gui.png]
117
118 = About Simulink (cont. II) =[about_simulink_cont_ii]
119
120 The program or system developed with Simulink is referred as a **model**. 
121
122 The models can be "compiled" to C code (code generation) using the //Simulink Coder// product.
123
124 = Things developed =[things_developed]
125
126 - **C Support Library**: @@
127   Define the API to communicate with the board. Include drivers and operating system.
128
129 - **Simulink Coder Target**: @@
130   Allows Simulink model's code generation, compilation and download for the board.
131
132 - **Simulink Block Set**: @@
133   Set of blocks that allows Simulink models to use board IO and communication peripherals.
134
135 - **Demos**: @@
136   Just a bunch of examples of control application in form of Simulink models.
137
138
139 == C Support Library ==[c_support_library]
140
141 Characteristics:
142
143 - Include drivers and operating system (FreeRTOS).
144 - Exposes a high-level user-oriented API for controlling the board.
145 - Static library, as part of the compilation each Simulink model link against this.
146
147
148 === Library - Layers ===[library___layers]
149
150 [500-layers.png]
151
152 === Library - Modules ===[library___modules]
153
154 [500-blocks.png]
155
156 === Library - Modules implemented ===[library___modules_implemented]
157
158 Modules in the scope of this project:
159
160 - **DIN** : Digital Input.
161 - **LOUT**: Digital Output.
162 - **AIN**: Analog Input.
163 - **AOUT**: Analog Output.
164 - **HBR**: H-Bridge.
165 - **MOUT**: Power outputs (2A).
166 - **SCI**: SD-RAM logging.
167 - **SCI**: Serial Communication Interface.
168
169 == Simulink Target ==[simulink_target]
170
171 Allows Simulink model's code generation, compilation and download to the board.
172
173 It is composed by:
174
175 - Installation script.
176 - Target descriptor.
177 - Template to generate a Makefile for source compilation.
178 - Template to generate the C //main// file (entry point).
179 - Script to download the compiled model binary to the board.
180 - Other minor control and support files.
181
182
183 Simulink generates code for almost all the standard blocks. But the model needs a way to output 
184 the results or input data so new blocks for board IO needed to be implemented.
185
186 == Simulink Block Set ==[simulink_block_set]
187
188 [600-block_library.png]
189
190 === Simulink Block Set - Anatomy ===[simulink_block_set___anatomy]
191
192 Each block is composed by:
193
194 - C-MEX S-Function. Fancy way to say:
195  - C : Implemented in C language. Other options are Fortran and Matlab language itself.
196  - MEX: Matlab Executable. Yes, it can be executed in Matlab, that's all. They are compiled by 
197    Matlab GCC wrapper called MEX.
198  - S-Function: System Function, as opposed to standard functions, or user functions.
199
200 - TLC (Target Language Compiler) file for code generation for that block.
201
202
203 === Simulink Block Set - C-MEX S-Function ===[simulink_block_set___c_mex_s_function]
204
205 C file that uses the S-Function API to describe what the block does:
206
207 - Number of inputs and outputs. Just like a function.
208 - Datatype of each input and output. Can be static or dynamic (block context).
209 - Arity of each input and output. Scalar (single value), 1-D (array), 2-D (matrix). @@
210   Matlab supports crazy things as dynamic n-dimensional dynamically typed matrices :O.
211 - Number of parameters (different from inputs), used to configure the block.
212 - Validation of parameters (things like range and datatype).
213
214
215 It can be used also for the block to do something within Simulink. Right now they are just 
216 descriptors.
217
218 === Simulink Block Set - TLC file ===[simulink_block_set___tlc_file]
219
220 File that defines how to generate code for that block (term is //inline//).
221
222 Defines template C code and rules that will be used on code generation for:
223
224 - Initialization of the block (required headers, calls to initialization functions, etc).
225 - The step function, the one that is called at each step to update the model. @@
226   "The function that is called in the main loop".
227 - Model termination. Like free manually allocated memory. Not used in our context.
228
229
230 TLC files can be viewed as wrappers for the C library API.
231
232
233 === Simulink Block Set - Process ===[simulink_block_set___process]
234
235 [tlc_process.png]
236
237 == Demos ==[demos]
238
239 12 demos for things like:
240
241 - Control analog output using analog input. Same for digital.
242 - Control H-Bridge (motor speed and direction) using analog input.
243 - Print a message. Echo all bytes received via SCI.
244 - Software generate a nice sinewave of analog outputs.
245 - Log each second the data read on one analog input.
246 - Others.
247
248 === Demos - H-Bridge Analog Control ===[demos___h_bridge_analog_control]
249
250 [demo_hbridge_analog_control.png]
251
252 = Questions? =[questions]
253
254 %xhtmls% ''' <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">
255 Thank you
256
257 %xhtmls% ''' </div>
258