1. GSR-ISAC界面介绍
发射端IQ
接收端IQ
接收端ofdm
matlab ofdm参数
Carriers、iFFT length可以理解为数据长度
prefixRatio理解为CP(Cyclic Prefix)长度
MCS为QAM调制阶数
2.labview自定义波形
%Nc 发射通道数,例如有2台USRP,每台USRP 2个发射通道,Nc = 4
%N 采样点数,即UI上的Number of Samples
%Fs 采样率,即UI上的Sample Rate
%定义Sig_out,二维复数数组
Sig_out = [0+0j,0+0j;0+0j,0+0j];
Ng=Nfft/Prefix; %length of CP 4096/(1/4)=16384 =1024
Nps=4; %Pilot Spacing
Np=floor(Carriers/Nps); %Number of pilots per OFDM symbol 3276/4=819
% 16 - QAM - Modulation Scheme
Es=1;
A=sqrt(3/2/(M-1)*Es); % Signal energy and QAM normalization factor 0.1
Xpi = 2*(randn(1,Np)>0)-1; % Pilot sequence generation 生成1,-1 的值 实部
Xpq = 2*(randn(1,Np)>0)-1; % Pilot sequence generation 生成1,-1 的值 虚部
Xp = Xpi+1i*Xpq; %组成复数信号
%msgint = randint(1,Nfft-Np,M);
msgint = randint(1,Carriers-Np,M); % 3276-819=2457 16 生成1行2457列的[1,16]
dat_ser = A*qam(msgint,M); %进行QAM调制
% serial to parllel conversion 转置
dat_par=dat_ser.';
% Pilot Insertion - Comb Type Arrangement
j = 1;
k = 1;
loc = [];
for i=1:Nfft %for循环 1:Nfft
if or((i<=round(Carriers/2)),(i> Nfft-round(Carriers/2))) %or(A,B) 表示 A 和 B 中有一个为真时,返回真。
if (mod(i,Nps)==1) %返回 除以 Nps 后的余数 %导频?
X(i) = Xp(k); %复数信号的第k个值给X(i)
loc=[loc i]; %loc数组合并
k=k+1; %+1
else
X(i) = dat_par(j); %赋值
j=j+1; %+1
end
else
X(i)=0+0i;
end
end
% inverse discret Fourier transform (IFFT)
X_ifft=ifft(X,Nfft); %X为原始信号,Nfft为采样点数
% Adding Cyclic Prefix - Guard interval
guard=X_ifft(:,end-Ng+1:end); % this is the Cyclic Prefix part to be appended.
ofdm=[guard X_ifft];
Sig_out = repmat(ofdm,Nc,1);
N_act = length(ofdm);
%Np Number of pilots per OFDM symbol
z = y
% FFT
Y = fft(y);
%LS Estimator with Linear Interpolator
k=1:Np;
LS_est(k) = Y(loc(k))./Xp(k);% LS channel estimation
H_LS = interpolate1d(loc,LS_est,1:Nfft,'spline');
x_rec=Y./H_LS;
x_rec(Carriers/2+1:Nfft-Carriers/2+1)=zeros(1,Nfft-Carriers+1)';
x_res = [];
c = 1;
for i=1:Nfft
if or((i<=round(Carriers/2)),(i> Nfft-round(Carriers/2))) % 【i<1638】 or 【i>2458】 0-1638 1638-2458 2458-4096
if mod(i,Nps) ~=1
x_res = [x_res x_rec(i)]; %调制信号
c=c+1; %2457个
end
end
end
x_demod = qamdemod(x_res./A,M);
3.matlab代码
%Nc 发射通道数,例如有2台USRP,每台USRP 2个发射通道,Nc = 4
%N 采样点数,即UI上的Number of Samples
%Fs 采样率,即UI上的Sample Rate
clc;clear;
%function[Sig_out,X,N_act,Xp,loc,Np,Carriers,Ng,Nfft]=ofmd_gen()
Nc = 1;
N = 8192;
Fs = 122880000;
Carriers = uint32(8192);
NSym = 1;
M = 64;
Prefix = 4; %labview中是1/4
Beta = 32; %labview中是1/32
Nfft = 8192;
%Nfft = 32;
%定义Sig_out,二维复数数组
Sig_out = [0+0j,0+0j;0+0j,0+0j];
Ng=Nfft/Prefix; %length of CP 4096/(1/4)=1024
Nps=4; %Pilot Spacing
Np=uint32(floor(Carriers/Nps)); %Number of pilots per OFDM symbol 3276/4=819
% 16 - QAM - Modulation Scheme
Es=1;
A=sqrt(3/2/(M-1)*Es); % Signal energy and QAM normalization factor 0.1
Xpi = 2*(randn(1,Np)>0)-1; % Pilot sequence generation 生成1,-1 的值 819个 做导频
Xpq = 2*(randn(1,Np)>0)-1; % Pilot sequence generation 生成1,-1 的值
Xp = Xpi+1i*Xpq; %组成复数信号 做导频
%msgint = randint(1,Nfft-Np,M);
msgint = randi(M,1,Carriers-Np)-1; % 3276-819=2457 发送的原始数据!!!! 生成1行2457列的[0,63] -1的目的是0,M-1
figure,plot(msgint);
title('xmod')
dat_ser = A*qammod(msgint,M); %进行QAM调制 M是字母表大小,必须是2的整数幂,表示调制阶数。消息信号X必须由0到M-1之间的整数组成。X可以是标量、矢量、矩阵或三维数组。
%figure,feather(dat_ser);
%title("dat_ser");
%disp(dat_ser);
% serial to parllel conversion 转置
dat_par=dat_ser.';
% Pilot Insertion - Comb Type Arrangement 在已调信号频谱中零点插入导频
j = 1;
k = 1;
t = 1;
loc = [];
for i=1:Nfft
if or((i<=round(Carriers/2)),(i> Nfft-round(Carriers/2))) % 【i<1638】 or 【i>2458】 0-1638 1638-2458 2458-4096
if mod(i,Nps)==1 % i 除以 Nps 后的余数
X(i) = Xp(k); %导频 Xp为819个
loc=[loc i];
k=k+1; %819个
else
X(i) = dat_par(j); %调制信号
j=j+1; %2457个
end
else
X(i)=0+0i;
t = t+1; %820个
end
end
%figure,feather(X);
%title("发送");
% inverse discret Fourier transform (IFFT)
X_ifft=ifft(X,Nfft); %对X进行IFFT变成Sig_out
% Adding Cyclic Prefix - Guard interval
guard=X_ifft(:,end-Ng+1:end); % this is the Cyclic Prefix part to be appended.
ofdm=[guard X_ifft];
%disp(ofdm);
Sig_out = repmat(ofdm,Nc,NSym);
figure,feather(Sig_out); %feather() 使用 Sig_out 指定的复数值绘制箭头,实部表示 x 分量,虚部表示 y 分量。
title("Sigout");
re = real(Sig_out);
im = imag(Sig_out);
%figure,plot(re);
%title("I路");
%figure,plot(im);
%title("Q路");
N_act = length(ofdm);
%%
% Arguments:
% shape : dimension of the channel matrix, e.g., [5,1].
% d : distance [m].
% fc : center frequency [GHz].
% K_dB : rician factor [dB].
% Returns:
% H : channel coefficient.
%{
shape = [1,Carriers+Ng]; % 第一个维度是发射机的天线数量,第二个维度是接收机的天线数量
d = 0.0000000009; %接收机和 发射机之间的距离
fc = 3.5 *1e9; % 2.4G Hz 中央频点自定义
K_dB = 3;
H_simulate = 4*gen_channel_coef(shape, d, fc, K_dB); % 这个H 就是信道系数
Sig_out = H_simulate.*Sig_out;
%}
%%
%收到Sig_out
Sig_in = Sig_out(:,Ng+1:Nfft+Ng); % 去掉CP 1024长度
% FFT
Y = fft(Sig_in); %对Sig_out进行FFT 变成了“X”、
%LS Estimator with Linear Interpolator 带线性插值器的LS估计器
k=1:Np; %1~819
%Y =[-0.393945+0.578717i,0.264238-0.515818i]; %4步一个
%Xp = [1+1i,-1-1i];
%loc = [1,5] %每次+4
% LS_est(k) = [0.0924+0.4863i,0.1258+0.3900i] %也是4步一个
LS_est(k) = Y(loc(k))./Xp(k);% LS channel estimation %导频??? %loc(k)为导频在Y中的位置 Y为接收信号的导频 Xp为真实导频
%H_LS = interpolate1d(loc,LS_est,1:Nfft,'spline');
%根据导频信号,估计出 其他的所有信号??? loc为导频横坐标(1,4096),LS_est为导频的纵坐标(复数), 要估计出其他的所有值!!!
H_LS = interp1(loc,LS_est,1:Nfft,'spline'); % Nfft=4096 yi=interp1(x,y,xi,method) x、y为已知的对应数据;xi为想要插值数据点的横坐标,返回对应的纵坐标yi
%Y=Hx+n n忽略,这个H就是信道系数!!
x_rec=Y./H_LS; %因为估算出H_LS,而H_LS可以看成拓展的LS即包含数据部分的LS(Xp可以看成X) 所以x_rec = Y/H_LS【依据先导信号同比例】
x_rec(Carriers/2+1:Nfft-Carriers/2+1)=zeros(1,Nfft-Carriers+1)'; % X(i)=0+0i; 变为0
%figure,feather(x_rec);
%title("接收");
x_res = [];
c = 1;
for i=1:Nfft
if or((i<=round(Carriers/2)),(i> Nfft-round(Carriers/2))) % 【i<1638】 or 【i>2458】 0-1638 1638-2458 2458-4096
if mod(i,Nps) ~=1
x_res = [x_res x_rec(i)]; %调制信号
c=c+1; %2457个
end
end
end
x_demod = qamdemod(x_res./A,M);
figure,plot(x_demod);
title("xdemod");
4.传输测试
matlab传输波形
IFFT前与FFT数据处理
调制解调(原始)数据处理
压力测试
理论每秒最高可传输5w字节