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">
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>
17 <div class="header" id="header">
18 <h1>Simulink coder target for automotive rapid prototyping platform</h1>
19 <h2>Carlos Jenkins</h2>
23 <div class="body" id="body">
25 <div id="section1" class="section">
26 <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">
28 Simulink coder target for automotive rapid prototyping platform
32 <img style="display: block;margin: 0 auto 0 auto;" width="300" src="media/images/logos.png" alt=""/>
36 <div id="section2" class="section">
38 <h1 id="agenda">Agenda</h1>
51 <li>Simulink Block Set.
63 <div id="section3" class="section">
65 <h1 id="background">Background</h1>
69 <div id="section4" class="section">
71 <h1 id="about_simulink">About Simulink</h1>
75 <div id="section5" class="section">
77 <h1 id="things_developed">Things developed</h1>
80 <li><strong>C Library</strong>: <br />
81 Define the API to communicate with the board. Include drivers and operating system.
84 <li><strong>Simulink Target</strong>: <br />
85 Allows Simulink model's code generation, compilation and download to the board.
88 <li><strong>Simulink Block Set</strong>: <br />
89 Set of blocks that allows Simulink models to use board IO and communication peripherals.
92 <li><strong>Demos</strong>: <br />
93 Just a bunch of examples of control application in form of Simulink models.
99 <div id="section6" class="section">
101 <h2 id="c_library">C Library</h2>
108 <li>Include drivers and operating system (FreeRTOS).
110 <li>Exposes a high-level user-oriented API for controlling the board.
112 <li>Static library, as part of the compilation each Simulink model link against this.
118 <div id="section7" class="section">
120 <h3 id="library___layers">Library - Layers</h3>
123 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/layers.png" alt=""/>
127 <div id="section8" class="section">
129 <h3 id="library___modules">Library - Modules</h3>
132 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/blocks.png" alt=""/>
136 <div id="section9" class="section">
138 <h3 id="library___modules_implemented">Library - Modules implemented</h3>
141 Modules in the scope of this project:
145 <li><strong>DIN</strong> : Digital Input.
147 <li><strong>LOUT</strong>: Digital Output.
149 <li><strong>AIN</strong>: Analog Input.
151 <li><strong>AOUT</strong>: Analog Output.
153 <li><strong>HBR</strong>: H-Bridge.
155 <li><strong>MOUT</strong>: Power outputs (2A).
157 <li><strong>SCI</strong>: SD-RAM logging.
159 <li><strong>SCI</strong>: Serial Communication Interface.
165 <div id="section10" class="section">
167 <h2 id="simulink_target">Simulink Target</h2>
170 Allows Simulink model's code generation, compilation and download to the board.
177 <li>Installation script.
179 <li>Target descriptor.
181 <li>Template to generate a Makefile for source compilation.
183 <li>Template to generate the C <em>main</em> file (entry point).
185 <li>Script to download the compiled model binary to the board.
187 <li>Other minor control and support files.
192 Simulink generates code for almost all the standard blocks. But the model needs a way
193 to output the results or input data so new blocks for board IO needed to be implemented.
197 <div id="section11" class="section">
199 <h2 id="simulink_block_set">Simulink Block Set</h2>
202 <img style="display: block;margin: 0 auto 0 auto;" width="600" src="media/images/block_library.png" alt=""/>
206 <div id="section12" class="section">
208 <h3 id="simulink_block_set___anatomy">Simulink Block Set - Anatomy</h3>
211 Each block is composed by:
215 <li>C-MEX S-Function. Fancy way to say:
217 <li>C : Implemented in C language. Other options are Fortran and Matlab language itself.
219 <li>MEX: Matlab Executable. Yes, it can be executed in Matlab, that's all. They are compiled by
220 Matlab GCC wrapper called MEX.
222 <li>S-Function: System Function, as opposed to standard functions, or user functions.
227 <li>TLC (Target Language Compiler) file for code generation for that block.
233 <div id="section13" class="section">
235 <h3 id="simulink_block_set___c_mex_s_function">Simulink Block Set - C-MEX S-Function</h3>
238 C file that uses the S-Function API to describe what the block does:
242 <li>Number of inputs and outputs. Just like a function.
244 <li>Datatype of each input and output. Can be static or dynamic (block context).
246 <li>Arity of each input and output. Scalar (single value), 1-D (array), 2-D (matrix). <br />
247 Matlab supports crazy things as dynamic n-dimensional dynamically typed matrices :O.
249 <li>Number of parameters (different from inputs), used to configure the block.
251 <li>Validation of parameters (things like range and datatype).
256 It can be used also for the block to do something within Simulink. Right now they are just descriptors.
260 <div id="section14" class="section">
262 <h3 id="simulink_block_set___tlc_file">Simulink Block Set - TLC file</h3>
265 File that defines how to generate code for that block (term is <em>inline</em>).
268 Defines template C code and rules that will be used on code generation for:
272 <li>Initialization of the block (required headers, calls to initialization functions, etc).
274 <li>The step function, the one that is called at each step to update the model. <br />
275 "The function that is called in the main loop".
277 <li>Model termination. Like free manually allocated memory. Not used in our context.
282 TLC files can be viewed as wrappers for the C library API.
286 <div id="section15" class="section">
288 <h3 id="simulink_block_set___process">Simulink Block Set - Process</h3>
291 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/tlc_process.png" alt=""/>
295 <div id="section16" class="section">
297 <h2 id="demos">Demos</h2>
300 12 demos for things like:
304 <li>Control analog output using analog input. Same for digital.
306 <li>Control H-Bridge (motor speed and direction) using analog input.
308 <li>Print a message. Echo all bytes received via SCI.
310 <li>Software generate a nice sinewave of analog outputs.
312 <li>Log each second the data read on one analog input.
320 <div id="section17" class="section">
322 <h2 id="demos___h_bridge_analog_control">Demos - H-Bridge Analog Control</h2>
325 <img style="display: block;margin: 0 auto 0 auto;" src="media/images/demo_hbridge_analog_control.png" alt=""/>
329 <div id="section18" class="section">
331 <h1 id="questions">Questions?</h1>
333 <div style="margin-top: 10%; text-align: center; font-size: 1.3em;">