début de la DFT

This commit is contained in:
Slamnia Enzo 2023-05-22 12:13:10 +02:00
parent fe6be534f1
commit b6baee8edc
32 changed files with 11351 additions and 11482 deletions

View file

@ -1,173 +0,0 @@
%%
%TUTO BAC A SABLE
figure(1);
plot(Res.Sinus_Continu);
hold on;
plot(Res.Sinus_Echanti,'o');
grid;
title('Courbe temporelle du Sinus');
tab = linspace(0,M-1,M);
tab = tab*(Fe/M);
r = fft(Res.Sinus_Echanti.data);
figure(2);
stem(tab,abs(r/M));
grid;
title('Module de la TFD en fonction de la fréquence');
%%
%QUESTION 1 ET 2
clear all;
close all;
clc;
Fe = 320000;
Te = 1/Fe;
T = 1/5000;
M = T/Te;
Tsim = T-Te;
F1 = 85000;
F2 = 90000;
F3 = 95000;
F4 = 100000;
F5 = 115000;
F6 = 120000;
Res = sim('SimuGuns');
echelle_freq = linspace(0,M-1,M)*(Fe/M);
r = fft(Res.Echanti.data);
figure(1);
plot(Res.Continu);
grid;
figure(2);
plot(echelle_freq,abs(r/M),'o');
grid;
%%
%QUESTION 3
clear all;
close all;
clc;
Fe = 320000;
Te = 1/Fe;
T = 1/5000;
M = T/Te;
Tsim = T-Te;
F1 = 85005.9;
F2 = 90000;
F3 = 94846.8;
F4 = 100000;
F5 = 115015.9;
F6 = 120000;
Res = sim('SimuGuns');
echelle_freq = linspace(0,M-1,M)*(Fe/M);
r = fft(Res.Echanti.data);
figure(1);
plot(Res.Continu);
grid;
hold on;
figure(2);
semilogy(echelle_freq,abs(r/M));
grid;
%%
%Question 4
clear all;
close all;
clc;
Fe = 320000;
Te = 1/Fe;
T = 1/5000;
M = T/Te;
Tsim = T-Te;
F1 = 85005.9;
F2 = 90000;
F3 = 94846.8;
F4 = 100000;
F5 = 115015.9;
F6 = 120000;
Res = sim('SimuGuns');
for i = 1:32
Res.Echanti.data(i) = 0;
end
echelle_freq = linspace(0,M-1,M)*(Fe/M);
r = fft(Res.Echanti.data);
figure(1);
plot(Res.Continu);
grid;
hold on;
figure(2);
semilogy(echelle_freq,abs(r/M));
grid;
%%
%Question 6
clear all;
close all;
clc;
F1 = 85000;
Fe = 320000;
Te = 1/Fe;
%T = 1/F1;
%M = T/Te;
T = 2*10^(-4);
M=2^6;
Tsim = T-Te;
Res = sim('SimuGuns');
echelle_freq = linspace(0,M-1,M)*(Fe/M);
r = fft(Res.carre1.data);
figure(1);
plot(Res.carre1);
grid;
hold on;
figure(2);
plot(echelle_freq,log10(abs(r/M)),'o');
grid;
%%
% Question 8
clear all;
close all;
clc;
F1 = 85000;
Fe = 320000;
Te = 1/Fe;
%T = 1/F1;
%M = T/Te;
T = 2*10^(-4);
M=2^6;
Tsim = T-Te;
p = tf('p');
Fp = 1/(1.7483e-23*p^4 + 7.6663e-18*p^3 + 1.162e-11*p^2 + 3.0332e-6*p+1);
Res = sim('SimuGuns');
echelle_freq = linspace(0,M-1,M)*(Fe/M);
r = fft(Res.carre.data);
figure(1);
plot(Res.carre);
grid;
hold on;
figure(2);
bode(Fp);
plot(bode(Fp));
%plot(echelle_freq,log10(abs(r/M)),'o');
grid;

View file

@ -10,7 +10,8 @@
;Section RAM (read write):
area maram,data,readwrite
M DCD 63
Index DCD 0
; ===============================================================================================
@ -29,6 +30,19 @@
AREA Trigo, DATA, READONLY
; codage fractionnaire 1.15
DFT_ModuleAuCaree proc
push{r2,r3,r4,r5,r6,r7,r8,r9}
ldr r3,=TabCos
ldr r2,=M
ldr r2,[r2]
ldr r7,=Index
ldr r4,[r7]
etape1
ldrsh r5 ,[r3
TabCos
DCW 32767 ; 0 0x7fff 0.99997
DCW 32610 ; 1 0x7f62 0.99518
@ -163,4 +177,7 @@ TabSin
END

View file

@ -14,6 +14,13 @@ int main(void)
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
CLOCK_Configure();
// K1 (85) = 34
// K2 (90) = 36
// K3 (95) = 38
// K4 (100) = 40
// K5 (115) = 46
// K6 (120) = 48

View file

@ -0,0 +1,7 @@
#ifndef GESTIONSON_H__
#define GESTIONSON_H__
void CallbackSon(void);
void StartSon(void);
#endif

View file

@ -4,6 +4,7 @@
IMPORT PeriodeSonMicroSec
IMPORT Son
IMPORT PWM_Set_Value_TIM3_Ch3
EXPORT CallbackSon
; ====================== zone de réservation de données, ======================================
@ -38,7 +39,8 @@ CallbackSon proc
ldr r7,=Index
ldr r4,[r7] ;compteur
cmp r4,r2
moveq r4,#0
;moveq r4,#0
beq fin
mov r5,#(1<<15) ;registre pour operations
mov r6,#719 ;sauvegarde de 719
@ -58,9 +60,20 @@ calcul
;add r4,#1
;cmp r2,r4
;bne calcul
fin
pop {r4,r5,r6,r7,lr}
bx lr
endp
StartSon proc
ldr r1,=Index
ldr r2,=LongueurSon
cmp r1,r2
bne pass
mov r1,#0
pass
bx lr
endp
END

View file

@ -24,14 +24,12 @@ Timer_1234_Init_ff(TIM4, 91*72);
Active_IT_Debordement_Timer( TIM4, 2, CallbackSon );
//============================================================================
while (1)
{
}
}

View file

@ -259,12 +259,12 @@
<Wi>
<IntNumber>0</IntNumber>
<FirstString>`SortieSon</FirstString>
<SecondString>FF0000000000000000000000000000000078864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000E03F1400000000000000000000000000000000000000C40A0008</SecondString>
<SecondString>FF0000000000000000000000000000000078864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000E03F1500000000000000000000000000000000000000C40A0008</SecondString>
</Wi>
<Wi>
<IntNumber>1</IntNumber>
<FirstString>((portb &amp; 0x00000001) &amp; 0x1) &gt;&gt; 0</FirstString>
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F72746220262030783030303030303031290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000FFFFFFFFFFFFDF3F1400000000000000000000000000000000000000D20A0008</SecondString>
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F72746220262030783030303030303031290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000FFFFFFFFFFFFDF3F1500000000000000000000000000000000000000D20A0008</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription>