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 demonstartion 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
72 [CAN messages sending and receiption](can_bus/index.html) under
73 Linux are implemented.
75 RT-Capable Platform and Kernel
78 Standard distribution Linux kernel does not guarantee bounded
79 latencies for many operations. The use of
80 [real-time variant](http://rt.wiki.kernel.org/) of
81 [Linux](http://en.wikipedia.org/wiki/Linux) kernel is required to
82 guarantee bounded latencies. This kernel variants minimizes regions
83 where switch to the highest priority (e.g. Linux ERT generated) task
84 is blocked by kernel when servicing system calls for other tasks.
86 Selection of the right version of the kernel is not enough for
87 non-disruptive operation. Computer system hardware selection is
88 critical as well. The system has to provide enough computational power
89 for compiled in blocks data evaluation evaluation and Linux kernel
90 services processing. Other critical disturbance sources are hardware
91 caused latencies and lags in a program processing by CPU. The source
92 can be bus systems load by other subsystems (i.e. graphic processor
93 memory access, peripheral DMA - SSD, SD-card, Flash controller etc.).
94 The other critical source of latencies in x86 based systems is
95 [SMI](http://en.wikipedia.org/wiki/System_Management_Mode) processing.
96 The SMI enable and processing is under BIOS and motherboard vendor
97 control and this problem cannot be resolved by the operating system.
98 This means that proper hardware selection is critical.
100 A long period evaluation data of different combinations of Linux
101 kernel version runing on many CPU architectures and boards from many
102 vendors is [OSADL](http://www.osadl.org/)
103 [Quality Assurance Farm](http://www.osadl.org/Quality-assurance-at-the-OSADL-QA-Farm.osadl-services-qa.0.html).
104 According to these track records carefully selected x86 or embedded
105 GNU/Linux system can run real-time tasks with sampling frequencies up
106 to 20 kHz with no losing sample per months.
108 Source Code and Download
111 - [Download area at Sourceforge](https://sourceforge.net/projects/lintarget/files/)
112 contains released versions of the Linux target and CANopen based
114 - [Linux ERT source code repository](http://rtime.felk.cvut.cz/gitweb/ert_linux.git)
115 (development version).
116 - [Humusoft MF624 card support blockset](http://rtime.felk.cvut.cz/gitweb/mf624-simulink.git)
117 <br>Initial version of blockset supporting analog and digital
118 input/output, IRC, PWM and PWM measurement for MF624 cards.
124 The Linux ERT has been initially developed at
125 [DCE of CTU](https://dce.fel.cvut.cz/en) in order to create a dynamic
126 environment model for hardware (airplane) in the loop testing of a
127 fly-by-wire system at [AERO Vodochody a.s.](http://www.aero.cz/en).
128 Simulink has been run on Windows host computer initially and code
129 generated for GNU/Linux embedded target system was compiled under
130 [MinGW/MSYS](http://en.wikipedia.org/wiki/Mingw) environment and then
131 uploaded to PowerPC based
132 [BOA5200](http://rtime.felk.cvut.cz/hw/index.php/Boa5200) computer.
133 The target computer was equipped with two CAN interfaces.
134 [CANopen](http://en.wikipedia.org/wiki/Canopen) blockset based on
135 [CANfestival](http://canfestival.org/) project was used to control
136 distributed servosystem used to simulate fly-by-wire system load.
137 Simulink CANopen blockset integrates a
138 [SocketCAN](http://en.wikipedia.org/wiki/Socketcan) driver
139 configuration and CAN messages processing support to the generated
140 code and enables the user to develop distributed embedded control
141 applications with CANopen communication.</p>
143 [[!img LinTarget.JPG size=300x alt="Original code generation workflow"]]
144 [[!img CANopenExample.JPG size=300x alt="Model including node controlled over CANopen"]]
146 Lukáš Hamáček, “*RTW target for Linux with CANopen support*”, Master Thesis, Prague 2009. ([Pdf](dp_2009_hamacek_lukas.pdf))
148 Systems Controlled Linux Target for Embedded Coder
151 Some more information about concrete examples of controlled systems/setups:
154 <dt><b>Moving Slide</b> parallel kinematic/robot control</dt>
155 <dd>The Linux ERT target is used at Adaptive Systems Department (Academy of Sciences
156 of Czech Republic, UTIA institute) to realize control system for parallel kinematics
157 control research projects. See <a href="moving-slide/index.html">respective page for more
158 information about project</a>.
160 <dt><b>Raspberry Pi</b> minimal components DC motor servo control</dt>
161 <dd><a href="http://en.wikipedia.org/wiki/Raspberry_Pi">Raspberry Pi</a> is low cost
162 hardware which does not implement any usual motor control peripherals in hardware.
163 Yet fully preemptive variant of Linux kernel latencies are so low that fast signals
164 processing in software allows to implement precise DC motor feedback control
165 for incremental encoder inputs changing up to 15 kHz.
166 See <a href="rpi-motor-control/index.html"> respective page for more information
169 <dt>Usable Simulink Embedded Coder Target for Linux</dt>
170 <dd>Michal Sojka, Pavel Pisa<br>
171 <a href="https://www.osadl.org/RTLWS-2014.rtlws-2014.0.html">16th Real-Time Linux Workshop</a>,
172 Düsseldorf, Germany, October 2014.
173 The <a href="http://rtime.felk.cvut.cz/publications/public/ert_linux.pdf">paper (PDF)</a>
174 and <a href="http://rtime.felk.cvut.cz/publications/public/ert_linux-rtlws2014.pdf">slides (PDF)</a>
175 are available from our
176 <a href="http://rtime.felk.cvut.cz/publications/">publications archive</a>.
184 <dt>Michal Sojka</dt>
185 <dd><a href="mailto:sojkam1@fel.cvut.cz">sojkam1@fel.cvut.cz</a> ,
186 homepage <a href="http://rtime.felk.cvut.cz/~sojka/">http://rtime.felk.cvut.cz/~sojka/</a>
187 <br>teacher, researcher and developer at DCE CTU.
190 <dd><a href="mailto:pisa@cmp.felk.cvut.cz">pisa@cmp.felk.cvut.cz</a> ,
191 homepage <a href="http://cmp.felk.cvut.cz/~pisa/">http://cmp.felk.cvut.cz/~pisa/</a>
192 <br>teacher, researcher and developer at DCE CTU.
194 <dt>Rostislav Lisový</dt>
195 <dd><a href="mailto:lisovros@fel.cvut.cz">lisovros@fel.cvut.cz</a>
196 <br>former CTU master study programe student, Linux related projects developer at DCE now.
198 <dt>Libor Waszniowski</dt>
199 <dd><a href="mailto:xwasznio@fel.cvut.cz">xwasznio@fel.cvut.cz</a>
200 <br>former DCE CTU researcher responsible for the project with AERO Vodochody.
202 <dt>Lukáš Hamáček</dt>
204 former CTU master student.
209 [Department of Control Engineering](http://dce.fel.cvut.cz/) –
210 [Czech Technical University in Prague](http://www.cvut.cz/en),
211 [Faculty of Electrical Engineering](http://www.fel.cvut.cz/en)
216 This work was supported by Ministry of Industry and Trade of the Czech Republic under Project
217 FT—TA3/044 during period of 2006 to 2009 years.