⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cp0201_transmitter_2ppm_th.m

📁 PPM调制的超宽带系统RAKE接收机的误码率仿真程序
💻 M
字号:
%
% FUNCTION 2.6 : "cp0201_transmitter_2PPM_TH"
%
% Simulation of a UWB transmitter implementing 2PPM with TH
%
% Transmitted Power is fixed to 'Pow'
% The signal is sampled with frequency 'fc'
% 'numbits' is the number of bits generated by the source
% 'Ns' pulses are generated for each bit, and these pulses
% are spaced in time by an average pulse repetition period
% 'Ts'
% The TH code has periodicity 'Np', and cardinality 'Nh'
% The chip time has time duration 'Tc'
% Each pulse has time duration 'Tm' and shaping factor
%  'tau'
% The PPM introduces a time shift of 'dPPM'
%
% The function returns:
% 1) the generated stream of bits ('bits')
% 2) the generated TH code ('THcode')
% 3) the generated signal ('Stx')
% 4) a reference signal without data modulation ('ref')
%
% Programmed by Guerino Giancola
%

function [bits,THcode,Stx,ref]=cp0201_transmitter_2PPM_TH(Pow,fc,numbits,Ts,Ns,Tc,Nh,Np,Tm,tau,dPPM,G)

% ----------------------------
% Step Zero - Input parameters
% ----------------------------
% 
% Pow = -30;       % average transmitted power (dBm)
% 
% fc = 50e9;       % sampling frequency
% 
% numbits = 10;     % number of bits generated by the source
% 
% Ts = 10e-9;       % frame time, i.e., average pulse
%                  % repetition period [s]
% Ns = 1;          % number of pulses per bit
% 
% Tc = 1e-9;       % chip time [s]
% Nh = 5;          % cardinality of the TH code
% Np = 2000;          % periodicity of the TH code
% 
% Tm = 0.5e-9;     % pulse duration [s]
% tau = 0.2e-9;   % shaping factor for the pulse [s]   
% dPPM = 0.5e-9;   % time shift introduced by the PPM [s]

G=0;
% G=0 -> no graphical output
% G=1 -> graphical output

% ----------------------------------------
% Step One - Simulating transmission chain
% ----------------------------------------

% binary source
bits = cp0201_bits(numbits);

% repetition coder
repbits = cp0201_repcode(bits,Ns);

% TH code
THcode = cp0201_TH(Nh,Np);

% PPM + TH
[PPMTHseq,THseq] = cp0201_2PPM_TH(repbits,fc,Tc,Ts,dPPM,THcode);

% shaping filter
power = (10^(Pow/10))/1000;     % average transmitted power
                                % (watt)
Ex = power * Ts;                % energy per pulse
w0 = cp0201_waveform(fc,Tm,tau);% energy normalized pulse waveform
% w0= cp0201_waveform_gauss_mod_osc(fc,Tm,tau);
wtx = w0 .* sqrt(Ex);           % pulse waveform
Sa = conv(PPMTHseq,wtx);        % output of the filter
                                % (with modulation)
Sb = conv(THseq,wtx);           % output of the filter
                                % (without modulation)

% Output generation
L = (floor(Ts*fc))*Ns*numbits;
% L = (floor(Ts*fc)+1)*Ns*numbits;
Stx = Sa(1:L);
ref = Sb(1:L);


% L1 = (floor(Ts*fc)+1)*Ns;
L1 = (floor(Ts*fc))*Ns;
tx_bits=cp0201_repcode(bits,L1);



% ---------------------------
% Step Two - Graphical output
% ---------------------------

if G

    
F = figure(1);
set(F,'Position',[32 223 951 420]);

tmax = numbits*Ns*Ts;
time = linspace(0,tmax,length(Stx));
subplot(311)
P1=plot(time*1e9,tx_bits);grid;

set(P1,'LineWidth',2);
ylow=-1.5*abs(min(tx_bits))-0.5;
yhigh=1.5*max(tx_bits)+0.5;
axis([0 tmax*1e9 ylow yhigh]);
AX=gca;
set(AX,'FontSize',12);
T=title('发射的数据比特流bits');
set(T,'FontSize',14);
X=xlabel('Time [ns]');
set(X,'FontSize',14);
Y=ylabel('Amplitude [V]');
set(Y,'FontSize',14);

subplot(312)
P2 = plot(time*1e9,Stx);
grid on;
set(P2,'LineWidth',2);
ylow=-1.5*abs(min(wtx));
yhigh=1.5*max(wtx);
axis([0 tmax*1e9 ylow yhigh]);
AX=gca;
set(AX,'FontSize',12);
T=title('发射的窄脉冲Stx');
set(T,'FontSize',14);
X=xlabel('Time [ns]');
set(X,'FontSize',14);
Y=ylabel('Amplitude [V]');
set(Y,'FontSize',14);


subplot(313)
P3 = plot(time*1e9,ref);
grid on;
set(P3,'LineWidth',2);
ylow=-1.5*abs(min(wtx));
yhigh=1.5*max(wtx);
axis([0 tmax*1e9 ylow yhigh]);
AX=gca;
set(AX,'FontSize',12);
T=title('参考的窄脉冲ref');
set(T,'FontSize',14);
X=xlabel('Time [ns]');
set(X,'FontSize',14);
Y=ylabel('Amplitude [V]');
set(Y,'FontSize',14);


% for j = 1 : numbits
%     tj = (j-1)*Ns*Ts;
%     L1=line([tj tj],[ylow yhigh]);
%     set(L1,'Color',[0 0 0],'LineStyle', ...
%        '--','LineWidth',2);
%     for k = 0 : Ns-1
%         if k > 0
%             tn = tj + k*Nh*Tc;
%             L2=line([tn tn],[ylow yhigh]);
%             set(L2,'Color',[0.5 0.5 0.5],'LineStyle', ...
%                '-.','LineWidth',2);
%         end
%         for q = 1 : Nh-1
%             th = tj + k*Nh*Tc + q*Tc;
%             L3=line([th th],[0.8*ylow 0.8*yhigh]);
%             set(L3,'Color',[0 0 0],'LineStyle', ...
%                ':','LineWidth',1);
%         end
%     end
% end



end % end of graphical output

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -