Screenshot or ert_linux

Linux ERT target for MathWorks' Simulink® Embedded Coder® allows to compile a model of designed control system to the C-code and combine it with target specific support functions. The resulting executable/controller can be run in real-time on the target Linux system. The running dynamic system can be augmented via tunable block parameters in the Simulink model and data can be acquired and visualized with Simulink scopes.

Linux ERT target uses heavily real-time capabilities of real-time variant of the Linux kernel that provides bounded maximal latencies. The resulting control system supports sampling frequencies up to 20 kHz. Matlab/Simulink GUI running on the same GNU/Linux desktop system as the generated real-time application is supported.

More information about initial version developed by Michal Sojka at Department of Control Engineering FEE CTU can be found in Michal Sojka's blog post.

Page Contents

Recent News

  • The real time control of DC and BDLC motors from plain C and Matlab/Simulink with ert_linux target hands-on session is planned at 29th February 2020 at 15:00–16:55 at place of the project origin (DCE labs) in the frame of InstallFest 2020 conference. See details.
  • The a paper Usable Simulink Embedded Coder Target for Linux and RPi motor control has been presented at 16th Real Time Linux Workshop taking place on 12 and 13 October 2014 in Dusseldorf Germany. The Paper and slides are available from our publications archive.
  • The ert_linux project has been presented at Amper exhibition from 18th to 21st March 2014 in Brno, Czech Republic.
  • Linux ERT at Embedded World exhibition – 25 until 27 February 2014 - Visit DCE CTU developers and researchers at the OSADL booth (hall 5 booth 276).

I/O and communication interface support

RT-Capable Platform and Kernel

Standard distribution Linux kernel does not guarantee bounded latencies for many operations. The use of real-time variant of Linux kernel is required to guarantee bounded latencies. This kernel variants minimizes regions where switch to the highest priority (e.g. Linux ERT generated) task is blocked by kernel when servicing system calls for other tasks.

Selection of the right version of the kernel is not enough for non-disruptive operation. Computer system hardware selection is critical as well. The system has to provide enough computational power for compiled in blocks data evaluation evaluation and Linux kernel services processing. Other critical disturbance sources are hardware caused latencies and lags in a program processing by CPU. The source can be bus systems load by other subsystems (i.e. graphic processor memory access, peripheral DMA - SSD, SD-card, Flash controller etc.). The other critical source of latencies in x86 based systems is SMI processing. The SMI enable and processing is under BIOS and motherboard vendor control and this problem cannot be resolved by the operating system. This means that proper hardware selection is critical.

A long period evaluation data of different combinations of Linux kernel version running on many CPU architectures and boards from many vendors is OSADL Quality Assurance Farm. According to these track records carefully selected x86 or embedded GNU/Linux system can run real-time tasks with sampling frequencies up to 20 kHz with no losing sample per months.

Source Code and Download

Project Background

The Linux ERT has been initially developed at DCE of CTU in order to create a dynamic environment model for hardware (airplane) in the loop testing of a fly-by-wire system at AERO Vodochody a.s.. Simulink has been run on Windows host computer initially and code generated for GNU/Linux embedded target system was compiled under MinGW/MSYS environment and then uploaded to PowerPC based BOA5200 computer. The target computer was equipped with two CAN interfaces. CANopen blockset based on CANfestival project was used to control distributed servosystem used to simulate fly-by-wire system load. Simulink CANopen blockset integrates a SocketCAN driver configuration and CAN messages processing support to the generated code and enables the user to develop distributed embedded control applications with CANopen communication.

Original code generation workflow Model including node controlled over CANopen

Lukáš Hamáček, “RTW target for Linux with CANopen support”, Master Thesis, Prague 2009. (Pdf)

Systems Controlled Linux Target for Embedded Coder

Some more information about concrete examples of controlled systems/setups:

Moving Slide parallel kinematic/robot control
The Linux ERT target is used at Adaptive Systems Department (Academy of Sciences of Czech Republic, UTIA institute) to realize control system for parallel kinematics control research projects. See respective page for more information about project.
Raspberry Pi minimal components DC motor servo control
Raspberry Pi is low cost hardware which does not implement any usual motor control peripherals in hardware. Yet fully preemptive variant of Linux kernel latencies are so low that fast signals processing in software allows to implement precise DC motor feedback control for incremental encoder inputs changing up to 15 kHz. See respective page for more information about project.
Permanent magnet synchronous motor control (PMSM) with SPI connected peripherals and power stage
The experiment is primarily focused on school labs. The experiment utilizes two extension boards. One is fully galvanically isolated 3/phases power stage with HAL effect based current sensing and differential IRC signals receiver. The other board provides peripherals (IRC processing and counting, PWM generation, current ADC results collection) required for vector PMSM motor control. This board is connected to Raspberry Pi simple board computer by SPI port. The control algorithm generated by the ERT target runs under fully preemptive Linux kernel at sampling rate 5 kHz. See respective page for more information about project.
The Xilinx Zynq DC motor and PMSM Motor Control
The FPGA based solutions provide flexibility unmatch by other hardware. This set of applications cobines Xilinx Zynq SoCs, Linux RT kernel, custom PMSM driver hardware and ert_linux Matlab/Simulink coder. The linux 4.19 kernel with RT preempt patches and with MathWork's FPGA IP drivers (mwipcore) applied can be found in branch linux-4.19.y-mwcore of the Pavel Pisa'a Linux kernel repository on GitHub. The mwipcore drivers are not required for this ert_linux solution, but RT patch is fundamental. The MZ_APO education kits (use MicroZed SBC) developed at PiKRON company to support teaching of Computer Architectures course at Department of Control Engineering are connected with the PMSM driver power stage developed initially for Altera DE2 kits with option to be SPI connected to Raspberry Pi are used with MZ_APO. The presentation GNU/Linux and FPGA in Real-time Control Applications presents the hardware. The Simulink model zynq_pmsm_motor_control.slx of PMSM controller is included along the Raspberry Pi example in repository https://github.com/ppisa/rpi-rt-control. The FPGA design can be found in branch microzed-mc-1 of the repository https://gitlab.fel.cvut.cz/canbus/zynq/zynq-can-sja1000-top. The MZ_APO education kit mechanical and electronics designs are available from https://gitlab.com/pikron/projects/mz_apo/microzed_apo.
Usable Simulink Embedded Coder Target for Linux
Michal Sojka, Pavel Pisa
16th Real-Time Linux Workshop, Düsseldorf, Germany, October 2014. The paper (PDF) and slides (PDF) are available from our publications archive.

Project Contributors

Michal Sojka
sojkam1@fel.cvut.cz , homepage http://rtime.felk.cvut.cz/~sojka/
teacher, researcher and developer at DCE CTU.
Pavel Píša
pisa@cmp.felk.cvut.cz , homepage http://cmp.felk.cvut.cz/~pisa/
teacher, researcher and developer at DCE CTU.
Rostislav Lisový
lisovros@fel.cvut.cz
former CTU master study programme student, Linux related projects developer at DCE now.
Libor Waszniowski
xwasznio@fel.cvut.cz
former DCE CTU researcher responsible for the project with AERO Vodochody.
Lukáš Hamáček
former CTU master student.

Department of Control EngineeringCzech Technical University in Prague, Faculty of Electrical Engineering

Acknowledgment

This work was supported by Ministry of Industry and Trade of the Czech Republic under Project FT—TA3/044 during period of 2006 to 2009 years.