diff --git a/openrtx/include/protocols/M17/M17DSP.h b/openrtx/include/protocols/M17/M17DSP.h index 4963eace..3c2b7bb0 100644 --- a/openrtx/include/protocols/M17/M17DSP.h +++ b/openrtx/include/protocols/M17/M17DSP.h @@ -36,7 +36,7 @@ namespace M17 /* * Coefficients for M17 RRC filter */ -extern const std::array rrc_taps; +extern const std::array rrc_taps; /* * FIR implementation of the RRC filter for baseband audio generation. diff --git a/openrtx/src/protocols/M17/M17DSP.cpp b/openrtx/src/protocols/M17/M17DSP.cpp index cda8d40e..45f3cb0d 100644 --- a/openrtx/src/protocols/M17/M17DSP.cpp +++ b/openrtx/src/protocols/M17/M17DSP.cpp @@ -26,34 +26,34 @@ namespace M17 /* * Coefficients for M17 RRC filter for 48KHz sample rate */ -const std::array rrc_taps = { - -0.009265784007800534, -0.006136551625729697, -0.001125978562075172, - 0.004891777252042491, 0.01071805138282269, 0.01505751553351295, - 0.01679337935001369, 0.015256245142156299, 0.01042830577908502, - 0.003031522725559901, -0.0055333532968188165, -0.013403099825723372, - -0.018598682349642525, -0.01944761739590459, -0.015005271935951746, - -0.0053887880354343935, 0.008056525910253532, 0.022816244158307273, - 0.035513467692208076, 0.04244131815783876, 0.04025481153629372, - 0.02671818654865632, 0.0013810216516704976, -0.03394615682795165, - -0.07502635967975885, -0.11540977897637611, -0.14703962203941534, - -0.16119995609538576, -0.14969512896336504, -0.10610329539459686, - -0.026921412469634916, 0.08757875030779196, 0.23293327870303457, - 0.4006012210123992, 0.5786324696325503, 0.7528286479934068, - 0.908262741447522, 1.0309661131633199, 1.1095611856548013, - 1.1366197723675815, 1.1095611856548013, 1.0309661131633199, - 0.908262741447522, 0.7528286479934068, 0.5786324696325503, - 0.4006012210123992, 0.23293327870303457, 0.08757875030779196, - -0.026921412469634916, -0.10610329539459686, -0.14969512896336504, - -0.16119995609538576, -0.14703962203941534, -0.11540977897637611, - -0.07502635967975885, -0.03394615682795165, 0.0013810216516704976, - 0.02671818654865632, 0.04025481153629372, 0.04244131815783876, - 0.035513467692208076, 0.022816244158307273, 0.008056525910253532, - -0.0053887880354343935, -0.015005271935951746, -0.01944761739590459, - -0.018598682349642525, -0.013403099825723372, -0.0055333532968188165, - 0.003031522725559901, 0.01042830577908502, 0.015256245142156299, - 0.01679337935001369, 0.01505751553351295, 0.01071805138282269, - 0.004891777252042491, -0.001125978562075172, -0.006136551625729697, - -0.009265784007800534 +const std::array rrc_taps = { + -0.003195702904062073, -0.002930279157647190, -0.001940667871554463, + -0.000356087678023658, 0.001547011339077758, 0.003389554791179751, + 0.004761898604225673, 0.005310860846138910, 0.004824746306020221, + 0.003297923526848786, 0.000958710871218619, -0.001749908029791816, + -0.004238694106631223, -0.005881783042101693, -0.006150256456781309, + -0.004745376707651645, -0.001704189656473565, 0.002547854551539951, + 0.007215575568844704, 0.011231038205363532, 0.013421952197060707, + 0.012730475385624438, 0.008449554307303753, 0.000436744366018287, + -0.010735380379191660, -0.023726883538258272, -0.036498030780605324, + -0.046500883189991064, -0.050979050575999614, -0.047340680079891187, + -0.033554880492651755, -0.008513823955725943, 0.027696543159614194, + 0.073664520037517042, 0.126689053778116234, 0.182990955139333916, + 0.238080025892859704, 0.287235637987091563, 0.326040247765297220, + 0.350895727088112619, 0.359452932027607974, 0.350895727088112619, + 0.326040247765297220, 0.287235637987091563, 0.238080025892859704, + 0.182990955139333916, 0.126689053778116234, 0.073664520037517042, + 0.027696543159614194, -0.008513823955725943, -0.033554880492651755, + -0.047340680079891187, -0.050979050575999614, -0.046500883189991064, + -0.036498030780605324, -0.023726883538258272, -0.010735380379191660, + 0.000436744366018287, 0.008449554307303753, 0.012730475385624438, + 0.013421952197060707, 0.011231038205363532, 0.007215575568844704, + 0.002547854551539951, -0.001704189656473565, -0.004745376707651645, + -0.006150256456781309, -0.005881783042101693, -0.004238694106631223, + -0.001749908029791816, 0.000958710871218619, 0.003297923526848786, + 0.004824746306020221, 0.005310860846138910, 0.004761898604225673, + 0.003389554791179751, 0.001547011339077758, -0.000356087678023658, + -0.001940667871554463, -0.002930279157647190, -0.003195702904062073, }; Fir< std::tuple_size< decltype(rrc_taps) >::value > rrc(rrc_taps); diff --git a/openrtx/src/protocols/M17/M17Demodulator.cpp b/openrtx/src/protocols/M17/M17Demodulator.cpp index afbefd50..942909ef 100644 --- a/openrtx/src/protocols/M17/M17Demodulator.cpp +++ b/openrtx/src/protocols/M17/M17Demodulator.cpp @@ -84,7 +84,7 @@ void M17Demodulator::stopBasebandSampling() void M17Demodulator::resetCorrelationStats() { conv_ema = 0.0f; - conv_emvar = 10000000000.0f; + conv_emvar = 1000000000.0f; } /** diff --git a/scripts/plot_m17_demod_csv.py b/scripts/plot_m17_demod_csv.py index 38fd376d..70448200 100755 --- a/scripts/plot_m17_demod_csv.py +++ b/scripts/plot_m17_demod_csv.py @@ -4,7 +4,7 @@ import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.autolayout"] = True -df = pd.read_csv("./build_linux/M17_clock_recovery_output_1.csv") +df = pd.read_csv("./build_linux/M17_demodulator_output_1.csv") print("Contents in csv file:\n", df) #plt.plot(df.index, df.Input) #plt.plot(df.index, df.RRCSignal) diff --git a/tests/unit/M17_demodulator.cpp b/tests/unit/M17_demodulator.cpp index 39c04de2..6ffacefd 100644 --- a/tests/unit/M17_demodulator.cpp +++ b/tests/unit/M17_demodulator.cpp @@ -75,7 +75,7 @@ int main() for(size_t i = 0; i < baseband_samples; i++) { float elem = static_cast< float >(baseband_buffer[i]); - filtered_buffer[i] = static_cast< int16_t >(M17::rrc(0.10 * elem)); + filtered_buffer[i] = static_cast< int16_t >(M17::rrc(elem)); } fwrite(filtered_buffer, baseband_samples, 2, baseband_out); fclose(baseband_out); @@ -89,7 +89,7 @@ int main() m17Demodulator.baseband = baseband; baseband.data = filtered_buffer; - FILE *output_csv_1 = fopen("M17_clock_recovery_output_1.csv", "w"); + FILE *output_csv_1 = fopen("M17_demodulator_output_1.csv", "w"); fprintf(output_csv_1, "Input,RRCSignal,LSFConvolution,FrameConvolution,Stddev\n"); // Test convolution m17Demodulator.resetCorrelationStats(); @@ -139,7 +139,7 @@ int main() } while (syncword.index != -1); fclose(syncword_ref); - FILE *output_csv_2 = fopen("M17_clock_recovery_output_2.csv", "w"); + FILE *output_csv_2 = fopen("M17_demodulator_output_2.csv", "w"); fprintf(output_csv_2, "RRCSignal,SyncDetect,QntMax,QntMin,Symbol\n"); uint32_t detect = 0, symbol = 0; offset = 0; diff --git a/tests/unit/assets/M17_test_baseband.raw b/tests/unit/assets/M17_test_baseband.raw index 751bd9fa..4f96e287 100644 Binary files a/tests/unit/assets/M17_test_baseband.raw and b/tests/unit/assets/M17_test_baseband.raw differ diff --git a/tests/unit/assets/M17_test_baseband_short.raw b/tests/unit/assets/M17_test_baseband_short.raw deleted file mode 100644 index b9d556a1..00000000 Binary files a/tests/unit/assets/M17_test_baseband_short.raw and /dev/null differ diff --git a/tests/unit/assets/M17_test_baseband_syncwords.txt b/tests/unit/assets/M17_test_baseband_syncwords.txt index 06f9c074..9a5b14fd 100644 --- a/tests/unit/assets/M17_test_baseband_syncwords.txt +++ b/tests/unit/assets/M17_test_baseband_syncwords.txt @@ -1,500 +1,2 @@ -1956 -3876 -5797 -7717 -9637 -10718 -11557 -13158 -13477 -15397 -17318 -19237 -21157 -23077 -24997 -26109 -26917 -28837 -29618 -30757 -32677 -34597 -36517 -37258 -38437 -40357 -42277 -44197 -46117 -48037 -49957 -51877 -53797 -55718 -57637 -59557 -61477 -63397 -65317 -67237 -69157 -71077 -72998 -74918 -76837 -78757 -80677 -82597 -84517 -86437 -88357 -90277 -92197 -94117 -96037 -97957 -99877 -101797 -103716 -105637 -106839 -107557 -109477 -111397 -113316 -115237 -117157 -119077 -120997 -122917 -124837 -126757 -127859 -128677 -130597 -132517 -134437 -136357 -138277 -140197 -142117 -144037 -145957 -147878 -149797 -151717 -153637 -155557 -157477 -159397 -160288 -161317 -163237 -165157 -167077 -168997 -170917 -172837 -174757 -176677 -178597 -180377 -180517 -182437 -184357 -186277 -188197 -190118 -191897 -192037 -193957 -195877 -197797 -199717 -201637 -203557 -205477 -207397 -209317 -211237 -213157 -215077 -216998 -218917 -220837 -222757 -224259 -224677 -226597 -228517 -230437 -232357 -234277 -236197 -238117 -240037 -241957 -243877 -245797 -247717 -249499 -249637 -251557 -253477 -255397 -257317 -259237 -261157 -263077 -264997 -266917 -268837 -270337 -270757 -272676 -274597 -276517 -278437 -280357 -282277 -284197 -286117 -288037 -289957 -291877 -292957 -293797 -295717 -297637 -299557 -301477 -303397 -305317 -306937 -307237 -309157 -311077 -312997 -314917 -316837 -318757 -320677 -322597 -324517 -326437 -328279 -328359 -330277 -332197 -334117 -336037 -337957 -339877 -341797 -343717 -344498 -345637 -347557 -349477 -351397 -353317 -355237 -357157 -359077 -360998 -362918 -364837 -366757 -368677 -370597 -372517 -374437 -376356 -378277 -380197 -382117 -384037 -385957 -387877 -389797 -391716 -393637 -395557 -397477 -399397 -401317 -403237 -405157 -407077 -407238 -408997 -410917 -412837 -414757 -416677 -418597 -420517 -422437 -424357 -426277 -428197 -430117 -432037 -433957 -435877 -437797 -439717 -441637 -443558 -445477 -447397 -449317 -451237 -453157 -455077 -456696 -456996 -458917 -460837 -462757 -464677 -466597 -468297 -468517 -470438 -472357 -474277 -476197 -478117 -480037 -481957 -483877 -485797 -487717 -489637 -491557 -493477 -495397 -497317 -499237 -501158 -503077 -504997 -506917 -508837 -510757 -512677 -514597 -516517 -518437 -520357 -522278 -524197 -526117 -527028 -528037 -529957 -531877 -533797 -535717 -537637 -539557 -541477 -543397 -545318 -547237 -549157 -551077 -552997 -554917 -556837 -558757 -560677 -562597 -564517 -566437 -568357 -570277 -572197 -574117 -576037 -577957 -579877 -581797 -583717 -585637 -587557 -589477 -591397 -593317 -595237 -597157 -599077 -600997 -602917 -604837 -606757 -608676 -610597 -612517 -614437 -616358 -618277 -620197 -622117 -624037 -625957 -627457 -627877 -629797 -631717 -633637 -635557 -637477 -639397 -639599 -641317 -643237 -645157 -647077 -648997 -650917 -652837 -654757 -656677 -658597 -660516 -662437 -664357 -666277 -668197 -670117 -672037 -673957 -675878 -677797 -679716 -681637 -683557 -685477 -687397 -689316 -691236 -693157 -695078 -696996 -698917 -700837 -702757 -704677 -706597 -708517 -708649 -709738 -710437 -712357 -714277 -716197 -718117 -720037 -721957 -723877 -725797 -727717 -729637 -731558 -733477 -735397 -737317 -739237 -741157 -743077 -744997 -746917 -748837 -750756 -752677 -754597 -756517 -758437 -760357 -762276 -764197 -766117 -768037 -769958 -771878 -773797 -775717 -777637 -779556 -781477 -783397 -785317 -787237 -789157 -791077 -792997 -794917 -796837 -798757 -800677 -802597 -804517 -806437 -808357 -810277 -812198 -814117 -816037 -817957 -819877 -821797 -823717 -825637 -827557 -829477 -831397 -833317 -835237 -837157 -838878 -839077 -840997 -842917 -844837 -846757 -848677 -850597 -852517 -854437 -856357 -858277 -860197 -862118 -864037 -865958 -867876 -869797 -871717 -873637 -875557 -877477 -879397 -881317 -883237 -885157 -887077 -888997 -890917 -892837 -894757 -896677 -898597 -900517 -902438 -904357 -905688 -906276 +1957 -1