f4exb / sdrangel

SDR Rx/Tx software for Airspy, Airspy HF+, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay and FunCube
GNU General Public License v3.0
2.91k stars 441 forks source link

Spectrum measurements inconsistent in Broadcast FM Demod plugin #2282

Open rapgenic opened 6 days ago

rapgenic commented 6 days ago

Hi,

I am using my PlutoSDR to do some qualitative measurements on my FM transmitter. I am having it generate a 10KHz modulated FM signal, receiving it with my SDR and demodulating it with the SDRAngel Broadcast FM Demod plugin.

I am interested in a few measurements provided by the spectrum analyser, which are, the peaks and the SNR.

The SNR measurement produces totally nonsense results, but does not provide any marker inside the spectrum, so I'm not reporting it yet because it is not easy to show you.

However when visualizing peaks it is clear that there is some kind of problem. In the following image I have reported the peak measurement for both the RF and baseband spectra, clearly showing that in the BB spectrum all peaks seem to be detected on the same fundamental tone, despite all the peaks being clearly "visible".

image

I do not think I am doing something wrong, I have tried multiple spectrum parameters (i.e. averaging and FFT resolution) but I suspect they are not relevant

srcejon commented 5 days ago

You have an 8k FFT - but the image is only 700 pixels wide. I'd guess if you zoom in you'll see multiple peaks.

rapgenic commented 5 days ago

image image image

Here are the zoomed in version of the fundamental tone, at 8k and 32k ffts, and also at 1k... I believe those are single peaks, is there some other way to check whether I'm wrong?

srcejon commented 5 days ago

Try saving the spectrum data to .csv then look at the actual values.

In the last image, look at peak 15 - it may be it is fractionally higher than the point to it's left, but not a real peak. If that is the case, then perhaps we need some parameter that specifies a minimum height, in order to filter out things like that.

rapgenic commented 5 days ago

Thanks for the suggestion! I have plotted the result for the 32k FFT around the 10Khz tone. The procedure for acquiring this data was:

  1. Run acquisition
  2. Adjust all parameters (i.e. zoom, fft size, etc)
  3. Stop the acquisition
  4. Take a screenshot of the BB spectrum
  5. Save the CSV spectrum content and plot the 10KHz peak

image image

Here I can see a few interesting things:

srcejon commented 5 days ago

Maybe the peak finder algorithm considers a equal value as non decreasing, thus a possible peak

Yep, it does, in GLSpectrumView::peakWidth. If you are compiling SDRangel yourself, you can try changing:

while ((left > maxLeft) && (spectrum[left] < prevLeft) && (right < maxRight) && (spectrum[right] < prevRight))

To:

while ((left > maxLeft) && (spectrum[left] <= prevLeft) && (right < maxRight) && (spectrum[right] <= prevRight))

Also looking at the CSV ALL values seem to be duplicated, not just ones around the peaks, is this something to be expected as normal?

It looks like that's because it's a single-side-band spectrum.

The peaks frequencies seem different from the CSV data, it seems that it's taking the middle point between two samples as the peak frequency

Probably a difference in labeling: i.e. one is bin start frequency, whereas the other is the bin centre frequency.

rapgenic commented 5 days ago

Hi, I finally managed to test a build with your suggested change and it actually works!

image

SNR measurement is working great as well!

image

I have seen that the measurement is performed only on the current span of the spectrum. Do you know if there is an easy way to set the span/center frequency without necessarily using the scroll wheel?

srcejon commented 5 days ago

Do you know if there is an easy way to set the span/center frequency without necessarily using the scroll wheel?

I don't think there is currently.

rapgenic commented 5 days ago

I understand.

Thank you very much for your support!

If It's ok I'd like to open a PR with this fix, unless there are any side effects that I can't think of.

srcejon commented 3 days ago

If It's ok I'd like to open a PR with this fix, unless there are any side effects that I can't think of.

It should be OK - the alternative is that SSBs are handled separately.