使用 GNU Radio Signal Probe 和这个自定义代码,我是否遗漏了任何样本?如果是这样,什么是更好的方法?
Using a GNU Radio Signal Probe and this custom code, am I missing any samples? If so, what would be a better approach?
我正在尝试测量发送由跳频无线电控制器传输的单个数据包所花费的时间长度。为此,我将仅包含一个信号的 wav 文件提供给信号探测器。在 main() 方法中,我设置了一些代码,调用 some_probe.level() 来测量振幅,如果它超过阈值,那么你就有了一个信号。理论上听起来不错,但我有理由相信这种方法行不通。
我首先关心的是 FCC 测试报告文件,我对它的解释可能正确也可能不正确。在描述控制器在跳跃之前停留在频道上多长时间的部分中,有一个 table 记录停留时间和脉冲时间。驻留时间为 68.80 毫秒,脉冲长度为 1.72 毫秒。对我来说,这意味着单个信号应该是 ~1.72 毫秒,并且这个信号之前和之后的时间总计为 ~68.80 毫秒。
除此之外,我还使用了两个不同的程序来直观地估计信号时间。如果我在 Audacity 中打开 wav 文件并尽可能放大以获得开始和结束时间,我得到平均 0.87 毫秒。但是,如果我使用 QT GUI Time Sink 并暂停它(我认为这更准确),我得到的更像是 1.50 毫秒。这与 FCC 测试报告更匹配,但即使它们略有不同,这两个程序都会给我一致的数字。
关键是,我有三个不同的消息来源告诉我信号时间范围为 0.87 毫秒 - 1.72 毫秒,我的视觉估计给出了一致的相似数字。我的脚本存在的问题是它给我的结果超出了这个范围并且输出总是变化的,即使它在完全相同的 wav 文件上 运行 也是如此。如果它工作正常,我希望得到与我的其他来源相似的数字,以及与之前输出相似的数字。真的,如果程序在相同的输入上运行,它应该有相同的输出。
tl;dr
我认为问题在于信号探测器正在读取 wav 文件源的输出,就好像它是实时发生的一样。因此,当我的代码在测量振幅后执行操作时,wav 文件源仍在输出样本,即使我没有测量它们。我想我需要的是某种缓冲区来存储所有样本并一次处理一个样本,但我不能确定,而且我不知道哪些块可能具有该功能。
下面是我的注释代码。我会post一张图的图片,但是我的声望太低了。它只包含一个连接到信号探测器的 wav 文件源和一个 qt gui 时间接收器。
我也试过一个类似的版本,在另一个线程上运行它,结果相似。
def main(top_block_cls=pulse_analysis_code, options=None):
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
#tb.show()
#Initializes variables
pulse_time = 0
pulse_start = 0
pulse_end = 0
#Indicates whether there is currently a pulse or not
#Assume that the file does not start at the beginning of a pulse
pulse_present = False
#Background noise ranges from -0.0387 at the highest and -0.0471 at the lowest (Found this by zooming into the QT Time Sink).
#This means we'll call anything above the high and below the low a part of a pulse.
noise_high = -0.0387
noise_low = -0.0471
while True:
#Record amplitude and the time it is measured
amplitude = tb.blocks_probe_signal_x_0.level()
time_of_measurement = time.time()
#If the amplitude is above or below the noise level, and was previously not, then we have found the
#beginning of a pulse.
if (amplitude > noise_high or amplitude < noise_low ) and (not pulse_present):
#Save the start time
pulse_start = time_of_measurement
#Indicate that a pulse has begun
pulse_present = True
#If the amplitude is not above the noise level, but previously was, then we have found the ending
#of a pulse.
elif(amplitude < noise_high and amplitude > noise_low ) and pulse_present:
pulse_end = time_of_measurement
#Add the time from start to end to total pulse time
pulse_time = pulse_time + (pulse_end - pulse_start)
pulse_present = False
#Print total pulse time as it grows
print '{:17.6f}'.format(pulse_time)
def quitting():
tb.stop()
tb.wait()
qapp.aboutToQuit.connect(quitting)
qapp.exec_()
信号探头只是一个测试离合器。
您想做的是编写或使用 GNU Radio 信号处理块 ("blocks") 来分析和处理您的数据。
我正在尝试测量发送由跳频无线电控制器传输的单个数据包所花费的时间长度。为此,我将仅包含一个信号的 wav 文件提供给信号探测器。在 main() 方法中,我设置了一些代码,调用 some_probe.level() 来测量振幅,如果它超过阈值,那么你就有了一个信号。理论上听起来不错,但我有理由相信这种方法行不通。
我首先关心的是 FCC 测试报告文件,我对它的解释可能正确也可能不正确。在描述控制器在跳跃之前停留在频道上多长时间的部分中,有一个 table 记录停留时间和脉冲时间。驻留时间为 68.80 毫秒,脉冲长度为 1.72 毫秒。对我来说,这意味着单个信号应该是 ~1.72 毫秒,并且这个信号之前和之后的时间总计为 ~68.80 毫秒。
除此之外,我还使用了两个不同的程序来直观地估计信号时间。如果我在 Audacity 中打开 wav 文件并尽可能放大以获得开始和结束时间,我得到平均 0.87 毫秒。但是,如果我使用 QT GUI Time Sink 并暂停它(我认为这更准确),我得到的更像是 1.50 毫秒。这与 FCC 测试报告更匹配,但即使它们略有不同,这两个程序都会给我一致的数字。
关键是,我有三个不同的消息来源告诉我信号时间范围为 0.87 毫秒 - 1.72 毫秒,我的视觉估计给出了一致的相似数字。我的脚本存在的问题是它给我的结果超出了这个范围并且输出总是变化的,即使它在完全相同的 wav 文件上 运行 也是如此。如果它工作正常,我希望得到与我的其他来源相似的数字,以及与之前输出相似的数字。真的,如果程序在相同的输入上运行,它应该有相同的输出。
tl;dr
我认为问题在于信号探测器正在读取 wav 文件源的输出,就好像它是实时发生的一样。因此,当我的代码在测量振幅后执行操作时,wav 文件源仍在输出样本,即使我没有测量它们。我想我需要的是某种缓冲区来存储所有样本并一次处理一个样本,但我不能确定,而且我不知道哪些块可能具有该功能。
下面是我的注释代码。我会post一张图的图片,但是我的声望太低了。它只包含一个连接到信号探测器的 wav 文件源和一个 qt gui 时间接收器。
我也试过一个类似的版本,在另一个线程上运行它,结果相似。
def main(top_block_cls=pulse_analysis_code, options=None):
qapp = Qt.QApplication(sys.argv)
tb = top_block_cls()
tb.start()
#tb.show()
#Initializes variables
pulse_time = 0
pulse_start = 0
pulse_end = 0
#Indicates whether there is currently a pulse or not
#Assume that the file does not start at the beginning of a pulse
pulse_present = False
#Background noise ranges from -0.0387 at the highest and -0.0471 at the lowest (Found this by zooming into the QT Time Sink).
#This means we'll call anything above the high and below the low a part of a pulse.
noise_high = -0.0387
noise_low = -0.0471
while True:
#Record amplitude and the time it is measured
amplitude = tb.blocks_probe_signal_x_0.level()
time_of_measurement = time.time()
#If the amplitude is above or below the noise level, and was previously not, then we have found the
#beginning of a pulse.
if (amplitude > noise_high or amplitude < noise_low ) and (not pulse_present):
#Save the start time
pulse_start = time_of_measurement
#Indicate that a pulse has begun
pulse_present = True
#If the amplitude is not above the noise level, but previously was, then we have found the ending
#of a pulse.
elif(amplitude < noise_high and amplitude > noise_low ) and pulse_present:
pulse_end = time_of_measurement
#Add the time from start to end to total pulse time
pulse_time = pulse_time + (pulse_end - pulse_start)
pulse_present = False
#Print total pulse time as it grows
print '{:17.6f}'.format(pulse_time)
def quitting():
tb.stop()
tb.wait()
qapp.aboutToQuit.connect(quitting)
qapp.exec_()
信号探头只是一个测试离合器。
您想做的是编写或使用 GNU Radio 信号处理块 ("blocks") 来分析和处理您的数据。