FPGA配合R820T

想法:FPGA控制R820T的I2C,将R820T输出的中频做处理。

准备:某宝买的RTL-SDR,原理如下:

软件无线电通过数字信号处理来实现无线信号的调制解调。在RTL-SDR中通过调谐芯片(R820T、E4000)将无线信号下变频至低中频信号,由RTL2832U中的ADC采样得到数字信号,再进行数字下变频得到基带信号,由USB传送给计算机。RTL-SDR得到的基带信号是I/Q信号交错排列的形式,计算机对基带信号进行分离得到两路信号即I/Q信号进行解调。

硬件原理图大致如下图所示:

把RTL2832U取下来,将SDA、SCL、IF_P、IF_N引出,

R820T结构图

因为配置R820T的比较复杂,使用zynq+axi-iic方式完成R820T的控制,资源够的话,例化Microblaze也是可以的。

这里提供R820T的手册下载百度云盘链接

链接:https://pan.baidu.com/s/1BWMHACYQsdAqvp5c7cLlGw 
提取码:5aci 

R820T中比较重要的寄存器:

  1. /* Those initial values start from REG_SHADOW_START */
  2. static const uint8_t r82xx_init_array[NUM_REGS] = {
  3. 0x83, 0x32, 0x75, /* 05 to 07 */
  4. 0xc0, 0x40, 0xd6, 0x6c, /* 08 to 0b */
  5. 0xf5, 0x63, 0x75, 0x68, /* 0c to 0f */
  6. 0x6c, 0x83, 0x80, 0x00, /* 10 to 13 */
  7. 0x0f, 0x00, 0xc0, 0x30, /* 14 to 17 */
  8. 0x48, 0xcc, 0x60, 0x00, /* 18 to 1b */
  9. 0x54, 0xae, 0x4a, 0xc0 /* 1c to 1f */
  10. };
  11. ------------R5=0x83---------------
  12. [7]Loop through ON/OFF = off
  13. [5]LNA 1 power control = on
  14. [4]LNA gain mode switch = on
  15. [3:0]LNA manual gain control = 0011
  16. ------------R6=0x32--------------
  17. [7]Power detector 1 on/off = on
  18. [6]Power detector 3 on/off = off
  19. [5]Filter gain 3db = +3db
  20. [2:0]LNA power control = 010
  21. ------------R7=0x75---------------
  22. [6]Mixer power = on
  23. [5]Mixer current control = normal current
  24. [4]Mixer gain mode = auto mode
  25. [3:0]Mixer manual gain control = 0101
  26. ------------R8=0xc0---------------
  27. [7]Mixer buffer power on/off = on
  28. [6]Mixer buffer current setting = low current
  29. [5:0]Image Gain Adjustment = 0
  30. ------------R9=0x40----------------
  31. [7]IF Filter power on/off = filter on
  32. [6]IF Filter current = low current
  33. [5:0]Image Phase Adjustment = 0
  34. ------------R10=0xd6--------------
  35. [7]Filter power on/off = on
  36. [6:5]Filter power control = 10
  37. [4] 1
  38. [3:0]Filter bandwidth manual fine tune = 0110
  39. ------------R11=0x6c----------------
  40. [7] 0
  41. [6:5]Filter bandwidth manual course tunnel = middle
  42. [4] 0
  43. [3:0]High pass filter corner control = 1100
  44. ------------R12=0xf5-------------
  45. [6]VGA power control = vga power on
  46. [4]VGA GAIN manual / pin selector = IF vga gain controlled by vagc pin
  47. [3:0]IF vga manual gain control = 0101
  48. ------------R13=0x63--------------
  49. [7:4]LNA agc power detector voltage threshold high setting = 0110
  50. [3:0]LNA agc power detector voltage threshold low setting = 0011
  51. ------------R14=0x75--------------
  52. [7:4]MIXER agc power detector voltage threshold high setting = 0111
  53. [3:0]MIXER agc power detector voltage threshold low setting = 0110
  54. ------------R15=0x68---------------
  55. [4]Clock out pin control = clk output on
  56. [1]AGC clk control = internal agc clock on
  57. ------------R16=0x6c----------------
  58. [7:5]PLL to Mixer divider number control = mixer in = vco out
  59. [4]PLL Reference frequency Divider = fref=xtal_freq
  60. [1:0]Internal xtal cap setting = no cap
  61. ------------R17=0x83--------------
  62. [7:6]PLL analog low drop out regulator switch = 2.0V
  63. ------------R18=0x80---------------
  64. [7:6]PLL integer divider number input Si2c = 10
  65. [5:0]PLL integer divider number input Ni2c = 0
  66. --------------------------------------
  67. ------------R30=0x4a------------------
  68. [5:0]Power detector timing control = 001010
  69. [6]Filter extension under weak signal = Enable

R820T和RTL2382U驱动可以在这里下载:https://github.com/osmocom/rtl-sdr.git:  Software to turn the RTL2832U into a SDR receiver
控制R820T只需要其中的tuner_r82xx.c、tuner_r82xx.h、librtlsdr.c、librtlsdr.h、rtl-sdr.h,略加修改删除其中的配置RTL2832U部分;

示波器采集到R820T I通道输出

FFT波形:

因为没有较好的模数转换器,使用LVDS 1-bit采样法,采集R820T I通道输出,FPGA采集到波形:

在Matlab上做算法验证:

  1. clear
  2. clc
  3. f1=1*1000; %信号频率为1KHz
  4. f2=10*1000*1000; %信号频率为10MHz
  5. Fs=240*1000*1000; %采样频率为200MHz
  6. C=3; %滤波器级数
  7. %%%%%%%%%%%%%%%%%%FM调制%%%%%%%%%%%%%%%%%%%%%
  8. % Fs = 240*10^6; % 240M采样率
  9. am = 255; % 设定调制信号幅度
  10. % f1 = 10*10^3; % 调制信号频率10K
  11. % f0 = 10*10^6; % 载波频率10M
  12. dt = 1/Fs; % 采样间隔
  13. t=0:dt:f2/Fs;
  14. N=length(t);
  15. mt = am*sin(2*pi*f1*t); % 生成调制信号 10K
  16. ct = cos(2*pi*f2*t); % 生成载波 10M
  17. kf = 10; % 调频系数 频偏75kHz
  18. figure(3);
  19. subplot(411);plot(mt);title('Matlab仿真滤波前信号波形');
  20. integral_mt(1)=0;
  21. for i=1:length(t)-1 %积分
  22. integral_mt(i+1)=integral_mt(i)+mt(i)*dt;
  23. end
  24. %figure(100);plot(t,integral_mt); title('integral_mt');
  25. sfm = cos(2*pi*f2*t+2*pi*kf*integral_mt); %已调信号
  26. for i=1:length(sfm)
  27. if(sfm(i)>0)
  28. sfm(i) = 1;
  29. else
  30. sfm(i) = -1;
  31. end
  32. end
  33. figure(3);
  34. subplot(412);plot(sfm);title('Matlab仿真滤波前信号波形');
  35. st=sin(2*pi*f2*t); %提取载波的正交分量 sin(wc*t)
  36. ct=cos(2*pi*f2*t); %cos(wc*t)
  37. for i=1:length(sfm)
  38. If(i)=sfm(i)*ct(i);
  39. Qf(i)=sfm(i)*st(i);
  40. end
  41. figure(1);
  42. subplot(211);plot(If); title("If");
  43. subplot(212);plot(Qf); title("Qf");
  44. % Flp=f2;
  45. % b=fir1(200,Flp/Fs,'low'); %设计滤波器
  46. % Im=filter(b,1,If);
  47. % Qm=filter(b,1,Qf);
  48. % figure(2);
  49. % subplot(321);plot(Im); title("Im");
  50. % subplot(322);plot(Qm); title("Qm");
  51. If1=cic1(5, If);
  52. Qf1=cic1(5, Qf);
  53. figure(2);
  54. subplot(323);plot(If1(1:length(Qf1)-3)); title("If1");
  55. subplot(324);plot(Qf1(1:length(Qf1)-3)); title("Qf1");
  56. If2=cic1(50, If1(1:length(If1)-3));
  57. Qf2=cic1(50, Qf1(1:length(Qf1)-3));
  58. figure(2);
  59. subplot(325);plot(If2(1:length(If2)-3)); title("If2");
  60. subplot(326);plot(Qf2(1:length(Qf2)-3)); title("Qf2");
  61. %%%%%%%%%%%%%进行16bit量化%%%%%%%%%%%%%%%%%
  62. If16=round(If2/max(abs(If2(1:length(If2)-3)))*(2^15-1));
  63. Qf16=round(Qf2/max(abs(Qf2(1:length(Qf2)-3)))*(2^15-1));
  64. %求系数绝对值之和,以此估计滤波后的有效数据位宽
  65. % sum_Shape=sum(abs(Qf16));
  66. %%%%%%%%%%%%%%%%%%%解调%%%%%%%%%%%%%%%%%%%
  67. Sn(1)=0;
  68. for i=2:length(If16)
  69. Sn(i) =-(Qf16(i)*If16(i-1)-Qf16(i-1)*If16(i));
  70. end
  71. Sn=Sn/max(abs(Sn));
  72. Sn1=cic1(50, Sn);
  73. figure(3);
  74. subplot(413);
  75. plot(Sn1(10:length(Sn1)-3));title('解调信号波形');

将Matlab调制后波形输出到FPGA仿真模型中,使用modelsim仿真波形,经过1bit采样、正交解调和3级CIC滤波后的波形总是杂乱无章,反复修改参数,关键在于CIC滤波抽取间隔值不能太大,目前大约在5~10之间。

目前没有DA模块,在FPGA综合实现后,无法验证输出是否正确,故暂停。

posted @ 2023-07-21 09:09  SymPny  阅读(77)  评论(0编辑  收藏  举报