📄 cp0202_transmitter_2pam_ds.m
字号:
%
% FUNCTION 2.9 : "cp0202_transmitter_2PAM_DS"
%
% Simulation of a UWB transmitter implementing 2PAM with DS
%
% 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 DS code has periodicity 'Np'
% Each pulse has time duration 'Tm' and shaping factor
% 'tau'
%
% The function returns:
% 1) the generated stream of bits ('bits')
% 2) the generated DS code ('DScode')
% 3) the generated signal ('Stx')
% 4) a reference signal without data modulation ('ref')
%
% Programmed by Guerino Giancola
%
function [bits,DScode,Stx,ref]=cp0202_transmitter_2PAM_DS
% ----------------------------
% Step Zero - Input parameters
% ----------------------------
Pow = -30; % average transmitted power (dBm)
fc = 50e9; % sampling frequency
numbits = 2; % number of bits generated by the source
Ts = 2e-9; % frame time, i.e., average pulse repetition
% period [s]
Ns = 10; % number of pulses per bit
Np = 10; % periodicity of the DS code
Tm = 0.5e-9; % pulse duration [s]
tau = 0.25e-9; % shaping factor for the pulse [s]
G = 1;
% 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);
% Direct Sequence code
DScode = cp0202_DS(Np);
% Pulse Amplitude Modulation + DS
[PAMDSseq,DSseq] = cp0202_2PAM_DS(repbits,fc,Ts,DScode);
% 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
wtx = w0 .* sqrt(Ex); % pulse waveform
Sa = conv(PAMDSseq,wtx); % output of the filter (with
% modulation)
Sb = conv(DSseq,wtx); % output of the filter (no
% modulation)
L = (floor(Ts*fc))*Ns*numbits;
Stx = Sa(1:L);
ref = Sb(1:L);
% ---------------------------
% 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));
P = plot(time,Stx);
set(P,'LineWidth',[2]);
ylow=-1.5*max(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);
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*Ts;
L2=line([tn tn],[0.8*ylow 0.8*yhigh]);
set(L2,'Color',[0.5 0.5 0.5], ...
'LineStyle','-.','LineWidth',[1]);
end
end
end
end % end of graphical output
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -