- 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:
+33
-17
@@ -52,6 +52,8 @@ garage_impl::garage_impl(int sampleRate, int samplesPerSym, float kLoopFilter, f
|
||||
, m_kThreshold(kThreshold)
|
||||
, m_vmin(0)
|
||||
, m_vmax(0)
|
||||
, m_v_sig(0)
|
||||
, m_v_sig_m(0.5f)
|
||||
, m_v_thr(0)
|
||||
, m_lag_accu(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 err = 0;
|
||||
|
||||
float alpha_sig = 0.5f/m_samplesPerSym;
|
||||
float alpha_sig_m = alpha_sig/5;
|
||||
|
||||
int i_i = 0;
|
||||
while ((i_i+1) < ninput_items[0])
|
||||
{
|
||||
@@ -142,32 +147,40 @@ 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_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;
|
||||
|
||||
// Detect bit change
|
||||
int bitChg = 0;
|
||||
if (m_bit == 1)
|
||||
if (isSignal)
|
||||
{
|
||||
if (y < (hyst_thr*m_v_thr))
|
||||
|
||||
// Detect bit change
|
||||
if (m_bit == 1)
|
||||
{
|
||||
m_bit = 0;
|
||||
bitChg = 1;
|
||||
if (y < (hyst_thr*m_v_thr))
|
||||
{
|
||||
m_bit = 0;
|
||||
bitChg = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y > (hyst_thr*m_v_thr))
|
||||
else
|
||||
{
|
||||
m_bit = 1;
|
||||
bitChg = 1;
|
||||
if (y > (hyst_thr*m_v_thr))
|
||||
{
|
||||
m_bit = 1;
|
||||
bitChg = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitProcessGap(bitChg && isSignal);
|
||||
bitProcessGap(bitChg);
|
||||
|
||||
// Calc error
|
||||
err = 0;
|
||||
if (bitChg && isSignal)
|
||||
if (bitChg)
|
||||
{
|
||||
err = -(m_count - (int)(m_samplesPerSym/2));
|
||||
}
|
||||
@@ -185,10 +198,13 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g
|
||||
{
|
||||
out[outCount++] = (float)m_bit;
|
||||
m_count = countReload;
|
||||
bitRecord(m_bit);
|
||||
if (m_pFile_bits)
|
||||
if (isSignal)
|
||||
{
|
||||
fprintf(m_pFile_bits, "%f %f\n", (float)m_sampleCounter/m_sampleRate, y);
|
||||
bitRecord(m_bit);
|
||||
if (m_pFile_bits)
|
||||
{
|
||||
fprintf(m_pFile_bits, "%f %f\n", (float)m_sampleCounter/m_sampleRate, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -39,6 +39,8 @@ class garage_impl : public garage
|
||||
float m_kThreshold;
|
||||
float m_vmin;
|
||||
float m_vmax;
|
||||
float m_v_sig;
|
||||
float m_v_sig_m;
|
||||
float m_v_thr;
|
||||
float m_lag_accu;
|
||||
int m_bit;
|
||||
|
||||
Reference in New Issue
Block a user