1.软件版本
matlab2013b
2.本算法理论知识
RFID的接口过程满足如下的结构框图:
3.核心代码
clc; %清屏
close all; %关闭所有窗口
clear all; %清除所有变量
warning off;
addpath 'func\'
%%
%参数定义
%信息码长度
SNR = [10:1:17];
TDL = [500,400,300,200,100,50,20,10];
ERR = zeros(1,length(SNR));
for jj = 1:length(SNR)
jj
Num = 0;
Ber = 0;
while Ber <= TDL(jj);
Num = Num + 1;
Ber
Frame_length = 10*64;
%信息码速率为10KHz
Rates = 10e3;
%发送带宽20KHz
Bwidth = 2*Rates;
%发送信号功率2W
Tpower = 2;
%载波频率70MHz
fc = 70e6;
%采样频率280MHz,满足四倍采样
fs = fc*4;
%20KHz方波
Swave1 = 20e3;
%40KHz方波
Swave2 = 40e3;
%采样点数
M = fs/(2*Swave2);
%信息码采样点
L = fs/Rates;
%2ASK调制的调制度
ma = 0.5;
%alpha值
alpha = 2*ma/(1-ma);
%%
%随机信息码产生
data_code0 = zeros(1,Frame_length);
%随机产生信息码
data_code0 =(randn(1,Frame_length)>=0.5);
%%
%CRC校验
data_code = func_CRC(data_code0);
%%
%数据采样化
data_code_sample = func_samples(data_code,Frame_length,L);
%%
%编码
data_code_sample = func_encode(data_code_sample,data_code,Frame_length,L,M);
%%
%调制发送
%FIR低通滤波器设计
data_sample_fir = func_filter(data_code_sample,fs,fc);
T = Frame_length*L*(1/fs);
t = [0:1/fs:T-(1/fs)];
Carriers = cos(2*pi*fc*t);
%ASK调制
RFID_ASK =((2*Tpower).^0.5)*(1+alpha*data_sample_fir).*Carriers;
%ASK调制信号加正弦波干扰
RFID_ASK_sin = RFID_ASK + 10*cos(2*pi*fc*t+pi/6);
%高斯信道
snr = SNR(jj);
RFID_ASK_sin_N = awgn(RFID_ASK_sin,snr,'measured');
figure(1);
subplot(221)
plot(RFID_ASK(100:1000));
title('2ASK调制信号');
axis([0,1000,-10,10]);
subplot(222)
plot(RFID_ASK_sin(100:1000));
grid on;
title('ASK调制信号加正弦波干扰');
axis([0,1000,-30,30]);
subplot(223)
plot(RFID_ASK_sin_N(100:1000));
grid on;
title('过信道之后信号');
axis([0,1000,-30,30]);
%限幅
AMP = 10;
RFID_ASK_sin_N_amp = func_amp_limit(RFID_ASK_sin_N,AMP);
%ASK解调
[RFID_deASK_filter,amp]=func_AKS_Demod(RFID_ASK_sin_N_amp,Carriers,fc,fs);
subplot(224)
plot(RFID_deASK_filter(100:end));
grid on;
title('2ASK解调信号');
axis([0 L*Frame_length -5 20]);
%判决门限
RFID_deASK10 = func_unsamples(amp,Frame_length,M);
%解码
data_code_rec = func_decode(RFID_deASK10,Frame_length);
%统计误码率
Err_rate = func_err(data_code_rec,data_code,Frame_length);
Ber = Ber + Err_rate*Frame_length;
end
ERR(jj) = Ber/(Num*Frame_length);
end
figure;
semilogy(SNR,ERR,'b-o');
xlabel('SNR');
ylabel('BER');
grid on;
4.操作步骤与仿真结论
5.参考文献
A01-94