简体   繁体   English

以特定频率,SDR和FFT获取功率

[英]Getting power at a particular frequency, SDR and FFT

I am trying to get the power at a particular frequency, with an RTL-SDR. 我正在尝试使用RTL-SDR获得特定频率的功率。 I'm adapting FFT examples I've found online. 我正在改编我在网上找到的FFT示例。 Abbreviated code here (removed superfluous stuff): 此处的缩写代码(删除了多余的内容):

import matplotlib.mlab as mlab
import rtlsdr

NFFT=1024

dwell = 0.016
sample_rate = 2.4e6
offset = 200e3
freq = 100e6

sdr = rtlsdr.RtlSdr(0)
sdr.set_sample_rate(sample_rate)
sdr.set_manual_gain_enabled(1)
sdr.set_gain(22.9)
sdr.freq_correction = 0

numsamples = next_2_to_pow(int(dwell * sample_rate))

freq = freq - offset  # avoid dc spike
sdr.set_center_freq(freq)
samples = sdr.read_samples(numsamples)

powers, freqs = mlab.psd(samples, NFFT=NFFT, Fs=sample_rate/1e6, window=hamming(NFFT))

bin_offset = int(offset / (sample_rate / NFFT))
freq = int(freq + offset)
pwr = float( "{:.2f}".format(10 * math.log10( powers[ int(len(powers)/2) + bin_offset ] )) )

This simply doesn't work. 这根本行不通。 The power at the frequency stays about the same (noise floor level), even when I inject a signal. 即使当我注入信号时,该频率下的功率也保持不变(本底噪声水平)。

I have two theories about why this doesn't work. 关于这为什么行不通,我有两种理论。 1) RTL-SDRs return I/Q data, and this method doesn't account for that (?) 2) My understanding of the FFT is simply not sound enough to perform it right. 1)RTL-SDR返回I / Q数据,而这种方法不能解决这个问题(?)2)我对FFT的理解根本不足以正确执行它。

Which is it? 哪有 How can I fix it? 我该如何解决?

Have you tried using rtl_power then just picking the right bin in the output? 您是否尝试过使用rtl_power然后仅在输出中选择正确的bin? It's a relatively recent addition to the rtl_sdr suite. 这是rtl_sdr套件的相对较新的功能。 In C, not Python. 在C中,不是Python。 https://github.com/osmocom/rtl-sdr https://github.com/osmocom/rtl-sdr

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM