This commit is contained in:
2025-10-23 18:45:13 +02:00
parent 9b652e9338
commit bf8421abb6
6 changed files with 964 additions and 419 deletions

68
QAM/c.py Normal file
View File

@ -0,0 +1,68 @@
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# --- Demande à l'utilisateur ---
user_input = input("GIF ? (o/n) : ").strip().lower()
GENERATE_GIF = user_input == 'o'
# --- Fichiers ---
ref_file = "constellation_ref.dat" # constellation de référence
rx_file = "constellation.dat" # symboles corrigés par la PLL
# Charger les données
ref_constel = np.loadtxt(ref_file) # colonnes I Q
rx_data = np.loadtxt(rx_file) # colonnes I Q
# Paramètres
window_size = 50 # nombre de symboles à afficher dans la fenêtre
speed_factor = 5 # pour accélérer l'animation
N_frames = len(rx_data)
# Figure
fig, ax = plt.subplots(figsize=(6,6))
ax.set_title("Rolling Constellation avec PLL")
ax.set_xlabel("I")
ax.set_ylabel("Q")
ax.grid(True)
# Constellation de référence
ax.scatter(ref_constel[:,0], ref_constel[:,1], c='red', marker='x', label='Référence')
# Points PLL
scat = ax.scatter([], [], c='blue', s=20, label='Points récents')
last_point = ax.scatter([], [], c='green', s=50, label='Dernier symbole')
ax.set_xlim(np.min(ref_constel[:,0])-0.5, np.max(ref_constel[:,0])+0.5)
ax.set_ylim(np.min(ref_constel[:,1])-0.5, np.max(ref_constel[:,1])+0.5)
ax.legend()
# Initialisation
def init():
scat.set_offsets(np.empty((0,2)))
last_point.set_offsets(np.empty((0,2)))
return scat, last_point
# Mise à jour
def update(frame):
idx = min(frame*speed_factor, N_frames)
start_idx = max(0, idx - window_size)
data_window = rx_data[start_idx:idx]
scat.set_offsets(data_window)
if len(data_window) > 0:
last_point.set_offsets(data_window[-1:])
return scat, last_point
# Création de l'animation
ani = FuncAnimation(fig, update, frames=int(N_frames/speed_factor)+1,
init_func=init, blit=True, interval=20)
# --- Sauvegarde GIF conditionnelle ---
if GENERATE_GIF:
ani.save("pll_constellation.gif", writer='pillow', fps=30)
print("GIF généré : pll_constellation.gif")
# Affichage à l'écran
plt.show()

View File

@ -1,416 +1,416 @@
-0.48961254 -0.44544459 -0.56017590 -0.42377949
-0.46513110 1.40428312 -0.45289523 1.51059437
-0.29307347 1.38893240 -0.07257432 1.43147803
1.31089689 -0.55680171 1.27307169 -0.67005556
-0.38632169 1.36097312 -0.37967337 1.36566367
-0.33123545 1.38726262 -0.29333356 1.41363109
-1.26549075 1.37974405 -1.33315292 1.27215770
-1.49852105 -1.19958987 -1.51359683 -1.23385338
-0.31017669 1.30222164 -0.37871841 1.17408296
1.50729893 1.24105325 1.43152849 1.43869158
-0.43017215 0.48948646 -0.52929376 0.42820425
-0.54096932 -0.28558853 -0.57760543 -0.22573077
-0.26310886 1.41585924 -0.51247161 1.38475262
-0.43457847 0.44417363 -0.56765549 0.25187418
-0.19980151 1.35561085 -0.40404161 1.24995427
-0.44785998 -0.33107245 -0.29429508 -0.34257885
-1.14331753 1.50994919 -1.49313732 1.15713334
0.14820610 -1.42291697 0.39917364 -1.40846552
-1.10811359 1.44551804 -1.40466440 0.98792150
-1.57079461 -1.11961078 -1.26379686 -1.51538156
-0.38427593 0.43042485 -0.47168254 0.20463768
-0.81528420 -1.22676725 -0.71913005 -1.39946099
-0.44084375 0.55211323 -0.66378306 0.47166596
-1.12415715 1.46959617 -1.41483771 1.10231336
-0.22904642 1.34965939 -0.47819178 1.21832484
-0.50438838 -0.39136139 -0.41889470 -0.50041356
-0.20762621 1.38489848 -0.38220082 1.32946665
0.33614255 -0.59435058 0.37365887 -0.65804940
-0.42253847 0.49986333 -0.55966082 0.42508728
-1.60347736 -0.95239233 -1.56075333 -0.94008134
-0.03566900 1.37591841 0.06556035 1.33341442
-0.51774331 -0.40091728 -0.48586063 -0.50163934
-0.44026540 0.59544844 -0.59018298 0.67782695
1.61978249 0.94637465 1.63890714 0.85050310
-0.92149464 1.71093438 -0.74794030 1.86791146
-1.56102417 -0.94051892 -1.53179861 -0.77946016
-0.01285030 1.38478328 0.26267466 1.32416755
-1.19627264 0.83013282 -1.05874201 1.08375705
-0.06307302 1.47052202 0.27163575 1.52834151
-0.58523530 -0.26077664 -0.65700148 -0.05629840
-0.98115028 1.59689715 -0.71673708 1.70588451
-1.66141576 -0.88628493 -1.80369749 -0.46584331
-0.00852613 1.43712353 0.37697228 1.42065476
-0.94510653 1.68296522 -0.59118366 1.88920409
0.02796472 1.45841907 0.47444261 1.44714133
0.04359314 -1.43960140 -0.30520153 -1.44651498
0.02915805 1.41430273 0.46287024 1.33856888
0.59530686 0.23857004 0.65884728 -0.03828696
0.01512380 1.39441413 0.52198669 1.26375960
0.87304003 1.07342230 1.22373302 0.55124560
0.03850944 1.47994568 0.75684246 1.37869460
-0.74819139 -1.08237048 -1.01144015 -0.62726620
-0.80309466 1.82889157 0.39573635 2.10090584
-1.69114176 -0.75838051 -1.74711783 0.39637249
-0.22871349 0.55763008 0.20810145 0.52232697
-0.28017727 0.51990165 0.11032738 0.52879796
0.05134513 1.43745319 1.19169298 0.86674812
0.70298158 -1.76376530 -1.20811534 -1.46826148
0.06299865 1.44501145 1.36576595 0.60485822
1.04763519 -0.94454689 -0.58189221 -1.27964494
-0.14211486 0.57473317 0.53520067 0.15282713
-1.05659494 0.90567818 0.62664866 1.20916062
0.21562582 1.42864813 1.48665772 -0.14829934
1.43794919 -0.18192650 -0.17634645 -1.48935341
-0.17191186 0.72065825 0.90249062 0.07726799
1.06943225 -1.00399960 -1.15109529 -1.02455858
-0.62563602 1.77948004 1.84095788 0.33174592
-1.75877350 -0.58976746 -0.18825800 1.78643369
0.15742790 1.38156984 1.28502734 -0.43995878
-1.36716105 0.18569423 0.53709956 1.21817420
-0.10959253 0.56159108 0.47170821 -0.18777161
-1.38029979 0.27498475 0.85638798 1.11088085
-0.16662433 0.63815496 0.67259516 -0.19240908
-0.69299949 -0.22078711 0.21664177 0.83241591
0.24097931 1.43158061 1.01154714 -1.11406080
-0.56183026 -0.17886504 0.22823492 0.47798745
-0.20186054 0.69913865 0.69566311 -0.50666926
-0.62490100 -0.14390235 0.50076049 0.42491448
-0.20291470 0.59305976 0.46338263 -0.41564102
0.51209376 -1.90033204 -1.13263193 1.72903008
-0.45613235 1.87052028 0.84254588 -1.77578692
-0.33525878 -1.36406488 0.21039663 1.37774295
-0.52204801 1.87033049 0.66780608 -1.89088328
-1.80395817 -0.49649028 1.78100201 0.45041323
-0.56417371 -0.09817205 0.49048315 -0.06506837
0.33527724 1.34641187 -0.72402635 -1.13962679
0.25267449 1.38825080 -0.69060936 -1.23539842
0.89090250 -1.07383883 -0.26574100 1.34331078
0.29405742 1.35820577 -0.92346177 -0.99729534
0.34849465 1.37038226 -1.10763676 -0.87876502
-0.31128450 1.84170483 -1.07208503 -1.48331711
-1.79739912 -0.39840073 1.49218375 -0.94083056
0.33475505 1.42320930 -1.34711300 -0.73263351
1.73584529 0.41520891 -1.28453400 1.01606001
-0.11884979 0.65144257 -0.54648352 -0.44319570
-0.58057834 -0.09703036 0.28789875 -0.44141882
0.41486733 1.25197673 -1.18637059 -0.00658476
-0.08610506 0.61807043 -0.55798335 -0.25370211
0.48157488 1.34603546 -1.44175973 0.18565129
-0.51959424 -0.10279402 0.19450483 -0.33744811
-0.22181939 1.85567303 -1.76900569 -0.46837781
-0.43696196 -1.32625724 1.34859325 -0.25273164
-0.22859344 1.91431107 -1.94031017 -0.34050293
-1.86197344 -0.21673157 0.24492776 -1.82645969
-0.07335711 0.70160975 -0.80240115 -0.08842996
-1.19148834 -0.78920537 0.81095501 -1.20193596
-0.13331574 0.62574148 -0.62357056 -0.22046612
-0.12591132 1.90861215 -1.93791955 0.03117123
0.55253930 1.36648515 -1.39726353 0.69037467
-0.61017418 -0.07900305 0.08561544 -0.58690030
0.56494240 1.25763125 -1.16231739 0.65212151
0.03588819 -0.60607038 0.57216330 -0.01413764
-0.16605597 0.61282039 -0.61095165 -0.29411086
-1.83991758 -0.05832141 -0.20225603 -1.75302469
0.44707974 1.32300615 -1.30808974 0.46108705
-0.58169728 -0.00595536 -0.12668999 -0.49715315
0.04035602 0.60491026 -0.51116863 0.28148695
1.82488117 0.13148933 0.39034466 1.69425745
-0.09894890 1.85431403 -1.69460921 0.61361246
-1.94432949 -0.01478929 -1.00158092 -1.74380533
0.65139963 1.21039977 -0.53882345 1.21031644
-0.73792715 1.19409828 -1.40286516 -0.01805414
0.61274010 1.20774353 -0.45321707 1.18787123
-0.55048746 0.06897033 -0.42312486 -0.19827109
-0.00216719 1.94731226 -1.39259474 1.45977775
-1.90572088 -0.00961994 -1.42960869 -1.27853019
0.63257907 1.28332411 -0.32844977 1.41772026
-0.03658697 1.88600425 -1.19368114 1.44698550
0.72958333 1.30050643 -0.07148486 1.59823702
-0.69441386 -1.20574763 0.00583920 -1.36130800
0.59432528 1.18046372 -0.17387102 1.18247255
0.57212587 0.03035341 0.36149591 0.34828894
0.72664451 1.15150859 0.16013382 1.28415764
1.33739250 0.53193906 1.00532357 1.08115165
0.65798374 1.22337579 -0.02437700 1.35588353
-1.27476518 -0.49007002 -0.93426497 -0.90363392
0.05715084 1.91518006 -0.84139839 1.75802080
-1.92376764 0.20568610 -1.92880367 -0.48600801
0.03337894 0.52213641 -0.13462601 0.34591997
0.09766169 0.76246638 -0.20498363 0.93770054
0.72672206 1.20756452 0.21611454 1.38725347
-0.24726369 -1.82461637 0.29412786 -1.74133562
0.84049477 1.19627841 0.49402091 1.45065818
0.45402707 -1.32737360 0.79149310 -1.14064010
0.10396333 0.67426301 -0.08770833 0.74695431
-0.46558946 1.36599073 -0.84896522 1.21788576
0.75612467 1.20061076 0.34699052 1.38588152
1.20224816 -0.82351951 1.42468197 -0.52352703
0.09945559 0.64980823 -0.06694096 0.68912431
0.40092147 -1.39275741 0.71260219 -1.32015171
0.28095155 1.95902585 -0.29333970 2.07329541
-1.89902051 0.38443177 -1.99618602 -0.07031522
0.81312652 1.06565550 0.45826194 1.15059507
-1.10523485 0.81614169 -1.25350933 0.40544865
0.17539027 0.60607147 0.07901791 0.63425212
-1.08341524 0.85037101 -1.21555860 0.52866835
0.11703295 0.56780442 -0.03657218 0.50445859
-0.62514703 0.08280138 -0.60531062 -0.18525472
0.93688915 1.13972258 0.51932143 1.47273191
-0.62616770 0.08694894 -0.58929165 -0.24446090
0.07656169 0.60466805 -0.28542989 0.51302196
-0.58304627 0.12275201 -0.50223486 -0.21168413
0.14060574 0.65332465 -0.33564206 0.63529564
-0.46504121 -1.86336679 0.94113942 -1.71151356
0.47300263 1.79896550 -0.93871449 1.54527150
-0.91510621 -1.05313216 0.23902395 -1.34761376
0.47114393 1.85433307 -1.28448356 1.44736671
-1.77301753 0.46009286 -1.22318413 -1.23729914
-0.54507731 0.16083904 -0.34232917 -0.33539074
0.88330875 0.97594803 -0.48506217 1.07517417
0.84930908 0.97970934 -0.58052853 0.97328586
0.26180808 -1.39899938 1.42127449 -0.20290376
0.92125691 0.88504166 -0.39183048 1.02040707
1.04997851 1.00795302 -0.62271429 1.38445406
0.52998259 1.81511825 -1.62286110 0.95478903
-1.71489073 0.52823691 -0.84406291 -1.41831634
0.98904512 1.04053873 -0.81241922 1.22121696
1.82532442 -0.57436133 0.99585270 1.66151016
0.13520730 0.50528308 -0.34719291 0.14397792
-0.61914934 0.21982490 -0.43043009 -0.54141487
1.01503204 1.05277598 -0.71860297 1.35331665
0.21159036 0.57605876 -0.42362767 0.40682290
0.91660475 0.94049546 -0.48062435 1.07337661
-0.61541016 0.29095564 -0.64403933 -0.39540518
0.62609787 1.74017153 -1.20682145 1.31163237
-1.08752399 -0.99132647 0.32591546 -1.51717009
0.76525865 1.72200222 -0.98439464 1.59340558
-1.76420782 0.71663228 -1.53521313 -1.14231798
0.22353957 0.49553689 -0.21636614 0.36104222
-1.36548697 -0.13614393 -0.47469942 -1.22628876
0.30057974 0.60480370 -0.38567915 0.63071372
0.72688319 1.69890859 -1.16027806 1.34729282
1.02144075 0.87191682 -0.36292738 1.18961391
-0.53104473 0.20727986 -0.31024868 -0.37370633
1.12890578 0.89874637 -0.40896982 1.42555646
-0.34307893 -0.59073421 0.42532007 -0.63357428
0.21189859 0.47810079 -0.28621189 0.23492612
-1.67898034 0.75335891 -1.11048711 -1.36687965
1.11877996 0.92515156 -0.66577896 1.35115783
-0.53524443 0.19639758 -0.21392503 -0.44591791
0.40246637 0.55394168 -0.36815110 0.69364382
1.71671976 -0.84851742 1.25746845 1.47626140
0.85241157 1.67085885 -1.38495585 1.21915608
-1.65999861 0.88996632 -1.28222518 -1.35424120
1.14343675 0.77619951 -0.41617254 1.27269826
0.01973882 1.50709965 -1.59166136 0.38260726
1.23496270 0.84604907 -0.55125726 1.51568086
-0.58865986 0.31450775 -0.47191104 -0.53912710
0.90706106 1.63673024 -1.34156199 1.25223692
-1.64951586 0.99700496 -1.45934771 -1.32788097
1.23705620 0.79200846 -0.45508492 1.47780453
0.90811187 1.69230330 -1.49660089 1.25879692
1.21871516 0.77786107 -0.44647022 1.42251821
-1.21417902 -0.82676679 0.56771393 -1.43889399
1.21843545 0.79754650 -0.50112406 1.42937090
0.46830390 -0.39568361 0.56365752 0.23875599
1.23591198 0.75994717 -0.47217163 1.42547044
1.30664386 -0.15646879 0.42377887 1.10105676
1.20837214 0.66956495 -0.35201711 1.29170494
-1.33597135 0.20770639 -0.48147733 -1.17660087
1.07684938 1.58402836 -1.40565060 1.34040859
-1.63631303 0.97690329 -1.08560707 -1.58828830
0.42837377 0.46174780 -0.31986211 0.56945010
0.33755803 0.49496571 -0.43085927 0.34607761
1.28309836 0.72649413 -0.70529887 1.39000564
-1.02856457 -1.51936209 1.41445828 -1.02573242
1.27789182 0.74562945 -0.77812882 1.36684061
-0.22354338 -1.43585457 1.47265361 -0.32168109
0.40585314 0.61327824 -0.71642896 0.51355019
0.18263466 1.44556002 -1.49788849 0.26034835
1.29947395 0.65836781 -0.51234117 1.42731577
0.67059393 -1.27143638 1.37227722 0.52784304
0.30976849 0.50595737 -0.46348516 0.29575992
-0.35133388 -1.38306488 1.25522763 -0.73185551
1.09424882 1.46139023 -1.16132345 1.27627382
-1.54993037 1.18919991 -1.55075597 -1.31398777
1.26990578 0.58664272 -0.26939794 1.35043607
-0.64627153 1.28576337 -1.41855142 -0.40948380
0.40915803 0.43278891 -0.25321126 0.48887229
-0.60210501 1.29808665 -1.40730351 -0.37248443
0.31782993 0.51648304 -0.51232706 0.29926432
-0.53174512 0.34997737 -0.38071407 -0.53674173
1.27252369 0.54738946 -0.29717868 1.31192675
-0.50931719 0.38587497 -0.44552879 -0.47655817
0.37844860 0.43542442 -0.31306008 0.38938133
-0.57010280 0.32272275 -0.31976359 -0.65691897
0.41449300 0.52494515 -0.50726473 0.51589728
-1.27703904 -1.43171480 1.18179590 -1.54875881
1.31351682 1.41133254 -1.14409922 1.60587726
-1.33669046 -0.53197769 0.33217726 -1.43610604
1.20667648 1.34711079 -1.11026376 1.26957954
-1.36551992 1.34228552 -1.55899666 -1.15478202
-0.53606785 0.42397625 -0.47506953 -0.59884739
1.42643488 0.52754677 -0.46988919 1.60307689
1.25063823 0.46187229 -0.38942873 1.15795644
-0.38606726 -1.35182299 1.34802114 -0.37184219
1.35171097 0.53935539 -0.62581664 1.38743223
1.35062855 0.42160177 -0.37790013 1.36513432
1.36233237 1.34029509 -1.36587105 1.36411209
-1.31043230 1.34643901 -1.29325614 -1.32688108
1.38244016 0.39373355 -0.41926822 1.40926419
1.25066238 -1.44855873 1.46536157 1.27287583
0.43200556 0.46788979 -0.54732285 0.35032616
-0.42134427 0.47098778 -0.44167438 -0.45147896
1.36281212 0.46815575 -0.70616366 1.30925240
0.44083823 0.36229051 -0.31623913 0.36939187
1.38305322 0.32810010 -0.42240683 1.36890939
-0.45110773 0.46380056 -0.39180475 -0.54508873
1.43603839 1.20120537 -1.29625917 1.30114096
-1.32190338 -0.37624311 0.55951250 -1.19822698
1.49449818 1.20125391 -1.33033920 1.42169087
-1.20567682 1.55232534 -1.53949061 -1.37310638
0.58422493 0.41427894 -0.51607031 0.65959938
-1.20715782 0.48988342 -0.21420794 -1.13166431
0.34866497 0.39151998 -0.40112584 0.10434650
1.49886828 1.20337418 -1.36412554 1.40217694
1.44048084 0.19095526 -0.18253252 1.50630130
-0.39314298 0.50199366 -0.47349134 -0.43860083
1.37274013 0.21145366 -0.24281265 1.33394399
-0.51646556 -0.34849968 0.35117264 -0.50147215
0.46286982 0.32106549 -0.28598853 0.36919386
-1.11795301 1.55817381 -1.43019023 -1.32049701
1.43635472 0.12670014 -0.23483888 1.47475181
-0.45229655 0.46130994 -0.27749189 -0.63165706
0.51300846 0.36804529 -0.46284559 0.42590708
1.09069505 -1.46299574 1.08632881 1.34309674
1.56406300 1.04566660 -1.30618130 1.32386728
-0.99216278 1.57795669 -1.35816894 -1.21375094
1.48352041 0.22764812 -0.64705037 1.48984964
0.67153229 1.22104534 -1.32633608 0.32874390
1.38989645 0.16687950 -0.48659272 1.29113157
-0.26628596 0.55482193 -0.52882669 -0.30018355
1.55176085 1.05592934 -1.45751092 1.14215938
-1.00805648 1.59717399 -1.25142097 -1.39860931
1.39738347 0.13954744 -0.53341743 1.28465005
1.64093666 1.09085350 -1.65027378 1.26276577
1.33149219 0.07607907 -0.36803717 1.16532974
-1.49718163 -0.19222213 0.75207139 -1.46823707
1.46484721 0.11587303 -0.55737628 1.44321603
0.30323162 -0.52722447 0.40489024 0.40666496
1.44154326 -0.04261822 -0.20105953 1.48343408
1.15996483 -0.78417104 0.42229726 1.31399171
1.46808337 0.06327806 -0.50654098 1.46207753
-1.13150524 0.70882611 -0.23545608 -1.20839381
1.73417711 0.92971637 -1.45503652 1.46627362
-0.88679017 1.65283145 -1.29302777 -1.31616454
0.65323782 0.27004474 -0.46427478 0.67428475
0.62156850 0.23908697 -0.38984232 0.61084960
1.43120236 -0.01977933 -0.45743592 1.38300930
-1.69704199 -0.81548161 1.35002789 -1.28346580
1.50195468 -0.11010930 -0.42253789 1.58876255
-0.89704982 -1.11511745 1.40458190 -0.38428716
0.51339586 0.28540725 -0.46181943 0.25745516
0.86939319 1.07216313 -1.29395053 0.31923242
1.41848331 -0.03882423 -0.60644398 1.29051309
-0.12057756 -1.45947991 1.45927536 0.48986704
0.69599133 0.22852746 -0.56056645 0.68185625
-0.91695338 -1.05331735 1.32389738 -0.36336689
1.78578231 0.74835257 -1.51990206 1.28573183
-0.74016968 1.81822295 -1.34748636 -1.55220074
1.40289027 -0.11172712 -0.53389984 1.29101337
0.07084859 1.43723720 -1.31833223 -0.66085964
0.58119839 0.21524718 -0.42701096 0.42605912
0.04198519 1.49789145 -1.42175914 -0.78379354
0.57210920 0.22097615 -0.42512484 0.40394351
-0.22366343 0.58627521 -0.43459708 -0.44407656
1.42455620 -0.12982301 -0.49556879 1.36547008
-0.13362457 0.68263829 -0.72904742 -0.34840364
0.54696227 0.24686813 -0.46323258 0.31698070
-0.24118480 0.58089469 -0.39594126 -0.48496526
0.56356655 0.30392984 -0.60301744 0.30669229
-1.77517966 -0.69108184 1.38262772 -1.33212603
1.83172461 0.61442927 -1.25217969 1.53478372
-1.42019865 0.19993192 0.32152636 -1.42648234
1.84241886 0.55973948 -1.15393035 1.59140203
-0.54492246 1.84798540 -1.59386343 -1.15565496
-0.22529925 0.58683552 -0.42095444 -0.46541980
1.42416898 -0.22866871 -0.35802540 1.43752805
1.44660767 -0.19126394 -0.49342695 1.44425771
-1.06656064 -1.02613643 1.47255177 -0.55260500
1.33374832 -0.27671784 -0.27110420 1.26148945
1.35663736 -0.31437592 -0.26427525 1.33989383
1.81277928 0.50904140 -1.32137320 1.31184928
-0.42071499 1.94048571 -1.62598445 -1.35418536
1.34430120 -0.30054542 -0.43921955 1.25147916
0.49215095 -1.80490515 1.14912632 1.43009627
0.55692097 0.14763690 -0.39360822 0.30474643
-0.09100418 0.57967127 -0.41513517 -0.33001712
1.31097206 -0.32851058 -0.50409875 1.15837816
0.60454127 0.10088269 -0.41303325 0.42035104
1.38250158 -0.31253244 -0.71139901 1.23226139
-0.03627446 0.57912606 -0.45349522 -0.28123507
1.85238460 0.35877373 -1.50365788 1.11570311
-1.35123008 0.43176677 0.56486287 -1.31309425
1.94955103 0.36646367 -1.72565247 1.20407268
-0.35021803 1.81764768 -0.99701980 -1.48266831
0.64238008 0.17451633 -0.65250340 0.30452062
-0.82792393 1.19165344 -0.38738202 -1.45457535
0.61155272 0.17222952 -0.58724389 0.27915734
1.81529035 0.32912303 -1.35821685 1.13913325
1.34665515 -0.39850446 -0.50297633 1.29692739
-0.07146229 0.59176372 -0.42880887 -0.33969887
1.31666474 -0.42121180 -0.36733876 1.28695074
-0.66679149 -0.07441151 0.43097612 -0.58386529
0.65795799 0.16475121 -0.59728020 0.46009946
-0.23277688 1.87718572 -1.50840720 -1.12879048
1.28531280 -0.57869031 0.05297976 1.41706535
-0.03715614 0.63080589 -0.56506788 -0.28765738
0.63786408 0.09445329 -0.42032226 0.51389409
0.20978234 -1.91444420 1.60625846 1.13329025
1.89066545 0.19889781 -1.12366083 1.53999467
-0.14577078 1.89789268 -1.58077514 -1.07863608
1.30375767 -0.50887943 -0.29245205 1.34787663
1.20271768 0.69208730 -1.21011805 0.60199587
1.33826305 -0.56560928 -0.37228587 1.46050541
-0.06780183 0.63430771 -0.42178039 -0.49219996
1.93393669 0.05628379 -1.32843700 1.48267086
-0.13854581 1.90279530 -1.22760849 -1.48024074
1.28577881 -0.54780021 -0.57000356 1.25087236
1.89384896 0.06695432 -1.44130397 1.22681830
1.33780890 -0.55354551 -0.73314352 1.30516039
-1.25558620 0.66576944 0.44591569 -1.36824959
1.33159009 -0.48283724 -0.87774197 1.13965235
0.04017382 -0.64200065 0.36097326 0.55198381
1.23844040 -0.59677820 -0.52916743 1.20899602
0.68829395 -1.26704094 0.28575600 1.45408910
1.29130299 -0.59222046 -0.60699782 1.29769355
-0.67535838 1.20820049 -0.25475930 -1.32373641
1.93869890 -0.05791543 -1.31938568 1.50335056
0.12713845 1.87484374 -1.51052347 -1.08866749
0.77657913 0.02040247 -0.72070488 0.66505391
0.63160102 0.00660691 -0.45659354 0.43681641
1.24244624 -0.67370943 -0.33937600 1.36998661
-1.84109063 0.08797837 1.11243972 -1.37420978
1.28182793 -0.69719047 -0.39586394 1.46996408
-1.31319236 -0.52642967 1.26246348 -0.64423889
0.63488504 -0.07598658 -0.36021352 0.54494751
1.32781009 0.62256655 -1.48609384 0.41588619
1.22594177 -0.71521729 -0.43868348 1.35742497
-0.76582438 -1.24994760 1.47085328 0.44995339
0.63268726 -0.15553386 -0.31316292 0.63040356
-1.32682719 -0.53291695 1.41070727 -0.34322719
2.01777801 -0.13027800 -1.78035823 1.29090603
0.14464114 1.90637156 -1.12202816 -1.57423715
1.12406593 -0.75712395 -0.47710792 1.18149901
0.78498751 1.21465878 -1.33930021 -0.65482861
0.62142786 -0.04518144 -0.52175006 0.32022806
0.77876616 1.15380949 -1.24222595 -0.55549998
0.61338544 -0.00774816 -0.55208425 0.23946826
0.06401641 0.66848491 -0.43635780 -0.58306419
1.15548903 -0.83882198 -0.41581288 1.38709588
0.12182780 0.68004504 -0.58111001 -0.51072254
0.54187921 -0.06399507 -0.32392980 0.27489901
0.02153134 0.60988530 -0.30789522 -0.50984649
0.75335082 -0.07216479 -0.68270996 0.63877289
-1.85238231 0.19396941 1.32172043 -1.26227214

BIN
QAM/out

Binary file not shown.

BIN
QAM/pll_constellation.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

416
QAM/pll_error.dat Normal file
View File

@ -0,0 +1,416 @@
0 -1.45145122
1 -1.69906690
2 -4.47129748
3 -5.96330133
4 -6.20274205
5 -7.13778791
6 -6.55095757
7 -7.31721234
8 -7.08483494
9 -6.74317554
10 -5.34416146
11 -9.48171937
12 -8.72074064
13 -4.47730085
14 -4.42917130
15 -3.49487851
16 -2.08100979
17 -2.55150948
18 -0.70290026
19 0.18363787
20 4.03597337
21 2.11953487
22 3.68191049
23 4.70294370
24 4.92539441
25 5.52268401
26 4.72237126
27 1.57472911
28 2.85667589
29 0.08084627
30 2.88460646
31 2.84225779
32 1.90955201
33 3.40792005
34 3.80169821
35 5.12583620
36 6.14431738
37 5.66675682
38 6.87978408
39 -0.87481631
40 -0.05368555
41 -0.80306149
42 -0.13019453
43 -0.34419021
44 -0.30070107
45 0.88737764
46 0.69805424
47 8.30137602
48 7.11938407
49 7.81242046
50 5.50869135
51 7.68861587
52 8.73351157
53 9.34469514
54 13.17554315
55 18.65018280
56 16.10333524
57 16.37581363
58 16.63317216
59 14.78530104
60 8.81006528
61 6.84977226
62 8.98860843
63 10.83226215
64 7.95317945
65 7.10940122
66 5.41714263
67 3.04563046
68 2.99832724
69 2.05672074
70 6.43537931
71 2.78064022
72 8.18759541
73 13.57710530
74 12.60169208
75 15.77959050
76 16.87109105
77 15.41961906
78 15.49255411
79 12.84119520
80 8.89749301
81 10.56824668
82 10.55730128
83 9.59079221
84 16.35080551
85 13.31914194
86 11.05072593
87 9.55958089
88 5.00713647
89 3.96703103
90 5.87492565
91 3.47177735
92 5.59215940
93 6.97470545
94 5.97329242
95 3.93945986
96 0.86904990
97 -2.48934317
98 0.14338149
99 -2.16685565
100 -2.25690594
101 -0.24335560
102 -1.33219419
103 -2.79209131
104 -9.31325358
105 -5.52403828
106 -9.49539136
107 -5.35570659
108 -6.10164228
109 -12.11985791
110 -13.08769484
111 -4.00635737
112 -6.96227952
113 -4.04450905
114 -3.64227377
115 2.56272808
116 5.77523192
117 6.86031000
118 6.62188994
119 4.56981296
120 5.75500291
121 2.60708698
122 3.32962730
123 -0.09052149
124 0.07621438
125 -0.10467282
126 -0.68057940
127 -1.24368959
128 -3.69074455
129 -6.44113626
130 -7.56310359
131 -6.97913861
132 -4.15347746
133 -3.17845751
134 -5.84090794
135 -5.34665734
136 -3.39462249
137 -3.64969938
138 -7.47118161
139 -7.86066917
140 -5.35381343
141 -6.37115643
142 -5.78377818
143 -2.16272938
144 -8.77711769
145 -4.99046608
146 -3.62371673
147 -3.45696508
148 -10.23777868
149 -7.59832183
150 -8.83779550
151 -11.13261158
152 -10.90480090
153 -10.00272162
154 -2.28176461
155 -2.86432657
156 -10.00081999
157 -14.41239732
158 -13.64677658
159 -16.88559698
160 -18.76857263
161 -21.72090154
162 -23.62523675
163 -20.39444483
164 -16.89736111
165 -17.50123439
166 -17.17925405
167 -16.20401520
168 -15.46453216
169 -13.59623072
170 -10.63738928
171 -8.22311012
172 -7.36538599
173 -5.96911968
174 -3.04249646
175 -5.20874414
176 -2.20705586
177 0.42838079
178 4.47557207
179 5.38295859
180 6.80423659
181 6.61924941
182 7.28338334
183 4.40105110
184 3.70794847
185 2.33214633
186 -0.25414357
187 -1.79778196
188 -4.31533593
189 -4.62189817
190 -6.90886381
191 -7.37663740
192 -7.31377994
193 -6.01682373
194 -6.21451273
195 -8.00836831
196 -6.63808044
197 -5.29252000
198 -3.67479401
199 -0.01579635
200 -3.24272244
201 -2.33048453
202 -1.63937137
203 -1.36790471
204 -1.45983305
205 -0.58380344
206 -0.37285257
207 0.24099117
208 0.48661638
209 -0.13932687
210 -0.47900574
211 0.34809387
212 0.03992012
213 0.50297697
214 0.53593848
215 -3.64907920
216 -3.58769334
217 -3.99449156
218 -4.49021829
219 -5.08078443
220 -4.69337199
221 -2.62307952
222 -5.50376317
223 -4.21298382
224 -2.58114827
225 -0.92913671
226 1.03499465
227 1.96002656
228 3.43768349
229 4.69710877
230 4.56051729
231 4.67363721
232 6.59793144
233 3.96693152
234 3.15127175
235 2.00866377
236 0.48054901
237 -0.08175854
238 -3.42615735
239 -4.02519501
240 -1.22835864
241 0.49255752
242 -0.69301956
243 -0.42056019
244 -1.65750588
245 1.81069703
246 1.51023294
247 -0.09192436
248 -1.95684559
249 -2.96963711
250 -3.64243340
251 -5.13804724
252 -3.79458214
253 -4.11955420
254 -4.01802989
255 -3.39988071
256 -2.29684548
257 -2.87253060
258 -2.87004370
259 -2.74227682
260 -3.10253800
261 -3.84366334
262 -1.53462091
263 -1.50718489
264 0.22339113
265 -0.77223672
266 -1.13854921
267 0.45827230
268 0.24445067
269 1.27468792
270 0.69046447
271 -0.11451626
272 -1.55685215
273 -0.22709654
274 5.20895985
275 4.63052990
276 2.11208493
277 1.44270435
278 -0.28080600
279 -2.26110351
280 -3.63402626
281 -4.02880320
282 -5.71386376
283 -1.67717988
284 -1.32732970
285 -0.32506023
286 -0.55533009
287 -1.29451090
288 -0.47877935
289 0.19751679
290 0.41626688
291 -2.61897328
292 -1.39248950
293 -0.91815048
294 -0.29724235
295 0.92815575
296 0.53076870
297 1.91918980
298 2.13336695
299 1.86855532
300 -0.37452090
301 -0.41759410
302 -0.44867232
303 0.76005983
304 0.50404262
305 0.39574557
306 -1.72202589
307 -4.10068383
308 -4.09485932
309 -3.80289207
310 -4.44764031
311 -3.83613249
312 -0.91946627
313 -0.22982236
314 0.82101275
315 0.60214958
316 -0.65258179
317 -0.25001500
318 0.44121658
319 0.96245495
320 1.45675107
321 2.69145796
322 2.37095582
323 3.97637516
324 3.85361441
325 3.58577535
326 3.50000828
327 -0.43423912
328 1.36523917
329 2.18195567
330 5.21570149
331 4.97610029
332 3.49323687
333 2.10115109
334 0.17235424
335 -1.65693151
336 -1.19993225
337 -2.11430285
338 -2.08670069
339 -2.53396648
340 -3.72798679
341 -5.04291244
342 -4.91874652
343 -5.80267373
344 -5.52241278
345 -4.28532392
346 -2.92635899
347 -4.17278916
348 -3.22602464
349 -3.35881958
350 -1.26911975
351 -3.84201081
352 -2.30996479
353 -1.51851602
354 0.19661667
355 2.00483430
356 5.35872769
357 5.51796261
358 8.62712861
359 8.90680187
360 8.76741407
361 6.92001797
362 5.93110615
363 3.88445548
364 4.88271185
365 2.96859712
366 5.65956130
367 1.90664653
368 0.61185042
369 -1.36498789
370 -3.07352133
371 -5.02975949
372 -6.06279919
373 -7.38376800
374 -7.93086081
375 -6.88736975
376 -7.29285632
377 -6.12726282
378 -4.89349560
379 -3.99839930
380 -1.99635080
381 -2.17305647
382 1.25292461
383 3.15141476
384 3.73890886
385 4.68866735
386 5.46853657
387 6.38095697
388 5.18027131
389 3.03735287
390 3.12669418
391 3.02499566
392 1.86693090
393 0.49700351
394 -0.31489838
395 -2.04849665
396 -4.23446144
397 -3.67551828
398 -3.76101457
399 -4.01155962
400 -7.40896510
401 -6.34552867
402 -4.55391017
403 -2.77388463
404 -2.18594372
405 -0.88289000
406 1.42591973
407 2.18216875
408 5.82453862
409 6.82758168
410 5.95849746
411 4.78360579
412 5.21365704
413 7.31742854
414 7.11921723
415 6.83090473

View File

@ -314,6 +314,56 @@ void po(qam_system* qam, double complex* s_with_preamble, double complex* preamb
} }
} }
// Costas loop
void pll(qam_system* qam, double complex* s_with_preamble, double complex* r_corr, int L, int total_samples, int nb_symbols, double Kp, double Ki, double alpha, FILE* fp_error) {
double phase_est = 0.0;
double integrator = 0.0;
double filtered_error = 0.0;
int start_data_idx = L * qam->N;
int N = qam->N;
for (int k = 0; k < nb_symbols; k++) {
double complex r_k = 0;
for (int n = 0; n < N; n++) {
int idx = start_data_idx + k * N + n;
double t = (double)idx / qam->Fs;
r_k += s_with_preamble[idx] * cexp(-2.0 * I * M_PI * qam->Fc * t) / A;
}
double complex r_symbol = r_k / N;
r_symbol *= cexp(-I * phase_est);
double min_dist = INFINITY;
double complex closest = 0;
for (int idx = 0; idx < qam->M; idx++) {
double dist = cabs(r_symbol - qam->constellation[idx]);
if (dist < min_dist) {
min_dist = dist;
closest = qam->constellation[idx];
}
}
double error = carg(r_symbol * conj(closest));
filtered_error = (1.0 - alpha) * filtered_error + alpha * error;
integrator += Ki * filtered_error;
phase_est += Kp * filtered_error + integrator;
if (fp_error) {
fprintf(fp_error, "%d % .8f\n", k, 100 * filtered_error);
fflush(fp_error);
}
for (int n = 0; n < N; n++) {
int idx = start_data_idx + k * N + n;
r_corr[idx] = s_with_preamble[idx] * cexp(-I * phase_est);
}
}
}
int main () { int main () {
// Initialisation du system qam // Initialisation du system qam
qam_system qam; qam_system qam;
@ -354,7 +404,7 @@ int main () {
double complex* s_with_preamble = concat_preamble_signal(preamble_mod, L, s_mod, nb_symbols, qam.N); double complex* s_with_preamble = concat_preamble_signal(preamble_mod, L, s_mod, nb_symbols, qam.N);
// Ajout du bruit // Ajout du bruit
add_noise(s_with_preamble, total_samples, 10); add_noise(s_with_preamble, total_samples, 24);
FILE *fp_ref = fopen("constellation_ref.dat", "w"); FILE *fp_ref = fopen("constellation_ref.dat", "w");
fill_constellation_data(&qam, fp_ref); fill_constellation_data(&qam, fp_ref);
@ -364,7 +414,7 @@ int main () {
add_dephasage(s_with_preamble, M_PI / 6.0 , total_samples); add_dephasage(s_with_preamble, M_PI / 6.0 , total_samples);
// AJout de decalage de fréquence // AJout de decalage de fréquence
add_freq(&qam, s_with_preamble, 10, total_samples); add_freq(&qam, s_with_preamble, 50, total_samples);
// Estimation / correction du CFO // Estimation / correction du CFO
cfo(s_with_preamble, qam.N, L, qam.Fs, total_samples, qam.Fc); cfo(s_with_preamble, qam.N, L, qam.Fs, total_samples, qam.Fc);
@ -373,10 +423,21 @@ int main () {
// Correction phase // Correction phase
po(&qam, s_with_preamble, preamble, L, total_samples); po(&qam, s_with_preamble, preamble, L, total_samples);
// PLL
double complex* s_corrected = malloc(sizeof(double complex) * total_samples);
double Kp = 0.5;
double Ki = 0.01;
double alpha = 0.1;
FILE *fp_pll_error = fopen("pll_error.dat", "w");
pll(&qam, s_with_preamble, s_corrected, L, total_samples, nb_symbols, Kp, Ki, alpha, fp_pll_error);
fclose(fp_pll_error);
// Démodulation // Démodulation
FILE *fp_constel = fopen("constellation.dat", "w"); FILE *fp_constel = fopen("constellation.dat", "w");
uint8_t* output_bits = (uint8_t*)malloc(nb_bits * sizeof(uint8_t)); uint8_t* output_bits = (uint8_t*)malloc(nb_bits * sizeof(uint8_t));
demodulate(&qam, s_with_preamble + L * qam.N, nb_symbols, output_bits, fp_constel); demodulate(&qam, s_corrected + L * qam.N, nb_symbols, output_bits, fp_constel);
fclose(fp_constel); fclose(fp_constel);
// Reconstruction du texte // Reconstruction du texte