SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
symsync.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // Symbol synchronizer or symbol clock recovery mostly encapsulating //
5 // liquid-dsp's symsync "object" //
6 // //
7 // This program is free software; you can redistribute it and/or modify //
8 // it under the terms of the GNU General Public License as published by //
9 // the Free Software Foundation as version 3 of the License, or //
10 // (at your option) any later version. //
11 // //
12 // This program is distributed in the hope that it will be useful, //
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15 // GNU General Public License V3 for more details. //
16 // //
17 // You should have received a copy of the GNU General Public License //
18 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
20 
21 #include "symsync.h"
22 
24 {
25  // For now use hardcoded values:
26  // - RRC filter
27  // - 4 samples per symbol
28  // - 5 symbols delay filter
29  // - 0.5 filter excess bandwidth factor
30  // - 32 filter elements for the internal polyphase filter
31  m_sync = symsync_crcf_create_rnyquist(LIQUID_FIRFILT_RRC, 4, 5, 0.5f, 32);
32  // - 0.02 loop filter bandwidth factor
33  symsync_crcf_set_lf_bw(m_sync, 0.01f);
34  // - 4 samples per symbol output rate
35  symsync_crcf_set_output_rate(m_sync, 4);
37 }
38 
40 {
41  symsync_crcf_destroy(m_sync);
42 }
43 
45 {
46  unsigned int nn;
47  Real v = -1.0f;
48  liquid_float_complex y = (s.m_real / SDR_RX_SCALEF) + (s.m_imag / SDR_RX_SCALEF)*I;
49  symsync_crcf_execute(m_sync, &y, 1, m_z, &nn);
50 
51  for (unsigned int i = 0; i < nn; i++)
52  {
53  if (nn != 1) {
54  qDebug("SymbolSynchronizer::run: %u", nn);
55  }
56 
57  if (m_syncSampleCount % 4 == 0) {
58  v = 1.0f;
59  }
60 
61  if (m_syncSampleCount < 4095) {
63  } else {
64  qDebug("SymbolSynchronizer::run: tau: %f", symsync_crcf_get_tau(m_sync));
66  }
67  }
68 
69  return v;
70 }
71 
72 liquid_float_complex SymbolSynchronizer::runZ(const Sample& s)
73 {
74  unsigned int nn;
75  liquid_float_complex y = (s.m_real / SDR_RX_SCALEF) + (s.m_imag / SDR_RX_SCALEF)*I;
76  symsync_crcf_execute(m_sync, &y, 1, m_z, &nn);
77 
78  for (unsigned int i = 0; i < nn; i++)
79  {
80  if (nn != 1) {
81  qDebug("SymbolSynchronizer::run: %u", nn);
82  }
83 
84  if (m_syncSampleCount == 0) {
85  m_z0 = m_z[i];
86  }
87 
88  if (m_syncSampleCount < 3) {
90  } else {
92  }
93  }
94 
95  return m_z0;
96 }
liquid_float_complex runZ(const Sample &s)
Definition: symsync.cpp:72
liquid_float_complex m_z[4+4]
Definition: symsync.h:36
#define SDR_RX_SCALEF
Definition: dsptypes.h:33
FixReal m_real
Definition: dsptypes.h:64
int32_t i
Definition: decimators.h:244
int m_syncSampleCount
Definition: symsync.h:38
symsync_crcf m_sync
Definition: symsync.h:35
Real run(const Sample &s)
Definition: symsync.cpp:44
liquid_float_complex m_z0
Definition: symsync.h:37
FixReal m_imag
Definition: dsptypes.h:65
float Real
Definition: dsptypes.h:42