Code covered by the BSD License  

Highlights from
Logiciels temps réel

Logiciels temps réel

by

 

Real-time software concerning the domains of the signal processing, feedback and regulation

harmoniques_signal.m
function [F,A,PHI,CC]=harmoniques_signal(signal)


repertoire=pwd;
cd ..
A=load('parametres_carte.mat');
cd(repertoire)
carte_sortie=A.S.sortie.carte;
plage_sortie=num2str(A.S.sortie.pop);
CC=0;
switch signal
    case 2              %triangle
        n=1:2:19;
        AC=5*(4/pi^2)./n.^2;
    case 3              %dents de scie
        n=1:1:10;
        AC=5*i*(1/pi)*((-1).^n)./n;
    case 4              %carr
         n=1:2:19;
         AC=5*i*(-2/pi)./n;
    case 5              %impulsions largeur 0.1 s
        n=1:1:10;
        AC=5*0.25*sinc(0.25*n);
        CC=5*0.25;
    case 6              %peigne
        n=1:1:10;
        AC=0.25*ones(size(n));
        CC=0.25;
    case 7              %sinusode redresse double alternance
        CC=5*2/pi;
        n=2:2:20;
        AC=zeros(size(n));
        AC(1)=5/(4*i);
        for k=1:1:length(n)
            AC(k)=(-5*2/pi)/((n(k)+1)*(n(k)-1));
        end;
end;
F=n;
A=2*abs(AC);
PHI=(pi/2)*ones(size(n))+angle(AC);
modele='reconstruction';
open_system([modele,'.mdl'])
for k=1:1:9
            if k==1
                bloc=[modele,'/Manual Switch'];
            else
                 bloc=[modele,'/Manual Switch',num2str(k-1)];
            end;
            set_param(bloc,'maskvaluestring','1|0|off')
            bloc=[modele,'/Sine Wave',num2str(k)];
            set_param(bloc,'Amplitude',num2str(A(k+1),10),'Frequency',num2str(F(k+1),10),'Phase',num2str(PHI(k+1),10))
end;
bloc=[modele,'/Sine Wave'];
set_param(bloc,'Amplitude',num2str(A(1),10),'Frequency',num2str(F(1),10),'Phase',num2str(PHI(1),10))
 bloc=[modele,'/Constant1'];
 set_param(bloc,'value',num2str(CC,10));
bloc3=[modele,'/compil'];
set_param(bloc3,'foregroundcolor','white')
set_param(gcs,'solver','FixedStepDiscrete')
set_param(gcs,'StartTime','0') 
set_param(gcs,'StopTime','Inf') 
set_param(gcs,'SystemTargetFile','rtwin.tlc') 
s=get_param(gcs,'Name');
sbao=[s,'/Analog Output'];
    set_param(sbao,'drvname',carte_sortie);
    set_param(sbao,'voltrange',plage_sortie);            
set_param(gcs,'SimulationMode','external');
set_param(gcs,'ExtMode','on');
set_param(bloc3,'foregroundcolor','red')
 pause(1)
rtwbuild(gcs);
set_param(bloc3,'foregroundcolor','white')
pause(1)
set_param(gcs,'SimulationCommand','connect');          
pause(1)
set_param(gcs,'SimulationCommand','start') 
        
           
        
        
        

Contact us