discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MPSK SNR Estimation block shifts input by one


From: Martin Luelf
Subject: MPSK SNR Estimation block shifts input by one
Date: Tue, 24 Mar 2020 10:33:59 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Hi everybody,

I stumbled over a strange behavior while writing unittests for a frame synchronization block.

The MPSK SNR Estimation block from GNURadio will output a complex zero sample before outputting the (shifted by one) input samples.

To show this problem I use a Vector source with a sequence of BPSK symbols and connect this source to a vector sink and the MPSK SNR estimation block. The SNR estimation block is connected to a second sink (the python script for this is attached at the bottom of this email). After the flowgraph completes I print out the input data and the data collected by the two sinks and it looks like this:

Original input data:............. ((1+0j), (-1+0j), (1+0j), (1+0j))
Data from source (SNR Est input): ((1+0j), (-1+0j), (1+0j), (1+0j))
Data from SNR Est:............... (0j, (1+0j), (-1+0j), (1+0j))

Note that the data from the SNR estimator has an additional 0j at the front before the input sequence and the last symbol from the input data is dropped.

However looking at the source code of the SNR Estimation block the first line of the work function (https://github.com/gnuradio/gnuradio/blob/351a22cc0e2fc05f4ca6ccb08de6ca1e83b62a70/gr-digital/lib/mpsk_snr_est_cc_impl.cc#L77) reads:

memcpy(output_items[0], input_items[0], noutput_items * sizeof(gr_complex));

which looks perfectly correct to me. So what is happening here? Am I missing something? I tried searching the mailing list for shifted samples but the results all resolve around actually wanting to shift samples around.

Any help/hint would be greatly appreciated.

Yours
Martin



Example code to reproduce the problem (tested on maint-3.7 branch currently at commit 351a22cc0e2fc05f4ca6ccb08de6ca1e83b62a70):

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

from gnuradio import blocks
from gnuradio import digital
from gnuradio import gr

tb = gr.top_block("Test MPSK SNR Estimation")

##################################################
# Variables
##################################################
data_in = (1.0+0j, -1.0+0j, 1.0+0j, 1.0+0j)

##################################################
# Blocks
##################################################
blocks_vector_source = blocks.vector_source_c(data_in, False, 1, [])
digital_mpsk_snr_est_cc = digital.mpsk_snr_est_cc(0, 10000, 0.001)
blocks_vector_sink1 = blocks.vector_sink_c(1, 1024)
blocks_vector_sink2 = blocks.vector_sink_c(1, 1024)

##################################################
# Connections
##################################################

# Source -> Sink 1
tb.connect((blocks_vector_source, 0), (blocks_vector_sink1, 0))

# Source -> MPSK SNR Est -> Sink 2
tb.connect((blocks_vector_source, 0), (digital_mpsk_snr_est_cc, 0))
tb.connect((digital_mpsk_snr_est_cc, 0), (blocks_vector_sink2, 0))

tb.run()

print('Original input data:............. {}'.format(data_in))
print('Data from source (SNR Est input): {}'.format(blocks_vector_sink1.data())) print('Data from SNR Est:............... {}'.format(blocks_vector_sink2.data()))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]