Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0...
Transcript of Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0...
![Page 1: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/1.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Targeting the Scicos Codegenerator forembedded applications
Ing. Roberto Bucher
Scuola Universitaria Professionale della Svizzera Italiana (SUPSI)
Paris - 1.7.2009
![Page 2: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/2.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Objectives
(Prices in Euro) Commercial ProposedControl design environment solution
Core SW 1950.- 0.-
Control SW 1000.- 0.-
Graphical GUI 3000.- 0.-
Code generator 7500.- 0.-
RT target 3000.- 0.-
![Page 3: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/3.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Objectives
![Page 4: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/4.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Outline
1 Rapid Controller Prototyping
2 Linux RTAI
3 Scilab/Scicos and Linux RTAI
4 Implementation
5 Examples
6 Conclusions
![Page 5: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/5.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Introduction
Control Design Loop
specification
modellingidentification
controldesign
simulation
implementation
verification
![Page 6: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/6.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Introduction
Rapid Controller Prototyping - Requirements
2 main components1 An OS with hard real-time features2 A Computer Aided Control System Design environment
including a code generator
→ Linux RTAI + RTAI-Lab + Scilab/Scicos
![Page 7: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/7.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Basics
The Linux RTAI project
Hard real-time extension to the Linux OS
Based on the ADEOS pipeline (with some improvements!)
Free Open Source Software (FOSS)
Implementation of hard real-time controllers using generalpurpose hardware
Same PC for the controller design, the hard real-timecontroller task and the soft real-time monitor task
Hard real-time in kernel and user space
Distributed control through the net rpc module
![Page 8: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/8.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Basics
Linux RTAI - Features
Latency: < 10µs depending on the HW
Typical sampling frequencies: 1 . . . 10kHz
![Page 9: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/9.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
RTAI-Lab
The GUI application - xrtailab
![Page 10: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/10.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
RTAI-Lab
The GUI application - xrtailab
PC with HRT task and xrtailab
PC with HRT task PC with xrtailab
Network
UDP/IP
![Page 11: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/11.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
RTAI-Lab
The GUI application - xrtailab
PC with HRT task and xrtailab
PC with HRT task PC with xrtailab
Network
UDP/IP
![Page 12: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/12.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
RTAI example 1
Systems controlled with Linux RTAI
http://www.inrialpes.fr/sed
Cycab (INRIA)
Biped Robot (INRIA)
![Page 13: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/13.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
RTAI example 2
National Radio Astronomy Observatory controlled withLinux RTAI - West Virginia
http://www.gb.nrao.edu/43m/
![Page 14: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/14.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Add-ons
Add-ons for Scilab/Scicos
The link between Scilab/Scicos and Linux RTAI is implementedthrough:
A code generator → RTAICodeGen .sci.
A rtmain.c (main file for the real-time task) specific for theScilab/Scicos environment.
An external ”template Makefile”
A new scicos palette RTAI-Lib.cosf.
Macros for the new blocks (Scicos interface functions).
A RTAI library specific for the new Scicos blocks (Scicosimplementation functions).
![Page 15: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/15.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
RTAICodeGen .sci
The code generator used in RTAI is a modification of the standardScicos code generator
Only stand-alone generation with specific main procedure(rtmain.c)
Sensors and actuators are integrated in the Scicos blockdiagram as specific custom peripheral blocks
Each block can be identified by a name which is then referredin RTAI-Lab
![Page 16: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/16.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation
SineSine
SCOPEScopeSCOPEScope
comedi0 CH−0COMEDI A/Dcomedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/Acomedi0 CH−0COMEDI D/A
Design
Superblock
RTAICodegen .sci
Code
Compiling and Link
rtmain.c libsciblk.a Scilab lib
Hard real-time stand-alone executable
RT exec
![Page 17: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/17.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation
SineSine
SCOPEScopeSCOPEScope
comedi0 CH−0COMEDI A/Dcomedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/Acomedi0 CH−0COMEDI D/A
Design
Superblock
RTAICodegen .sci
Code
Compiling and Link
rtmain.c libsciblk.a Scilab lib
Hard real-time stand-alone executable
RT exec
![Page 18: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/18.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation
SineSine
SCOPEScopeSCOPEScope
comedi0 CH−0COMEDI A/Dcomedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/Acomedi0 CH−0COMEDI D/A
Design
Superblock
RTAICodegen .sci
Code
Compiling and Link
rtmain.c libsciblk.a Scilab lib
Hard real-time stand-alone executable
RT exec
![Page 19: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/19.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation
SineSine
SCOPEScopeSCOPEScope
comedi0 CH−0COMEDI A/Dcomedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/Acomedi0 CH−0COMEDI D/A
Design
Superblock
RTAICodegen .sci
Code
Compiling and Link
rtmain.c libsciblk.a Scilab lib
Hard real-time stand-alone executable
RT exec
![Page 20: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/20.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation
SineSine
SCOPEScopeSCOPEScope
comedi0 CH−0COMEDI A/Dcomedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/Acomedi0 CH−0COMEDI D/A
Design
Superblock
RTAICodegen .sci
Code
Compiling and Link
rtmain.c libsciblk.a Scilab lib
Hard real-time stand-alone executable
RT exec
![Page 21: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/21.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation -Details
Superblock
rtai.gen
standalone.cmd rtai.mak
model.c model Cblocks.c Makefile
![Page 22: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/22.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation -Details
Superblock
rtai.gen
standalone.cmd rtai.mak
model.c model Cblocks.c Makefile
![Page 23: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/23.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation -Details
Superblock
rtai.gen
standalone.cmd rtai.mak
model.c model Cblocks.c Makefile
![Page 24: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/24.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Code generation -Details
Superblock
rtai.gen
standalone.cmd rtai.mak
model.c model Cblocks.c Makefile
![Page 25: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/25.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Target specific files - The “gen” file
rtai.makstandalone.cmd
![Page 26: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/26.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Target specific files - The “cmd” file
[CCode,FCode]=gen_blocks()[Code,Code_common]=make_standalone42();files=write_code(Code,CCode,FCode,Code_common);Makename=rt_gen_make(rdnom,files,archname);ok=compile_standalone();
![Page 27: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/27.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The code generator
Target specific files - The “mak” file
all: ../$$MODEL$$
...
CC = gcc
CC_OPTIONS = -O -DNDEBUG -Dlinux -DNARROWPROTO -D_GNU_SOURCE
MODEL = $$MODEL$$
OBJSSTAN = rtmain.o common.o $$MODEL$$.o $$OBJ$$
SCILIBS = $(SCIDIR)/libs/scicos.a $(SCIDIR)/libs/poly.a $(SCIDIR)/libs/calelm.a$(SCIDIR)/libs/blas.a $(SCIDIR)/libs/lapack.a $(SCIDIR)/libs/os_specific.a
OTHERLIBS =
ULIBRARY = $(RTAIDIR)/lib/libsciblk.a $(RTAIDIR)/lib/liblxrt.a
CFLAGS = $(CC_OPTIONS) -O2 -I$(SCIDIR)/routines -I$(SCIDIR)/routines/scicos $(C_FLAGS) -DMODEL=$(MODEL) -DMODELN=$(MODEL).c
rtmain.c: $(RTAIDIR)/share/rtai/scicos/rtmain.c $(MODEL).c
cp $< .
../$$MODEL$$: $(OBJSSTAN) $(ULIBRARY)
gcc -static -o $@ $(OBJSSTAN) $(SCILIBS) $(ULIBRARY) -lpthread $(COMEDILIB) -lm
@echo "### Created executable: $(MODEL) ###"
![Page 28: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/28.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Scicos blocks
The new Scicos palette
Sine
Square
Step
test.datextdata
SENS
SENSOR
SCOPEScope
METERMeter
LEDLed
ACTACTUATOR
MBX1Mbx Send Ovw
MBX1Mbx Rcv no blk
MBX1Mbx Send if
MBX1Mbx rcv blk
comedi0 CH−0COMEDI A/D
comedi0 CH−0COMEDI D/A
comedi0 CH−0COMEDI DI
comedi0 CH−0COMEDI DO
SEM1
SEM wait
SEM1SEM signal
BlockC RTAI
0Fifoout
0Fifoin
![Page 29: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/29.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Scicos blocks
Specific blocks for RTAI-Lab
SCOPEScopeSCOPEScope
METERMeterMETERMeter
LEDLEDLEDLED
![Page 30: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/30.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Scicos blocks
Specific blocks for RTAI-Lab
SCOPEScopeSCOPEScope
METERMeterMETERMeter
LEDLEDLEDLED
![Page 31: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/31.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Scicos blocks
Specific blocks for RTAI-Lab
SCOPEScopeSCOPEScope
METERMeterMETERMeter
LEDLEDLEDLED
![Page 32: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/32.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Scicos blocks
Specific blocks for RTAI-Lab
SCOPEScopeSCOPEScope
METERMeterMETERMeter
LEDLEDLEDLED
![Page 33: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/33.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Other palettes
Additional palettes
![Page 34: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/34.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The ”main” file
The main file rtmain.c
3 threads:
Main thread rtMain
Hard RT thread rt BaseRate
Communication thread with the GUI client applicationrt HostInterface
![Page 35: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/35.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The ”main” file
The rt BaseRate thread
WaitTimingEvent
End?
Y
N
HARD real−time
SOFT real−time
SOFT real−time
NAME(MODEL,_isr)(double t);
NAME(MODEL,_init)();
NAME(MODEL,_end)();
![Page 36: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/36.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Adding new blocks
Adding a new block
Each new block needs
An interface function (“.sci”)
An implementation function (“.c”)
![Page 37: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/37.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 38: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/38.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 39: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/39.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 40: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/40.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 41: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/41.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 42: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/42.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
The inverted pendulum
The Inverted Pendulum
Particular of the RF encoder
M1
i1 φ1
RF
receiver
Driver
CAN BUS
PC with HRT
controller
Encoder+RF sender
Reduced orderobsever
Klqr
y
φ
u
The Scicos scheme
SCOPEScope
Safety block
11
Real Plant
LQR_controller Input_ref
Swingup_controller
Sine
0.21Switch
ABS
![Page 43: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/43.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Ball on Beam
The Scicos scheme
Scope
SCOPEScope
Ball on beamControllore + Osservatore
11
−K−siginp.datextdata
The anti-windup controller
Saturazione
11
11
2211
Mux C + O Direct
y=Cx+Dux+=Ax+Bu
Sum
+
+
C + O Feedback
y=Cx+Dux+=Ax+Bu
33
The CANopen blocks
ExpressionMathemati..
0x02encoderEpos
0x02motor IEpos
00x02Epos Analog
11
2211
11
X01sINIT ENC
PHI01sINIT ENC
den(z)num(z)sync
canopenEpos
![Page 44: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/44.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Ball on Beam
The Scicos scheme
Scope
SCOPEScope
Ball on beamControllore + Osservatore
11
−K−siginp.datextdata
The anti-windup controller
Saturazione
11
11
2211
Mux C + O Direct
y=Cx+Dux+=Ax+Bu
Sum
+
+
C + O Feedback
y=Cx+Dux+=Ax+Bu
33
The CANopen blocks
ExpressionMathemati..
0x02encoderEpos
0x02motor IEpos
00x02Epos Analog
11
2211
11
X01sINIT ENC
PHI01sINIT ENC
den(z)num(z)sync
canopenEpos
![Page 45: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/45.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Ball on Beam
The Scicos scheme
Scope
SCOPEScope
Ball on beamControllore + Osservatore
11
−K−siginp.datextdata
The anti-windup controller
Saturazione
11
11
2211
Mux C + O Direct
y=Cx+Dux+=Ax+Bu
Sum
+
+
C + O Feedback
y=Cx+Dux+=Ax+Bu
33
The CANopen blocks
ExpressionMathemati..
0x02encoderEpos
0x02motor IEpos
00x02Epos Analog
11
2211
11
X01sINIT ENC
PHI01sINIT ENC
den(z)num(z)sync
canopenEpos
![Page 46: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/46.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Ball on Beam
The Scicos scheme
Scope
SCOPEScope
Ball on beamControllore + Osservatore
11
−K−siginp.datextdata
The anti-windup controller
Saturazione
11
11
2211
Mux C + O Direct
y=Cx+Dux+=Ax+Bu
Sum
+
+
C + O Feedback
y=Cx+Dux+=Ax+Bu
33
The CANopen blocks
ExpressionMathemati..
0x02encoderEpos
0x02motor IEpos
00x02Epos Analog
11
2211
11
X01sINIT ENC
PHI01sINIT ENC
den(z)num(z)sync
canopenEpos
![Page 47: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/47.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Ball on Beam
The Scicos scheme
Scope
SCOPEScope
Ball on beamControllore + Osservatore
11
−K−siginp.datextdata
The anti-windup controller
Saturazione
11
11
2211
Mux C + O Direct
y=Cx+Dux+=Ax+Bu
Sum
+
+
C + O Feedback
y=Cx+Dux+=Ax+Bu
33
The CANopen blocks
ExpressionMathemati..
0x02encoderEpos
0x02motor IEpos
00x02Epos Analog
11
2211
11
X01sINIT ENC
PHI01sINIT ENC
den(z)num(z)sync
canopenEpos
![Page 48: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/48.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Ball on beam
Videos
Sample Videos
![Page 49: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/49.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Conclusions
Conclusions
Open source!!!
Complete and stable.
Able to solve complex control problems in a simple way.
It runs parallel to a MATLAB/Simulink/RTW environment inmy student laboratory
![Page 50: Targeting the Scicos Codegenerator for embedded … wait SEM1 SEM signal SEM1 C RTAI Block Fifoout 0 Fifoin 0 Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples](https://reader031.fdocuments.net/reader031/viewer/2022022004/5aad12437f8b9a693f8de03c/html5/thumbnails/50.jpg)
Rapid Controller Prototyping Linux RTAI Scicos Implementation Examples Conclusions
Questions
Questions?
Thank You
www.rtai.org
www.dti.supsi.ch/∼bucher/scilab.html
www.dti.supsi.ch/∼smt/laboO4.html