diff --git a/gr-jay/lib/garage_impl.cc b/gr-jay/lib/garage_impl.cc index f105183..0a302de 100644 --- a/gr-jay/lib/garage_impl.cc +++ b/gr-jay/lib/garage_impl.cc @@ -105,7 +105,7 @@ void garage_impl::forecast (int noutput_items, gr_vector_int &ninput_items_requi int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - float rho = 1e-5; + float rho = 1e-4; const float *in = (const float *) input_items[0]; float *out = (float *) output_items[0]; int outCount = 0; @@ -142,6 +142,8 @@ 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); + // Detect bit change int bitChg = 0; if (m_bit == 1) @@ -161,21 +163,21 @@ int garage_impl::general_work (int noutput_items, gr_vector_int &ninput_items, g } } - bitProcessGap(bitChg); + bitProcessGap(bitChg && isSignal); // Calc error err = 0; - if (bitChg and (m_v_thr >= loopThreshold)) + if (bitChg && isSignal) { err = -(m_count - (int)(m_samplesPerSym/2)); } - + float vcorr = k_leadLag*k_lead*err + m_lag_accu; - + // Lag part of loop filter m_lag_accu += k_leadLag*k_lag*err; m_lag_accu *= (1.f - k_leak); - + m_baudRate = (float)m_sampleRate/((1+vcorr)*m_samplesPerSym); // Sample bit at baud rate = fs/numSamplesPerSym