提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
USRP具有宽带信号接收的能力。USRP-B210的可接收频段为70MHz-6GHz,涵盖了绝大部分民用通信信号的频段,本文展示了使用USRP-B210对GSM,LTE,WIFI信号的宽带采集与存储,并使用Python 进行了信号展示。
系统环境为Ubantu 20.04 + GNU Radio 3.8
一、信号采集原理
信号采集的原理为在指定频段接收一段时间的信号,随后对信号进行FFT变换,转换为多个频点的幅频特性。随后对FFT结果取模值,作为信号强度写入文件中进行存储。
二、GNU Radio 实现
采集的实现方法为使用gr_modtool 自建模块实现,模块名称为spmea_ave。该模块的操作为,每隔一段时间进行一小段时间的采样,进行fft运算。根据设置的采样间隔,将若干次的测量结果进行平均后作为每一次采样的结果。信号的流图如图所示。
图中spmea_ave为信号采集模块,可设置的参数有:fft长度,存储文件路径,采样率,载频,开始测量信号,采样率。信号采集系统界面如下图
点击开始即可开始测试,界面中可以设置采样的频带,采样率,fft点数。
三、测量结果
1 GSM900 UPLINK
2 GSM1800 UPLINK
3 LTE
4 WIFI 2.4G
5 测量数据(rawdata)
四、部分测量代码
spmea_ave_impl.cc 中的接收信号处理
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "spmea_ave_impl.h"
int
spmea_ave_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
// Do <+signal processing+>
for(int i = 0; i < noutput_items; i++){
if(running){
//when the system is running
if(~d_stop&&d_stop_old){ // stop pushbutton signal
else{
if(waiting == 0){
if(sig_idx>=d_frouier_len){
//fft operation and store
// doing FFT
if(ave_idx>=d_ave_num){
for (int jj=0; jj<freq_num;jj++){
// average the fft result
}
ave_idx = 0;
for (int ii=0;ii<freq_num;ii++){
// write to file
}
outFile<<std::endl;
// if(!(measure_times%(d_mea_rate)||(measure_times%(d_ave_num)))){
std::cout<<"The"<<int(measure_times/d_ave_num)<<" time measurement writen"<<std::endl;//}
memset(tmp_fftamp, 0, sizeof(float)*freq_num);
}
else{
for (int jj=0; jj<freq_num;jj++){
// add the result
}
ave_idx = ave_idx+1;
}
measure_times=measure_times+1;
// if((measure_times%d_mea_rate)==0){std::cout<<"The"<<int(measure_times/d_mea_rate/d_ave_num)<<" time measurement times completed"<<std::endl;}
waiting=1;
sig_idx=0;
}
else{
// store the signal
}
}
else{
if(wait_idx>=wait_num){
waiting=0;
wait_idx=0;
}
else{
wait_idx=wait_idx+1;
}
}
// run fft and store the spectrum power
}
}
else if(~d_start&&d_start_old){ // start pushbutton signal
running=1;
std::cout<<"Start running"<<endl;
if(initial_state)
{
write thr initial information
}
std::cout<<"Frequency information writen finished"<<std::endl;
outFile<<std::endl;
}
else{
outFile.open(file1, ios::app);
outFile<<std::endl;
std::cout<<"File reopened"<<std::endl;
}
//when the system is not running and the start button is pushed
}
else{
//when the system is not working and waiting for controlling signals
}
d_start_old=d_start;
d_stop_old=d_stop;
}
// Tell runtime system how many output items we produced.
return noutput_items;
}
void spmea_ave_impl::kfft(float *pr,float *pi,int n,int k,float *fr,float *fi)
// FFT function
{
return;
}
} /* namespace SP_MEA */
} /* namespace gr */