Objectifs Comprendre l’approche Model-Based Design Implémenter un contrôleur temps réel Maîtriser les types de données (fixed point, flottant) Comprendre l’implémentation multi-rate Model Based DesignIdentification Simulation / synthèse commande Test type de données Virgule Fixe Virgule Flottante Virgule fixe int8 $\underbrace{1}_{sign\ (1)} \ \underbrace{1111111}_{mantisse\ (7)} * \underbrace{slope}_{\text{LSB value}}$
$v = (mantisse-sign*128) * slope $
plage: $\pm 2^{7} * slope$
2 digit [0-9] significatifs
Virgule flottante Single (32 bits) $\underbrace{1}_{sign\ (1)} \ \underbrace{11111111}_{exponent\ (8)} \ \color{yellow}{1}\underbrace{11111111111111111111111}_{mantisse\ (23)} $
$v \approx (1-2 sign) * mantisse * 2^{exponent-127}$
plage: $\pm 2^{128} = \pm 3.4*10^{38}$
7 digit [0-9] significatifs
IEEE 754 Single Double Format width 32 64 Sign bit 1 1 exponent width 8 11 Precision width 23+1 52+1
1st phantom bitof the significand is always 1.
Virgule flottante Custom (8 bits) $\underbrace{1}_{sign\ (1)} \ \underbrace{1111}_{exponent\ (4)} \ \color{yellow}{1}\underbrace{111}_{mantisse\ (3)} $
$v \approx (1-2 sign) * mantisse * 2^{exponent-127}$
plage: $\pm 2^{128} = 3.4*10^{38}$
0.9 digit [0-9] significatifs
Custom 8 bit Floating point Parameter Single Double Custom Format width 32 64 8 Sign bit 1 1 1 exponent width 8 11 4 Precision width 23+1 52+1 3+1
Integrateur (avec petit TS)
GPS Script Matlab pour tester un flottant 8 bits % 4 bit exponent (signed)
emin = - 7 ; emax = 6 ;
% 3 bits significand
p = 3 ;
exps = 2. ^[ emin : emax ];
vals = ( 2 ^p ) + [ 0 :( 2 ^p - 1 )]; % significand with leading 1
TotalVal = vals '* exps ;
% add denormalized values
float8bit = unique ([ TotalVal ; 2 ^emin * ( 0 :( 2 ^p - 1 )) ' ]);
float8bit = unique ([ flipud ( - TotalVal ); TotalVal ]); % with neg vals
Data-type
Data-type notation int8…uint23 fixdt(1,16)signed (1) 16 bit width Scaling is derived from defined min & max fixdt(1,16,15)Scaling is En 15 (Exp neg $\rightarrow 2^{-15}$) fixdt(1,16,-15)Scaling is E 15 (Exp $\rightarrow 2^{15}$)
SI : Stored IntegerRWV : Real World ValueCouleurs : Period echantillonnage Datatype
Aspect Temporel: Simulation Modélisation en temps continu:
transformé de Laplace en p (s)
Solver résoud les équations différentielles Pas de contraintes temps réelledifférent solveurs (Runge-Kutta, ODEx,…) Couleurs : Period echantillonnage
DSPACE discretise le modèle Aspect Temporel: Implémentation Implémentation en temps discret:
“pas” de calcul fixe
pas de solveur Contrainte temps réelmodel Single-Rate & Multi-Rate implementation Single-Tasking & Multi-Tasking Single Rate / Multi rate
Single Tasking / Multi Tasking Discrete times Single-rate :
Les blocks ont tous la même période d’exécution
(Même couleur) Multi-Rate
Les blocks peuvent avoir des périodes d’exécution différentes
(Schéma multicolore) Modèle multi-rate
Charge CPU d’un modèle multi-rate single-tasking (@70 mips)
Charge CPU d’un modèle multi-rate single-tasking (@20 mips)
Single-Tasking Single-Tasking: Dans le slot de temps, l’exécution de tous les blocks doit se terminer avant la fin du slot.
Multi-Tasking Multi-Tasking: Préemption possible -> Monotonic Rate Scheduler
La tâche la plus fréquente à la priorité maximalePréemptera une tache plus lente Beaucoup plus flexible Mode par défaut (voir options du solveur) Charge CPU d’un modèle multi-rate multi-tasking (@70 mips)
Charge CPU d’un modèle multi-rate multi-tasking (@20 mips)
Tasking Conclusion 20 MIPS ok avec multi-tasking
Single tasking: deterministe Slide control: Next: Right Arrow or Space Previous: Left Arrow Start: Home Finish: End Overview: Esc Speaker notes: S Fullscreen: F Zoom: Alt + Click