- added signal detection

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@380 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-01-03 19:34:23 +00:00
parent b7d75bc171
commit a9b715d31a
2 changed files with 35 additions and 17 deletions
+20 -4
View File
@@ -52,6 +52,8 @@ garage_impl::garage_impl(int sampleRate, int samplesPerSym, float kLoopFilter, f
, m_kThreshold(kThreshold) , m_kThreshold(kThreshold)
, m_vmin(0) , m_vmin(0)
, m_vmax(0) , m_vmax(0)
, m_v_sig(0)
, m_v_sig_m(0.5f)
, m_v_thr(0) , m_v_thr(0)
, m_lag_accu(0) , m_lag_accu(0)
, m_bit(0) , m_bit(0)
@@ -122,6 +124,9 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g
float k_leak = 0; float k_leak = 0;
float err = 0; float err = 0;
float alpha_sig = 0.5f/m_samplesPerSym;
float alpha_sig_m = alpha_sig/5;
int i_i = 0; int i_i = 0;
while ((i_i+1) < ninput_items[0]) while ((i_i+1) < ninput_items[0])
{ {
@@ -142,10 +147,17 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g
m_vmin = m_vmin + rho*(m_v_thr - m_vmin); m_vmin = m_vmin + rho*(m_v_thr - m_vmin);
m_vmax = m_vmax + rho*(m_v_thr - m_vmax); m_vmax = m_vmax + rho*(m_v_thr - m_vmax);
bool isSignal = (m_v_thr >= loopThreshold); // Signal detection
float y_nodc = (y-m_v_thr);
m_v_sig = (1.f-alpha_sig)*m_v_sig + alpha_sig*y_nodc*y_nodc;
m_v_sig_m = (1.f-alpha_sig_m)*m_v_sig_m + alpha_sig_m*y;
bool isSignal = m_v_sig >= loopThreshold;
int bitChg = 0;
if (isSignal)
{
// Detect bit change // Detect bit change
int bitChg = 0;
if (m_bit == 1) if (m_bit == 1)
{ {
if (y < (hyst_thr*m_v_thr)) if (y < (hyst_thr*m_v_thr))
@@ -162,12 +174,13 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g
bitChg = 1; bitChg = 1;
} }
} }
}
bitProcessGap(bitChg && isSignal); bitProcessGap(bitChg);
// Calc error // Calc error
err = 0; err = 0;
if (bitChg && isSignal) if (bitChg)
{ {
err = -(m_count - (int)(m_samplesPerSym/2)); err = -(m_count - (int)(m_samplesPerSym/2));
} }
@@ -185,12 +198,15 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g
{ {
out[outCount++] = (float)m_bit; out[outCount++] = (float)m_bit;
m_count = countReload; m_count = countReload;
if (isSignal)
{
bitRecord(m_bit); bitRecord(m_bit);
if (m_pFile_bits) if (m_pFile_bits)
{ {
fprintf(m_pFile_bits, "%f %f\n", (float)m_sampleCounter/m_sampleRate, y); fprintf(m_pFile_bits, "%f %f\n", (float)m_sampleCounter/m_sampleRate, y);
} }
} }
}
else else
{ {
m_count--; m_count--;
+2
View File
@@ -39,6 +39,8 @@ class garage_impl : public garage
float m_kThreshold; float m_kThreshold;
float m_vmin; float m_vmin;
float m_vmax; float m_vmax;
float m_v_sig;
float m_v_sig_m;
float m_v_thr; float m_v_thr;
float m_lag_accu; float m_lag_accu;
int m_bit; int m_bit;