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

📄 transmitter_tr_th_2ppm.m

📁 传输参考TH-PPM调制超宽带信号的功率谱密度计算
💻 M
字号:
%产生TR-PPM调制信号!!!!!
% 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')
%
function [Stx]=transmitter_TR_TH_2PPM
%function [bits]=transmitter_TR_2PPM
% ----------------------------
% Step Zero - Input Parameters
% ----------------------------

%Pow = -30;       % Average transmitted power (dBm)
%功率为1w
fc = 50e9;       % sampling frequency

numbits = 2000;     % number of bits generated by the source
                 % number of sequence generated is 2*numbits
Ts = 40e-9;      % frame time, i.e. average bit period [s]
Tf = 4e-9;       % average pulse repetition period [s]
Ns = 10;         % 数据脉冲与参考脉冲的总个数
Nr = 4;          % 参考脉冲的总个数
Nd = Ns-Nr;      % 数据脉冲的总个数
Tc = 1e-9;       % 数据脉冲相比参考脉冲的延迟 [s]
Tm = 0.5e-9;     % pulse duration [s]
tau = 0.25e-9;   % shaping factor for the pulse [s]   
dPPM = 0.5e-9;   % time shift introduced by the PPM [s]

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

% ----------------------------------------
% Step One - Simulating Transmission Chain
% ----------------------------------------

%%%%%%%%%%%%%%%%%%%%%%%%% binary source
sequence = zeros(1,Ns*numbits);
bits = rand(1,numbits)>0.5;


%figure;
%plot(bits);


for i = Nr+1:Ns
    sequence(i:Ns:Ns*numbits) = bits;
end%在每个bit前加入Nr个0,相当于Nr个参考脉冲;每个bit重复Ns-Nr次

pn = floor(rand(1,Nd).*3);%TH Code--0 1 2

%figure;
%plot(pn);


%%%%%%%%%%%%%%%%%% Pulse Position Modulation + TH%%%%%%%%%%%%%%%%
dt = 1 ./ fc;                   % sampling period
framesamples = floor(Ts./dt);   % no. of samples between bits
pulsesamples = floor(Tf./dt);   % no. of samples between pulses
thcodesamples = floor(Tc./dt);   % no. of samples of Tc
PPMsamples = floor (dPPM./dt);  % no. of samples for the
                                %  PPM shift

totlength = framesamples*numbits;
TR_THPPMseq=zeros(1,totlength);

% ------------------------------------------------
% Step Two - main loop for introducing TH and 2PPM
% ------------------------------------------------

for k = 1 : Ns*numbits
    
    if mod(k,Ns)<=Nr
        if mod(k,Ns)>0
            index = 1 + (k-1)*pulsesamples;
        else
            index = 1 + (k-1)*pulsesamples + pn(Ns-Nr)*thcodesamples + sequence(k)*PPMsamples;
        end
    else
        index = 1 + (k-1)*pulsesamples + pn(mod(k,Ns)-Nr)*thcodesamples + sequence(k)*PPMsamples;
    end
    
    TR_THPPMseq(index) = 1;
    
end % for k = 1 : 2*numbits


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Shaping filter
power = 1;%(10^(Pow/10))/1000;     % average transmitted power
                                %  (watt)
Ex = power * Ts;                % energy per pulse
w0 = cp0201_waveform(fc,Tm,tau);% Energy Normalized pulse
                                %  waveform
wtx = w0 .* sqrt(Ex);           % pulse waveform
Sa = conv(TR_THPPMseq,wtx);        % Output of the filter
                                %  (with modulation)

% Output generation

L = (floor(Ts*fc))*numbits;

%%%%%%%%%%%%%%%%%%%%%%%%%%%采样数值
Stx = Sa(1:L);

% ---------------------------
% Step Two - Graphical Output
% ---------------------------

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

tmax = numbits*Ts;
time = linspace(0,tmax,length(Stx));
P = plot(time,Stx);
set(P,'LineWidth',[2]);
ylow=-1.5*abs(min(wtx));
yhigh=1.5*max(wtx);
axis([0 tmax ylow yhigh]);
AX=gca;
set(AX,'FontSize',12);
X=xlabel('Time [s]');
set(X,'FontSize',14);
Y=ylabel('Amplitude [V]');
set(Y,'FontSize',14);


end % end of graphical output
figure;
plot(bits);

⌨️ 快捷键说明

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