1 [[!meta title="Linux Target for Simulink® Embedded Coder®"]]
3 [[!img ert_linux_snapshot1.png size="300x" align=right alt="Screenshot or ert_linux"]]
5 Linux ERT target for [MathWorks]' [Simulink]® Embedded Coder® allows
6 to compile a model of designed control system to the C-code and
7 combine it with target specific support functions. The resulting
8 executable/controller can be run in real-time on the target Linux
9 system. The running dynamic system can be augmented via tunable block
10 parameters in the Simulink model and data can be acquired and
11 visualized with Simulink scopes.
13 Linux ERT target uses heavily real-time capabilities of
14 [real-time variant of the Linux kernel](https://rt.wiki.kernel.org/index.php/CONFIG_PREEMPT_RT_Patch)
15 that provides bounded maximal latencies. The resulting control system
16 supports sampling frequencies **up to 20 kHz**. Matlab/Simulink GUI
17 running on the same GNU/Linux desktop system as the generated
18 real-time application is supported.
20 More information about current version can be found in
21 [Michal Sojka's blog post](http://rtime.felk.cvut.cz/~sojka/blog/on-generating-linux-applications-from-simulink/).
25 [MathWorks]: http://www.mathworks.com/
26 [Simulink]: http://en.wikipedia.org/wiki/Simulink
34 - We will present the a paper
35 [Usable Simulink Embedded Coder Target for Linux](https://www.osadl.org/?id=2018)
36 and RPi motor control demonstration at
37 [16th Real Time Linux Workshop](https://www.osadl.org/RTLWS-2014.rtlws-2014.0.html)
38 taking place on 12 and 13 October 2014 in Dusseldorf Germany. The
39 [Paper](http://rtime.felk.cvut.cz/publications/public/ert_linux.pdf)
41 [slides](http://rtime.felk.cvut.cz/publications/public/ert_linux-rtlws2014.pdf)
42 are available from our
43 [publications archive](http://rtime.felk.cvut.cz/publications/).
44 - We will present the ert_linux project at
45 [Amper exhibition](http://www.amper.cz/en/online-catalog/list-of-exhibitors.html/e9595_0-fakulta-elektrotechnicka-cvut-v-praze)
46 from 18th to 21st March 2014 in Brno, Czech Republic.
47 - Linux ERT at Embedded World exhibition – 25 until 27 February 2014 - Visit
48 [DCE CTU](http://www.ask-embedded-world.de/index.php5?id=342793&Action=showCompany)
49 developers and researchers at the OSADL booth (hall 5 booth 276).
51 I/O and communication interface support
54 - [Humusoft MF624 data acquisition card](http://www.humusoft.com/data/session.php?redirect=/produkty/datacq/mf624/&lang=en).
56 <abbr title="User Space I/O">UIO</abbr> driver and Simulink blockset
57 has been developed. The UIO driver is already
58 [included in the mainline Linux kernel](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=06849faab58fc7ff9f4eae2532380c2a746a6f47).
59 Simulink blockset is available from a
60 [separate repository](https://rtime.felk.cvut.cz/gitweb/mf624-simulink.git).
61 More documentation about the UIO driver can be found on
62 [DCE HW Wiki page](http://rtime.felk.cvut.cz/hw/index.php/Humusoft_MF6xx).
64 - The Bhanderi's [ComediToolbox](http://www.mathworks.com/matlabcentral/fileexchange/15792-comedi-toolbox-v1-0-for-linux-based-rtw-targets) suitable for most Linux [Comedi](http://www.comedi.org/)
65 driver supported analog and digital inputs/output cards has been
66 successfuly tested with <b>ert_linux target</b>. The little updated
67 version with target configuration example is available in
69 [download area](https://sourceforge.net/projects/lintarget/files/).
71 - The basic blocks for [CAN bus communication](can_bus/index.html)
72 under Linux are implemented.
74 RT-Capable Platform and Kernel
77 Standard distribution Linux kernel does not guarantee bounded
78 latencies for many operations. The use of
79 [real-time variant](http://rt.wiki.kernel.org/) of
80 [Linux](http://en.wikipedia.org/wiki/Linux) kernel is required to
81 guarantee bounded latencies. This kernel variants minimizes regions
82 where switch to the highest priority (e.g. Linux ERT generated) task
83 is blocked by kernel when servicing system calls for other tasks.
85 Selection of the right version of the kernel is not enough for
86 non-disruptive operation. Computer system hardware selection is
87 critical as well. The system has to provide enough computational power
88 for compiled in blocks data evaluation evaluation and Linux kernel
89 services processing. Other critical disturbance sources are hardware
90 caused latencies and lags in a program processing by CPU. The source
91 can be bus systems load by other subsystems (i.e. graphic processor
92 memory access, peripheral DMA - SSD, SD-card, Flash controller etc.).
93 The other critical source of latencies in x86 based systems is
94 [SMI](http://en.wikipedia.org/wiki/System_Management_Mode) processing.
95 The SMI enable and processing is under BIOS and motherboard vendor
96 control and this problem cannot be resolved by the operating system.
97 This means that proper hardware selection is critical.
99 A long period evaluation data of different combinations of Linux
100 kernel version running on many CPU architectures and boards from many
101 vendors is [OSADL](http://www.osadl.org/)
102 [Quality Assurance Farm](http://www.osadl.org/Quality-assurance-at-the-OSADL-QA-Farm.osadl-services-qa.0.html).
103 According to these track records carefully selected x86 or embedded
104 GNU/Linux system can run real-time tasks with sampling frequencies up
105 to 20 kHz with no losing sample per months.
107 Source Code and Download
110 - [Download area at Sourceforge](https://sourceforge.net/projects/lintarget/files/)
111 contains released versions of the Linux target and CANopen based
113 - [Linux ERT source code repository](http://rtime.felk.cvut.cz/gitweb/ert_linux.git)
114 (development version).
115 - [Humusoft MF624 card support blockset](http://rtime.felk.cvut.cz/gitweb/mf624-simulink.git)
116 <br>Initial version of blockset supporting analog and digital
117 input/output, IRC, PWM and PWM measurement for MF624 cards.
123 The Linux ERT has been initially developed at
124 [DCE of CTU](https://dce.fel.cvut.cz/en) in order to create a dynamic
125 environment model for hardware (airplane) in the loop testing of a
126 fly-by-wire system at [AERO Vodochody a.s.](http://www.aero.cz/en).
127 Simulink has been run on Windows host computer initially and code
128 generated for GNU/Linux embedded target system was compiled under
129 [MinGW/MSYS](http://en.wikipedia.org/wiki/Mingw) environment and then
130 uploaded to PowerPC based
131 [BOA5200](http://rtime.felk.cvut.cz/hw/index.php/Boa5200) computer.
132 The target computer was equipped with two CAN interfaces.
133 [CANopen](http://en.wikipedia.org/wiki/Canopen) blockset based on
134 [CANfestival](http://canfestival.org/) project was used to control
135 distributed servosystem used to simulate fly-by-wire system load.
136 Simulink CANopen blockset integrates a
137 [SocketCAN](http://en.wikipedia.org/wiki/Socketcan) driver
138 configuration and CAN messages processing support to the generated
139 code and enables the user to develop distributed embedded control
140 applications with CANopen communication.</p>
142 [[!img LinTarget.JPG size=300x alt="Original code generation workflow"]]
143 [[!img CANopenExample.JPG size=300x alt="Model including node controlled over CANopen"]]
145 Lukáš Hamáček, “*RTW target for Linux with CANopen support*”, Master Thesis, Prague 2009. ([Pdf](dp_2009_hamacek_lukas.pdf))
147 Systems Controlled Linux Target for Embedded Coder
150 Some more information about concrete examples of controlled systems/setups:
153 <dt><b>Moving Slide</b> parallel kinematic/robot control</dt>
154 <dd>The Linux ERT target is used at Adaptive Systems Department (Academy of Sciences
155 of Czech Republic, UTIA institute) to realize control system for parallel kinematics
156 control research projects. See <a href="moving-slide/index.html">respective page for more
157 information about project</a>.
159 <dt><b>Raspberry Pi</b> minimal components DC motor servo control</dt>
160 <dd><a href="http://en.wikipedia.org/wiki/Raspberry_Pi">Raspberry Pi</a> is low cost
161 hardware which does not implement any usual motor control peripherals in hardware.
162 Yet fully preemptive variant of Linux kernel latencies are so low that fast signals
163 processing in software allows to implement precise DC motor feedback control
164 for incremental encoder inputs changing up to 15 kHz.
165 See <a href="rpi-motor-control/index.html"> respective page for more information
168 <dt><b>Permanent magnet synchronous motor control (PMSM) with SPI connected peripherals and power stage</dt>
169 <dd>The experiment is primarily focussed on school labs. The experiment utilizes
170 two extension boards. One is fully galvanically isolated 3/phases power stage
171 with HAL effect based current sensing and differential IRC signals receiver.
172 The other board provides peripherals (IRC processing and counting,
173 PWM generation, current ADC results collection) required
174 for vector PMSM motor control. This board is connected to
175 <a href="http://en.wikipedia.org/wiki/Raspberry_Pi">Raspberry Pi</a> simple board
176 computer by SPI port. The control algorithm generated by the ERT target
177 runs under fully preemptive Linux kernel at sampling rate 5 kHz.
178 See <a href="rpi-pmsm-control/index.html"> respective page for more
179 information about project</a>.
181 <dt>Usable Simulink Embedded Coder Target for Linux</dt>
182 <dd>Michal Sojka, Pavel Pisa<br>
183 <a href="https://www.osadl.org/RTLWS-2014.rtlws-2014.0.html">16th Real-Time Linux Workshop</a>,
184 Düsseldorf, Germany, October 2014.
185 The <a href="http://rtime.felk.cvut.cz/publications/public/ert_linux.pdf">paper (PDF)</a>
186 and <a href="http://rtime.felk.cvut.cz/publications/public/ert_linux-rtlws2014.pdf">slides (PDF)</a>
187 are available from our
188 <a href="http://rtime.felk.cvut.cz/publications/">publications archive</a>.
196 <dt>Michal Sojka</dt>
197 <dd><a href="mailto:sojkam1@fel.cvut.cz">sojkam1@fel.cvut.cz</a> ,
198 homepage <a href="http://rtime.felk.cvut.cz/~sojka/">http://rtime.felk.cvut.cz/~sojka/</a>
199 <br>teacher, researcher and developer at DCE CTU.
202 <dd><a href="mailto:pisa@cmp.felk.cvut.cz">pisa@cmp.felk.cvut.cz</a> ,
203 homepage <a href="http://cmp.felk.cvut.cz/~pisa/">http://cmp.felk.cvut.cz/~pisa/</a>
204 <br>teacher, researcher and developer at DCE CTU.
206 <dt>Rostislav Lisový</dt>
207 <dd><a href="mailto:lisovros@fel.cvut.cz">lisovros@fel.cvut.cz</a>
208 <br>former CTU master study programme student, Linux related projects developer at DCE now.
210 <dt>Libor Waszniowski</dt>
211 <dd><a href="mailto:xwasznio@fel.cvut.cz">xwasznio@fel.cvut.cz</a>
212 <br>former DCE CTU researcher responsible for the project with AERO Vodochody.
214 <dt>Lukáš Hamáček</dt>
216 former CTU master student.
221 [Department of Control Engineering](http://dce.fel.cvut.cz/) –
222 [Czech Technical University in Prague](http://www.cvut.cz/en),
223 [Faculty of Electrical Engineering](http://www.fel.cvut.cz/en)
228 This work was supported by Ministry of Industry and Trade of the Czech Republic under Project
229 FT—TA3/044 during period of 2006 to 2009 years.