gnuradio中把file_sink的二进制文件转换成文本文件

http://www.swigerco.com/gnuradio/plotting.html

Plotting Signals



Here are a few simple utilities to convert raw datafiles into a format you can read and plot w/ gnuplot.

raw2num.c - converts a file of 16 bit shorts into a numerical human readable file with an index. Used for files created with

   gr.file_sink (gr.sizeof_short, "datafile")

Usage $./raw2num <input_file> <output_file> <offset> <number_of_numbers> 

raw2num_f.c - converts a file of 4-byte floating point numbers into a numerical form with an index. 

raw2num_fc.c - converts a file of 4-byte float complex pairs into numerical form. 

sign2unsigned.c - converts a signed short file, numbers in the range of -32768 to +32767, to unsigned 0-65535, with the former 0 at 32768+bias. For example, my ADC creates numbers from 0-4095 with signal zero at 2048. When I create a signal file with gnuradio I can convert from it's signed format to unsigned with the 0 level at 2048.




New: To view complex data in 3D form try 'splot' in gnuplot. 

gnuplot>set xrange[0:50]
gnuplot>splot "complex_mag_num"

Then click and drag to rotate and look at the corkscrew from different angles. 

<img src="http://www.swigerco.com/gnuradio/3d_plot.jpg"




Usage - start gnuplot. At the gnuplot> prompt type

gnuplot>plot "file"

will display the converted short or float file. Change the x-axis range with

gnuplot>set xrange [0:512]
gnuplot>plot "file"

For example, to use gnuplot like an oscilloscope for dial_tone.py, a version which adds both 350 & 440 hz into one channel
Briefly run $./dial_tone_2.py and hit enter to stop it. There will be a data file "dial_tone.dat" of float data. Convert to numerical with 

$./raw2num_f dial_tone.dat dial_tone.num 0 65536

then display with gnuplot. 

$gnuplot
gnuplot>plot "dial_tone.num"

and get a display like this:



Finally focus on a small area of the waveform with

gnuplot>set xrange [0:2000]
gnuplot>plot "dial_tone.num"

and get a plot like this:






For complex float output your have to run gnuplot with 'using'. For example, this program creates a complex signal

Run this briefly and get a complex float data file dial_tone_c.dat. Convert to numerical with

$./raw2num_fc dial_tone_c.dat dial_tone_c.num 0 65536 

Then plot with 

$gnuplot
gnuplot>set xrange [0:1000]
gnuplot>plot "dial_tone_c.num" using 1:2, "dial_tone_c.num" using 1:3 

That creates one plot using columns 1 and 2, the imaginary part of the complex signal, and another plot using columns 1 and 3, the real part, so you get a plot like this: 

 

Notice the 90 degree phase shift between the real and imaginary plots. Change the frequencies to negative in the above script, repeat and notice the change in phase to this


  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用Vivado HLS(高层次综合)工具可以将GNU Radio模块转换为硬件描述语言(HDL)代码。下面是一个大致的步骤: 1. 准备工作:首先,确保已经安装了Vivado HLS工具和GNU Radio开发环境。你可以从Xilinx官方网站下载和安装Vivado开发套件,并按照GNU Radio的安装指南设置开发环境。 2. 选择模块:选择要转换为硬件的GNU Radio模块。这可以是整个信号处理流图,也可以是其的一个子模块。根据需要和资源限制,选择合适的模块进行转换。 3. 配置和接口:使用Vivado HLS工具,配置HLS项目并定义模块的接口。这包括输入和输出端口的数据类型、数据宽度等。 4. 代码转换:根据GNU Radio模块的功能和需求,使用C或C++编写HLS代码。你可以使用GNU Radio提供的标准库函数和API来实现相应的信号处理功能。 5. 进行综合:使用Vivado HLS工具对HLS代码进行综合。这将生成逻辑电路的结构描述,也就是HDL代码。 6. 实现和烧录:将生成的HDL代码集成到FPGA项目,并使用Vivado开发套件对项目进行实现和烧录。这将生成比特流文件,可以加载到FPGA上运行。 需要注意的是,将GNU Radio转换为HDL代码是一个复杂的过程,需要一定的硬件设计和编程知识。你可能需要参考Vivado HLS的文档和GNU Radio的相关资源,如官方文档和用户论坛,以获取更详细的指导和帮助。此外,转换的结果可能需要进行性能优化和调整,以满足资源和时序要求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值