From 551eac3140ab33bf0235014f2627208bc38338e0 Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sat, 14 Oct 2017 12:18:43 -0300 Subject: [PATCH] TX filter coefficients for 48 kHz --- DMRDMOTX.cpp | 14 ++++++++++---- DMRTX.cpp | 14 ++++++++++---- DStarTX.cpp | 8 +++++--- DStarTX.h | 2 +- IO.cpp | 2 +- P25TX.cpp | 14 +++++++++----- YSFTX.cpp | 14 ++++++++++---- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/DMRDMOTX.cpp b/DMRDMOTX.cpp index a0b9bef..9e10c0a 100644 --- a/DMRDMOTX.cpp +++ b/DMRDMOTX.cpp @@ -22,10 +22,16 @@ #include "Globals.h" #include "DMRSlotType.h" -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 850, 219, -720, -1548, -1795, -1172, 237, 1927, 3120, 3073, 1447, -1431, -4544, -6442, - -5735, -1633, 5651, 14822, 23810, 30367, 32767, 30367, 23810, 14822, 5651, -1633, -5735, -6442, - -4544, -1431, 1447, 3073, 3120, 1927, 237, -1172, -1795, -1548, -720, 219, 850}; // numTaps = 45, L = 5 +// Generated using rcosdesign(0.2, 8, 10, 'sqrt') in MATLAB +static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 850, 592, 219, -234, -720, -1179, + -1548, -1769, -1795, -1597, -1172, -544, 237, 1092, 1927, 2637, + 3120, 3286, 3073, 2454, 1447, 116, -1431, -3043, -4544, -5739, + -6442, -6483, -5735, -4121, -1633, 1669, 5651, 10118, 14822, + 19484, 23810, 27520, 30367, 32156, 32767, 32156, 30367, 27520, + 23810, 19484, 14822, 10118, 5651, 1669, -1633, -4121, -5735, + -6483, -6442, -5739, -4544, -3043, -1431, 116, 1447, 2454, + 3073, 3286, 3120, 2637, 1927, 1092, 237, -544, -1172, -1597, + -1795, -1769, -1548, -1179, -720, -234, 219, 592, 850}; // numTaps = 90, L = 10 const uint16_t RRC_0_2_FILTER_PHASE_LEN = 9U; // phaseLength = numTaps/L const q15_t DMR_LEVELA = 1362; diff --git a/DMRTX.cpp b/DMRTX.cpp index 0c5d055..81e106a 100644 --- a/DMRTX.cpp +++ b/DMRTX.cpp @@ -22,10 +22,16 @@ #include "Globals.h" #include "DMRSlotType.h" -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 850, 219, -720, -1548, -1795, -1172, 237, 1927, 3120, 3073, 1447, -1431, -4544, -6442, - -5735, -1633, 5651, 14822, 23810, 30367, 32767, 30367, 23810, 14822, 5651, -1633, -5735, -6442, - -4544, -1431, 1447, 3073, 3120, 1927, 237, -1172, -1795, -1548, -720, 219, 850}; // numTaps = 45, L = 5 +// Generated using rcosdesign(0.2, 8, 10, 'sqrt') in MATLAB +static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 850, 592, 219, -234, -720, -1179, + -1548, -1769, -1795, -1597, -1172, -544, 237, 1092, 1927, 2637, + 3120, 3286, 3073, 2454, 1447, 116, -1431, -3043, -4544, -5739, + -6442, -6483, -5735, -4121, -1633, 1669, 5651, 10118, 14822, + 19484, 23810, 27520, 30367, 32156, 32767, 32156, 30367, 27520, + 23810, 19484, 14822, 10118, 5651, 1669, -1633, -4121, -5735, + -6483, -6442, -5739, -4544, -3043, -1431, 116, 1447, 2454, + 3073, 3286, 3120, 2637, 1927, 1092, 237, -544, -1172, -1597, + -1795, -1769, -1548, -1179, -720, -234, 219, 592, 850}; // numTaps = 90, L = 10 const uint16_t RRC_0_2_FILTER_PHASE_LEN = 9U; // phaseLength = numTaps/L const q15_t DMR_LEVELA = 1362; diff --git a/DStarTX.cpp b/DStarTX.cpp index e2b3eb1..8447923 100644 --- a/DStarTX.cpp +++ b/DStarTX.cpp @@ -27,8 +27,10 @@ const uint8_t BIT_SYNC = 0xAAU; const uint8_t FRAME_SYNC[] = {0xEAU, 0xA6U, 0x00U}; -// Generated using gaussfir(0.35, 1, 5) in MATLAB -static q15_t GAUSSIAN_0_35_FILTER[] = {0, 0, 0, 0, 1001, 3514, 9333, 18751, 28499, 32767, 28499, 18751, 9333, 3514, 1001}; // numTaps = 15, L = 5 +// Generated using gaussfir(0.35, 1, 10) in MATLAB +static q15_t GAUSSIAN_0_35_FILTER[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1001, 1942, 3514, 5930, + 9333, 13699, 18751, 23938, 28499, 31644, 32767, 31644, + 28499, 23938, 18751, 13699, 9333, 5930, 3514, 1942, 1001}; // numTaps = 30, L = 10 const uint16_t GAUSSIAN_0_35_FILTER_PHASE_LEN = 3U; // phaseLength = numTaps/L const q15_t DSTAR_LEVEL0 = -841; @@ -196,7 +198,7 @@ m_poLen(0U), m_poPtr(0U), m_txDelay(60U) // 100ms { - ::memset(m_modState, 0x00U, 20U * sizeof(q15_t)); + ::memset(m_modState, 0x00U, 15U * sizeof(q15_t)); m_modFilter.L = DSTAR_RADIO_SYMBOL_LENGTH; m_modFilter.phaseLength = GAUSSIAN_0_35_FILTER_PHASE_LEN; diff --git a/DStarTX.h b/DStarTX.h index 24876d7..0424761 100644 --- a/DStarTX.h +++ b/DStarTX.h @@ -40,7 +40,7 @@ public: private: CSerialRB m_buffer; arm_fir_interpolate_instance_q15 m_modFilter; - q15_t m_modState[20U]; // blockSize + phaseLength - 1, 8 + 9 - 1 plus some spare + q15_t m_modState[15U]; // blockSize + phaseLength - 1, 8 + 3 - 1 plus some spare uint8_t m_poBuffer[600U]; uint16_t m_poLen; uint16_t m_poPtr; diff --git a/IO.cpp b/IO.cpp index ae18e90..474d5eb 100644 --- a/IO.cpp +++ b/IO.cpp @@ -23,7 +23,7 @@ #include "IO.h" // Generated using [b, a] = butter(1, 0.001) in MATLAB -static q31_t DC_FILTER[] = {3367972, 0, 3367972, 0, 2140747704, 0}; // {b0, 0, b1, b2, -a1, -a2} +static q31_t DC_FILTER[] = {1685306, 0, 1685306, 0, 2144113034, 0}; // {b0, 0, b1, b2, -a1, -a2} const uint32_t DC_FILTER_STAGES = 1U; // One Biquad stage // One symbol boxcar filter diff --git a/P25TX.cpp b/P25TX.cpp index 2901a74..9c70e11 100644 --- a/P25TX.cpp +++ b/P25TX.cpp @@ -23,11 +23,15 @@ #include "P25Defines.h" -// Generated using rcosdesign(0.2, 8, 5, 'normal') in MATLAB -// numTaps = 40, L = 5 -static q15_t RC_0_2_FILTER[] = {-897, -1636, -1840, -1278, 0, 1613, 2936, 3310, 2315, 0, -3011, -5627, -6580, -4839, - 0, 7482, 16311, 24651, 30607, 32767, 30607, 24651, 16311, 7482, 0, -4839, -6580, -5627, - -3011, 0, 2315, 3310, 2936, 1613, 0, -1278, -1840, -1636, -897, 0}; // numTaps = 40, L = 5 +// Generated using rcosdesign(0.2, 8, 10, 'normal') in MATLAB +static q15_t RC_0_2_FILTER[] = {-444, -897, -1311, -1636, -1825, -1840, -1659, -1278, -712, 0, + 800, 1613, 2354, 2936, 3277, 3310, 2994, 2315, 1296, 0, -1478, + -3011, -4448, -5627, -6386, -6580, -6090, -4839, -2800, 0, 3474, + 7482, 11835, 16311, 20666, 24651, 28032, 30607, 32219, 32767, + 32219, 30607, 28032, 24651, 20666, 16311, 11835, 7482, 3474, 0, + -2800, -4839, -6090, -6580, -6386, -5627, -4448, -3011, -1478, + 0, 1296, 2315, 2994, 3310, 3277, 2936, 2354, 1613, 800, 0, -712, + -1278, -1659, -1840, -1825, -1636, -1311, -897, -444, 0}; // numTaps = 80, L = 10 const uint16_t RC_0_2_FILTER_PHASE_LEN = 8U; // phaseLength = numTaps/L // Generated in MATLAB using the following commands, and then normalised for unity gain diff --git a/YSFTX.cpp b/YSFTX.cpp index c0361c6..9df4a02 100644 --- a/YSFTX.cpp +++ b/YSFTX.cpp @@ -23,10 +23,16 @@ #include "YSFDefines.h" -// Generated using rcosdesign(0.2, 8, 5, 'sqrt') in MATLAB -static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 850, 219, -720, -1548, -1795, -1172, 237, 1927, 3120, 3073, 1447, -1431, -4544, -6442, - -5735, -1633, 5651, 14822, 23810, 30367, 32767, 30367, 23810, 14822, 5651, -1633, -5735, -6442, - -4544, -1431, 1447, 3073, 3120, 1927, 237, -1172, -1795, -1548, -720, 219, 850}; // numTaps = 45, L = 5 +// Generated using rcosdesign(0.2, 8, 10, 'sqrt') in MATLAB +static q15_t RRC_0_2_FILTER[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 850, 592, 219, -234, -720, -1179, + -1548, -1769, -1795, -1597, -1172, -544, 237, 1092, 1927, 2637, + 3120, 3286, 3073, 2454, 1447, 116, -1431, -3043, -4544, -5739, + -6442, -6483, -5735, -4121, -1633, 1669, 5651, 10118, 14822, + 19484, 23810, 27520, 30367, 32156, 32767, 32156, 30367, 27520, + 23810, 19484, 14822, 10118, 5651, 1669, -1633, -4121, -5735, + -6483, -6442, -5739, -4544, -3043, -1431, 116, 1447, 2454, + 3073, 3286, 3120, 2637, 1927, 1092, 237, -544, -1172, -1597, + -1795, -1769, -1548, -1179, -720, -234, 219, 592, 850}; // numTaps = 90, L = 10 const uint16_t RRC_0_2_FILTER_PHASE_LEN = 9U; // phaseLength = numTaps/L const q15_t YSF_LEVELA_HI = 1893;