FM的正交解调法
1.FM的模拟调制过程
FM信号是一种频率调制信号,其携带的信息保存在其信号的频率中,通过改变载波的频率来实现基带数据的传输。
其函数表达式如下:
\[s(t) = A*cos(w_c*t + K_f*\int m(\tau) d\tau)
\]
其中:
\(A\):表示载波幅度。
\(m(\tau)\):表示基带信号。
\(w_c\):表示载波信号角度增量。
\(K_f`\):是调频灵敏度。
正交调制法公式如下:
\[I(t) = cos(K_f*\int m(\tau) d\tau) \\
Q(t) = sin(K_f*\int m(\tau) d\tau) \\
s(t) = A*(I(t)*cos(w_c*t) - Q(t)*sin(w_c*t))
\]
2.FM的数字正交解调
原理:
对于I路,其中\(\varphi\)表示调制载波与解调载波的相位差:
\[\begin{array}{flalign}
I(n) & = LPF(s(n)*cos(w_c*n + \varphi)) \\
& = \frac{cos(K_f*\sum m(n))*cos(\varphi) + sin(K_f*\sum m(n))*sin(\varphi)}{2} \\
& = \frac{1}{2}*cos(K_f*\sum m(n) - \varphi)
\end{array}
\]
对于Q路:
\[\begin{array}{flalign}
Q(n) & = LPF(s(n)*sin(w_c*n + \varphi)) \\
& = \frac{cos(K_f*\sum m(n))*sin(\varphi) - sin(K_f*\sum m(n))*cos(\varphi)}{2} \\
& = \frac{1}{2}*sin(K_f*\sum m(n) - \varphi)
\end{array}
\]
同时:
\[\begin{array}{flalign}
&\ \frac{Q(n)}{I(n)} = \frac{sin(K_f*\sum m(n)- \varphi)}{cos(K_f*\sum m(n)- \varphi)} = tan(K_f*\sum m(n) - \varphi) \\
&\ SUM(n) = arctan(\frac{Q(n)}{I(n)}) = K_f*\sum m(n) - \varphi\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space\space
(\frac{Q(n)}{I(n)}) \in (-\pi/2\space\space\space\space\pi/2) \\
&\ M(n) = SUM(n) - SUM(n-1) = K_f* m(n) \\
\end{array}
\]
注:上式推算中使用了arctan
函数,其中arctan
的输入范围\((-\pi/2\space\space\space\space\pi/2)\)。当范围超过将计算错误。所以将使用MATLAB的atan2
函数进行计算。
\[\begin{array}{equation}
SUM(n) = atan2(Q(n),I(n)) = K_f*\sum m(n) - \varphi \\
M(n) = SUM(n) - SUM(n-1) = K_f* m(n)
\end{array}
\]
3.MATLAB仿真
仿真代码:
fs = 20000;%采样率
l = 1E3;%基带信号点数
f = 100;%基带信号
f_c = 2000;%载波信号
t = 0:1/fs:(l-1)/fs;
mt = cos(2*pi*f*t);
kf = fs * 0.4;
%% IQ信号
I = cos(kf*cumtrapz(t,mt));
Q = sin(kf*cumtrapz(t,mt));
%% 调制数据
mod_data = I.*cos(2*pi*f_c*t) - Q.*sin(2*pi*f_c*t);
%% 解调
mmm = atan2(Q,I);
demod = zeros(1,length(mmm));
for i = 2:1:length(demod)
demod(i) = mmm(i) - mmm(i-1);
if(demod(i) >= pi)
demod(i) = demod(i) - pi*2;
elseif(demod(i) <= -pi)
demod(i) = demod(i) + pi*2;
else
demod(i) = demod(i);
end
end
%% 保存IQ数据FPGA使用仿真
fid = fopen('FM.txt','w');
for i = 1:l
fprintf(fid,'%d %d\n',floor(I(i)* (2^13)),floor(Q(i)* (2^13)));
end
fclose(fid);
%% 绘制
figure
time = 3;
subplot(time,1,1);
plot(mt);
title('基带数据');
subplot(time,1,2);
plot(mod_data);
title('调制数据');
subplot(time,1,3);
plot(demod);
title('解调数据');
结果:
4.FPGA解调
逻辑代码:
module fm_demod(
input clk ,
input rst ,
//解调参数
input i_valid ,
input [15:0] i_data_i ,
input [15:0] i_data_q ,
output reg o_rdy ,
output reg [15:0] o_data
);
wire fm_valid ;
wire [23:0] fm_i ;
wire [23:0] fm_q ;
wire fm_rdy ;
wire [47 : 0] m_axis_dout_tdata ;
wire [15:0] fm_phase ;
//AM 解调
assign fm_valid = i_valid ;
assign fm_i = {{8{i_data_i[15]}},i_data_i} ;
assign fm_q = {{8{i_data_q[15]}},i_data_q} ;
cordic_translate cordic_translate (
.aclk (clk ), // input wire aclk
.s_axis_cartesian_tvalid (fm_valid ), // input wire s_axis_cartesian_tvalid
.s_axis_cartesian_tdata ({fm_i,fm_q} ), // input wire [47 : 0] s_axis_cartesian_tdata
.m_axis_dout_tvalid (fm_rdy ), // output wire m_axis_dout_tvalid
.m_axis_dout_tdata (m_axis_dout_tdata ) // output wire [47 : 0] m_axis_dout_tdata
);
reg [15:0] fm_phase_d;
assign fm_phase = m_axis_dout_tdata[24 +:16];
always @(posedge clk)begin
if(rst)begin
o_rdy <= 0;
o_data <= 0;
o_data <= 0;
end
else begin
o_rdy <= fm_rdy;
fm_phase_d <= fm_phase[15:0];
o_data <= fm_phase[15:0] - fm_phase_d;
end
end
endmodule
仿真代码:
module tb_fm_demod();
reg clk;
reg rst;
initial begin
clk <= 0;
rst <= 1;
#300
rst <= 0;
end
always #(100/2) clk <=~clk;
reg valid;
reg [15:0] din_i;
reg [15:0] din_q;
wire o_rdy ;
wire [15:0] o_data ;
fm_demod fm_demod(
.clk (clk),
.rst (rst),
.i_valid (valid),
.i_data_i (din_i),
.i_data_q (din_q),
.o_rdy (o_rdy ),
.o_data (o_data )
);
integer file_rd; //定义数据读指针
integer flag;
initial begin //打开读取和写入的文件,这里的路径要对
file_rd = $fopen("FM.txt","r");
end
reg [15:0] cnt;
always @(posedge clk)begin
if(rst)begin
din_i <= 0;
din_q <= 0;
cnt <= 0;
valid <= 0;
end
else if(cnt <= 1000)begin
valid <= 1;
flag = $fscanf(file_rd,"%d %d",din_i,din_q);
cnt <= cnt + 1;
end
else begin
$fclose(file_rd);
$stop();
end
end
endmodule
仿真结果: