1
0
Fork 0
mirror of https://github.com/hb9fxq/gr-digitalhf synced 2024-12-22 15:10:00 +00:00

use the amplitude from corr_est_cc to normalize samples

This commit is contained in:
Christoph Mayer 2019-09-24 13:29:20 +02:00
parent 4b0c109e9a
commit 48b1f4a669
2 changed files with 25 additions and 11 deletions

View file

@ -52,7 +52,9 @@ doppler_correction_cc_impl::doppler_correction_cc_impl(unsigned int preamble_len
, _state(WAIT_FOR_PHASE_EST_TAG) , _state(WAIT_FOR_PHASE_EST_TAG)
, _msg_metadata(pmt::make_dict()) , _msg_metadata(pmt::make_dict())
, _port_name(pmt::intern("doppler")) , _port_name(pmt::intern("doppler"))
, _phase_est(0) , _phase_est(0.0f)
, _amp_est_saved(1.0f)
, _amp_est(1.0f)
{ {
GR_LOG_DECLARE_LOGPTR(d_logger); GR_LOG_DECLARE_LOGPTR(d_logger);
GR_LOG_ASSIGN_LOGPTR(d_logger, "doppler_correction_cc"); GR_LOG_ASSIGN_LOGPTR(d_logger, "doppler_correction_cc");
@ -71,6 +73,7 @@ void
doppler_correction_cc_impl::handle_message(pmt::pmt_t msg) doppler_correction_cc_impl::handle_message(pmt::pmt_t msg)
{ {
gr::thread::scoped_lock lock(d_setlock); gr::thread::scoped_lock lock(d_setlock);
bool const success = pmt::to_bool(pmt::dict_ref(msg, pmt::intern("success"), pmt::get_PMT_F())); bool const success = pmt::to_bool(pmt::dict_ref(msg, pmt::intern("success"), pmt::get_PMT_F()));
if (!success) { if (!success) {
// GR_LOG_DEBUG(d_logger, "next state > CONSUME_AND_SKIP success=false"); // GR_LOG_DEBUG(d_logger, "next state > CONSUME_AND_SKIP success=false");
@ -78,6 +81,11 @@ doppler_correction_cc_impl::handle_message(pmt::pmt_t msg)
_state = CONSUME_AND_SKIP; _state = CONSUME_AND_SKIP;
return; return;
} }
bool const use_amp_est = pmt::to_bool(pmt::dict_ref(msg, pmt::intern("use_amp_est"), pmt::get_PMT_T()));
if (use_amp_est)
_amp_est = _amp_est_saved;
float const doppler = pmt::to_float(pmt::dict_ref(msg, pmt::intern("doppler"), pmt::from_float(0))); float const doppler = pmt::to_float(pmt::dict_ref(msg, pmt::intern("doppler"), pmt::from_float(0)));
_rotator.set_phase_incr(gr_expj(-doppler)); _rotator.set_phase_incr(gr_expj(-doppler));
if (_state == WAIT_FOR_MSG) { if (_state == WAIT_FOR_MSG) {
@ -112,15 +120,17 @@ doppler_correction_cc_impl::work(int noutput_items,
int nout = 0; int nout = 0;
switch (_state) { switch (_state) {
case WAIT_FOR_PHASE_EST_TAG: { case WAIT_FOR_PHASE_EST_TAG: {
std::vector<tag_t> v; std::vector<tag_t> v_phase, v_amp;
get_tags_in_window(v, 0, 0, noutput_items, pmt::intern("phase_est")); get_tags_in_window(v_phase, 0, 0, noutput_items, pmt::intern("phase_est"));
if (v.empty()) { get_tags_in_window(v_amp, 0, 0, noutput_items, pmt::intern("amp_est"));
if (v_phase.empty()) {
nout = noutput_items; nout = noutput_items;
} else { } else {
tag_t const& tag = v.front(); tag_t const& tag_phase = v_phase.front();
uint64_t const offset = tag.offset - nitems_read(0); tag_t const& tag_amp = v_amp.front();
nout = offset; uint64_t const offset = nout = tag_phase.offset - nitems_read(0);
_phase_est = pmt::to_double(tag.value); _phase_est = pmt::to_double(tag_phase.value);
_amp_est_saved = pmt::to_double(tag_amp.value);
_msg_metadata = pmt::dict_add(_msg_metadata, pmt::intern("packet_len"), pmt::from_long(_preamble_length)); _msg_metadata = pmt::dict_add(_msg_metadata, pmt::intern("packet_len"), pmt::from_long(_preamble_length));
message_port_pub(_port_name, message_port_pub(_port_name,
pmt::cons(_msg_metadata, pmt::cons(_msg_metadata,
@ -156,6 +166,9 @@ doppler_correction_cc_impl::work(int noutput_items,
for (int i=0; i<nout; ++i) for (int i=0; i<nout; ++i)
out[i] = _rotator.rotate(in[i]); out[i] = _rotator.rotate(in[i]);
#endif #endif
volk_32f_s32f_multiply_32f(reinterpret_cast<float*>(out),
reinterpret_cast<float const*>(out),
_amp_est, 2*nout);
// Tell runtime system how many output items we produced. // Tell runtime system how many output items we produced.
return nout; return nout;
} }

View file

@ -43,8 +43,9 @@ private:
pmt::pmt_t _msg_metadata; pmt::pmt_t _msg_metadata;
pmt::pmt_t _port_name; pmt::pmt_t _port_name;
float _phase_est; float _phase_est; // phase from correlation
float _amp_est_saved; // new amplitude correction
float _amp_est; // currenlty applied amplitude correction
public: public:
doppler_correction_cc_impl(unsigned int preamble_length, unsigned int preamble_length_cc); doppler_correction_cc_impl(unsigned int preamble_length, unsigned int preamble_length_cc);
virtual ~doppler_correction_cc_impl(); virtual ~doppler_correction_cc_impl();