Uploaded by abdobash2244

Matlab Programs

advertisement
DPSK_UWB_system.m
1-Applying 2nd derivative of Gaussian
𝑡 2
𝑡 2
𝑦 = 1(1 − 4𝜋 ( ) ) 𝑒𝑥𝑝 (−2𝜋 ( ) )
𝑝𝑤
𝑝𝑤
-50
3
-51
Receiver filtered noise output
x 10
3.5
x 10
3
2
AMPLITUDE
AMPLITUDE
2.5
1
0
2
1.5
1
-1
0.5
-2
-1
0
1
2
3
4
5
TIME
0
6
0
1
2
3
FREQUENCY
-8
x 10
9
-1000
15
4
5
10
x 10
Filter impulse response(ht)
x 10
AMPLITUDE
20LOG10=DB
-1020
-1040
-1060
10
5
-1080
-1100
0
1
2
3
FREQUENCY
4
5
10
x 10
0
-1
0
1
2
3
TIME
4
5
6
-8
x 10
-7
1
x 10
-8
Receiver filtered correlator output
1.2
x 10
1
AMPLITUDE
AMPLITUDE
0.5
0
0.8
0.6
0.4
-0.5
0.2
-1
-2
0
2
TIME
4
0
6
0
1
-8
x 10
2
3
FREQUENCY
4
5
10
x 10
6
-200
5
4
-250
VOLTAGE
20LOG10=DB
Comparator output (filtered) 1001101
-150
-300
-350
2
1
-400
-450
3
0
0
1
2
3
FREQUENCY
4
5
10
x 10
-1
0
1
2
3
FREQUENCY
4
5
-8
x 10
-7
1
-9
Receiver correlator output-no LPF
x 10
1.6
x 10
1.4
1.2
AMPLITUDE
AMPLITUDE
0.5
0
-0.5
1
0.8
0.6
0.4
0.2
-1
-1
0
1
2
3
4
5
TIME
0
6
0
1
-8
x 10
2
3
FREQUENCY
4
5
10
x 10
6
-200
5
-250
4
VOLTAGE
20LOG10=DB
Comparator output
-150
-300
-350
3
2
-400
1
-450
0
-500
0
1
2
3
FREQUENCY
4
5
10
x 10
-1
0
0.5
1
1.5
FREQUENCY
2
2.5
-8
x 10
-4
4
x 10
-6
DPSK modulated pulse train(01110110)
6
3
x 10
5
AMPLITUDE
AMPLITUDE
2
1
0
-1
4
3
2
-2
1
-3
-4
-1
0
1
2
3
4
5
TIME
-4
4
0
6
2
3
FREQUENCY
4
2
3
FREQUENCY
4
5
10
x 10
-100
3
-150
2
-200
20LOG10=DB
AMPLITUDE
1
x 10
DPSK delayed pulse train(01110110)
x 10
1
0
-1
-250
-300
-350
-2
-400
-3
-4
-1
0
-8
0
1
2
3
TIME
4
5
6
-8
x 10
-450
0
1
5
10
x 10
2- Applying Fifth derivative of Gaussian pulse.(5 zero crossings)
60
−(𝑡 − 0)2
𝑦 = (( 5 ) (𝑡 − 0)𝑒𝑥𝑝 (
)
𝑝𝑤
𝑝𝑤 2
80
−(𝑡 − 0)2
3
− ( 7 ) (𝑡 − 0) 𝑒𝑥𝑝 (
)
𝑝𝑤
𝑝𝑤 2
(𝑡 − 0)5
−(𝑡 − 0)2
+ (16
𝑒𝑥𝑝 (
)))
𝑝𝑤 9
𝑝𝑤 2
-50
3
x 10
-51
Receiver filtered noise output
3.5
3
2
2.5
1
AMPLITUDE
AMPLITUDE
x 10
0
-1
2
1.5
1
-2
0.5
-3
-2
0
2
TIME
4
0
6
0
1
2
3
FREQUENCY
-8
x 10
9
-1000
15
x 10
4
5
10
x 10
Filter impulse response(ht)
AMPLITUDE
20LOG10=DB
-1020
-1040
-1060
10
5
-1080
-1100
0
1
2
3
FREQUENCY
4
5
10
x 10
0
-2
0
2
TIME
4
6
-8
x 10
-7
1
x 10
-8
Receiver filtered correlator output
1.2
x 10
1
AMPLITUDE
AMPLITUDE
0.5
0
0.8
0.6
0.4
-0.5
0.2
-1
-2
0
2
TIME
4
0
6
0
1
-8
x 10
2
3
FREQUENCY
4
5
10
x 10
Comparator output (filtered) 1001101
-150
6
-200
5
VOLTAGE
20LOG10=DB
4
-250
-300
-350
2
1
-400
-450
3
0
0
1
2
3
FREQUENCY
4
5
10
x 10
-1
0
1
2
3
FREQUENCY
4
5
-8
x 10
-7
1
x 10
-9
Receiver correlator output-no LPF
1.6
x 10
1.4
1.2
AMPLITUDE
AMPLITUDE
0.5
0
-0.5
1
0.8
0.6
0.4
0.2
-1
-2
0
2
TIME
4
0
6
0
1
-8
x 10
2
3
FREQUENCY
4
5
10
x 10
6
-200
5
-250
4
VOLTAGE
20LOG10=DB
Comparator output
-150
-300
-350
3
2
-400
1
-450
0
-500
0
1
2
3
FREQUENCY
4
5
10
x 10
-1
0
0.5
1
1.5
FREQUENCY
2
2.5
-8
x 10
-4
4
x 10
-6
DPSK modulated pulse train(01110110)
7
3
6
5
AMPLITUDE
AMPLITUDE
2
1
0
-1
3
1
-3
-4
-1
0
1
2
3
4
5
TIME
-4
x 10
0
6
1
2
3
FREQUENCY
4
2
3
FREQUENCY
4
5
10
x 10
DPSK delayed pulse train(01110110)
-100
-150
2
20LOG10=DB
-200
1
0
-1
-250
-300
-350
-2
-400
-3
-4
-1
0
-8
x 10
3
AMPLITUDE
4
2
-2
4
x 10
0
1
2
3
TIME
4
5
6
-8
x 10
-450
0
1
5
10
x 10
TR_UWB1_Multipath.m
Undefined function 'ieeechannelTest' for input arguments of type
'struct'.
Error in TR_UWB1_Multipath (line 44)
[h] = ieeechannelTest(param,cm_num);
Example uses function (TRUWBTXfinal)
1
0.5
0
-0.5
-1
0
0.2
0.4
0.6
0.8
1
1.2
-6
x 10
1
0.5
0
-0.5
-1
0
500
1000
1500
2000
2500
DPSK_UWB_system
%Run from editor debug(F5)-DPSK UWB system analysis
%JC 12/10/05
%This m file simulates a differential phase shift keyed (DPSK) ultra wide
bandwidth(UWB) system using
%a fifth derivative waveform equation of a Gaussian pulse. I thought the
setup for DPSK
%would be apparent to configure from my other fifth drivative m files but
several emails
%convinced me otherwise so here it is. This system should be fairly easy to
breadboard in
%the lab assuming an appropriately starting pulse can be realized along with
the required
%delay line in the receuver. I have to keep reminding myself we are only
talking one to
%five meters, not miles. One could walk in front of the antennas and flip and
move the antennas to
%observe multipath, etc. Another interesting problem for test equipment
vendors
%is how to measure and characterize the spectrum of the waveform coming off
the
%transmitting antenna in the far field. Anyway, good luck to those who like
to tinker and
%play in new areas of wireless.
%The receiver section uses a squaring %circuit(mixer) with a delay in one leg
and a low pass filter
%is used to integrate the waveforms to recover the voltage levels(a
radiometer and/or correlaton receiver).
%A one bit flash ADC is simulated via a comparator routine to show the
demodulated
%output bits from the integrator. Various plots of time and frequency
waveforms are shown at
%different positions in the file so the user can observe and analyze the
%operation of the simulated system. The transmitter is simulated assuming
%the fifth order waveforms are being sent from an appropriate antenna. The
receiving antenna
%in a real system would distort the original and delayed signal equally.
%The fifth derivative waveform equation is obtained by use of the Matlab
symbolic processor in
%matlab.You would actually use the fourth derivative of the gaussian
%monocycle 1st derivative which is t/pw*exp(-t^2/pw^2).Procedure as follows:
%syms t pw
%t/pw*exp(-t^2/pw^2)enter
%diff(ans,t,4)
%ans=60/pw^5*t*exp(-t^2/pw^2)-80/pw^7*t^3*exp(-t^2/pw^2)+16*t^5/pw^9*exp(t^2/pw^2)
%set pw=1 to normalize and do an ezplot(ans) and you should get a plot of the
fifth order
%derivative which has 5 zero crossings.It is apparent from my previous files
that the 1st and
%second derivative pulses will not meet the FCC spectral mask without
%reducing the transmitter power. The fifth order derivative pulse meets the
FCC
%mask without a reduction in power. It also retains a wide 3DB and 10DB
bandwidth.
%One may ask how to generate these pulses at the transmitter. One possible
%method might be to take a high speed differentially encoded digital bit
stream and process it
%thru highpass or bandpass filters(the pulse would ring on the leading edge
%and would ring and be inverted on the trailing edge) with the output being a
close match to a
%fourth derivative waveform and use a TX antenna that differentiates the
pulse
%once for fifth order. DPSK does not require a template at the receiver and
any
%distortions caused by the receiving antenna or the channel path would be
reduced
%and possibly balanced out. It may be possible to improve the system (for
short distances
%and very high bit rates), to use direct sequence spread spectrum(DSSS) (for
smoothing and
%multiple access-may not be required since UWB is already a spread spectrum
process) and forward
%error correction(FEC) coding with the DPSK scheme. Not needing to synch up
the receiver with a templet
%solves a lot of design problems. You would only lose several DB of Eb/No(1e3)
%and as stated before would not require generation of a template at
%the receiver for syncronization assuming timing jitter can be held to a
minimum.
%The characteristics of the fifth order waveform are as follows and which you
can verify are:
%pw(tail to tail)=~.5e-9
%fc=~7Ghz
%3DB fl to fh=~3GHz
%10DB fl to fh=~6GHz
%You might wish to review my other files published under UWB or author(C,J)
to get
%additional information on UWB analysis.
%================================================
clear
Fs=100e9;%sample frequency
Fn=Fs/2;%Nyquist frequency
t=-1e-9:1/Fs:46e-9;%time vector sampled at Fs Hertz. zoom in/out using (-1e9:1/Fs:xxxx)-set for
%6e-9 to see first pulse.
%================================================
% EQUATIONS
%================================================
%y=A*(t/pw).*exp(-(t/pw).^2);%1st derivative of Gaussian pulse=Gaussian
monocycle
%y =1*(1 - 4*pi.*((t)/pw).^2).* exp(-2*pi.*((t)/pw).^2);%2nd derivative of
Gaussian
%pulse=doublet(two zero crossings)
pw=75e-12;%value sets pulse width of fifth derivative looking at figure 1
y=((60./pw.^5).*(t-0).*exp(-(t-0).^2./pw.^2)-(80./pw.^7).*(t-0).^3.*exp(-(t0).^2./pw.^2)+ ...
(16.*(t-0).^5./pw.^9.*exp(-(t-0).^2/pw.^2)));%Fifth derivative of Gaussian
pulse.(5 zero crossings)
yd=((60./pw.^5).*(t-5e-9).*exp(-(t-5e-9).^2./pw.^2)-(80./pw.^7).*(t-5e9).^3.*exp(-(t-5e-9).^2./pw.^2)+ ...
(16.*(t-5e-9).^5./pw.^9.*exp(-(t-5e-9).^2/pw.^2)));%(one) fifth derivative
pulse delayed by 5e-9 sec
% t=t-5e-9;
% ydd=((60./pw.^5).*(t-0).*exp(-(t-0).^2./pw.^2)-(80./pw.^7).*(t-0).^3.*exp((t-0).^2./pw.^2)+ ...
% (16.*(t-0).^5./pw.^9.*exp(-(t-0).^2/pw.^2)));%Fifth derivative of Gaussian
pulse.(5 zero crossings)
% dddddddd
%================================================
%NOISE SETUP FOR BER AND SNR
%================================================
noise=1e-50*(randn(size(t)));%(Noise-AWGN)Set to 1e-50 to disable(set to~3e-5
for Eb/No=9DB BER @1e-3)
%================================================
%DPSK
%================================================
%The following series of equations sets the pulse recurring frequency(PRF)
%at 200MHz(waveform repeats every 5e-9 sec and a
%modulated bit stream(bit rate=200Mb/s)of 1001101 (differentially encoded to
a value of 01110110)
%where a phase change (0to1 or 1to0)=0 and no phase change (0to0 or 1to1)=1
%==================================================
% FIFTH DERIVATIVE(DPSK) WITH 5 PULSES)
%==================================================
%DPSK modulated fifth(ydiff)
A=.6e-45;%sets voltage level out of TX or input to mixer(.6e-45 for .6mv volt
peak to peak)
ydiff=-A*y+ ...
A*((60./pw.^5).*(t-5e-9).*exp(-(t-5e-9).^2./pw.^2)-(80./pw.^7).*(t-5e9).^3.*exp(-(t-5e-9).^2./pw.^2)+ ...
(16.*(t-5e-9).^5./pw.^9.*exp(-(t-5e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-10e-9).*exp(-(t-10e-9).^2./pw.^2)-(80./pw.^7).*(t-10e9).^3.*exp(-(t-10e-9).^2./pw.^2)+ ...
(16.*(t-10e-9).^5./pw.^9.*exp(-(t-10e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-15e-9).*exp(-(t-15e-9).^2./pw.^2)-(80./pw.^7).*(t-15e9).^3.*exp(-(t-15e-9).^2./pw.^2)+ ...
(16.*(t-15e-9).^5./pw.^9.*exp(-(t-15e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-20e-9).*exp(-(t-20e-9).^2./pw.^2)-(80./pw.^7).*(t-20e9).^3.*exp(-(t-20e-9).^2./pw.^2)+ ...
(16.*(t-20e-9).^5./pw.^9.*exp(-(t-20e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-25e-9).*exp(-(t-25e-9).^2./pw.^2)-(80./pw.^7).*(t-25e9).^3.*exp(-(t-25e-9).^2./pw.^2)+ ...
(16.*(t-25e-9).^5./pw.^9.*exp(-(t-25e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-30e-9).*exp(-(t-30e-9).^2./pw.^2)-(80./pw.^7).*(t-30e9).^3.*exp(-(t-30e-9).^2./pw.^2)+ ...
(16.*(t-30e-9).^5./pw.^9.*exp(-(t-30e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-35e-9).*exp(-(t-35e-9).^2./pw.^2)-(80./pw.^7).*(t-35e9).^3.*exp(-(t-35e-9).^2./pw.^2)+ ...
(16.*(t-35e-9).^5./pw.^9.*exp(-(t-35e-9).^2/pw.^2)));
%-A inverts waveform
%DPSK delayed(5e-9) fifth(ydelayed)(notice inversion from ydiff-keeps ADC
%(comparator) output correct). This is acceptable under differential
%encoding PSK phase ambiguity rules.
ydelayed=A*yd+ ...
-A*((60./pw.^5).*(t-10e-9).*exp(-(t-10e-9).^2./pw.^2)-(80./pw.^7).*(t-10e9).^3.*exp(-(t-10e-9).^2./pw.^2)+ ...
(16.*(t-10e-9).^5./pw.^9.*exp(-(t-10e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-15e-9).*exp(-(t-15e-9).^2./pw.^2)-(80./pw.^7).*(t-15e9).^3.*exp(-(t-15e-9).^2./pw.^2)+ ...
(16.*(t-15e-9).^5./pw.^9.*exp(-(t-15e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-20e-9).*exp(-(t-20e-9).^2./pw.^2)-(80./pw.^7).*(t-20e9).^3.*exp(-(t-20e-9).^2./pw.^2)+ ...
(16.*(t-20e-9).^5./pw.^9.*exp(-(t-20e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-25e-9).*exp(-(t-25e-9).^2./pw.^2)-(80./pw.^7).*(t-25e9).^3.*exp(-(t-25e-9).^2./pw.^2)+ ...
(16.*(t-25e-9).^5./pw.^9.*exp(-(t-25e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-30e-9).*exp(-(t-30e-9).^2./pw.^2)-(80./pw.^7).*(t-30e9).^3.*exp(-(t-30e-9).^2./pw.^2)+ ...
(16.*(t-30e-9).^5./pw.^9.*exp(-(t-30e-9).^2/pw.^2)))+ ...
-A*((60./pw.^5).*(t-35e-9).*exp(-(t-35e-9).^2./pw.^2)-(80./pw.^7).*(t-35e9).^3.*exp(-(t-35e-9).^2./pw.^2)+ ...
(16.*(t-35e-9).^5./pw.^9.*exp(-(t-35e-9).^2/pw.^2)))+ ...
A*((60./pw.^5).*(t-40e-9).*exp(-(t-40e-9).^2./pw.^2)-(80./pw.^7).*(t-40e9).^3.*exp(-(t-40e-9).^2./pw.^2)+ ...
(16.*(t-40e-9).^5./pw.^9.*exp(-(t-40e-9).^2/pw.^2)));
ydiff=ydiff+noise;%DPSK modulated fifth with noise
ydelayed=ydelayed+noise;%delayed DPSK fifth with noise
yc=ydelayed.*ydiff;
%yc=ydiff.*ydelayed;%This is where the correlation occurs in the receiver and
would be the
%mixer in the receiver. You are multipling the DPSK fifth with a .5e-9
delayed replecia
%==================================================
% FFT
%==================================================
%new FFT for DPSK modulated fifth(ydiff)
NFFYDIFF=2.^(ceil(log(length(ydiff))/log(2)));
FFTYDIFF=fft(ydiff,NFFYDIFF);%pad with zeros
NumUniquePts=ceil((NFFYDIFF+1)/2);
FFTYDIFF=FFTYDIFF(1:NumUniquePts);
MYDIFF=abs(FFTYDIFF);
MYDIFF=MYDIFF*2;
MYDIFF(1)=MYDIFF(1)/2;
MYDIFF(length(MYDIFF))=MYDIFF(length(MYDIFF))/2;
MYDIFF=MYDIFF/length(ydiff);
f=(0:NumUniquePts-1)*2*Fn/NFFYDIFF;
%new FFT for correlated pulses(yc)
%yc is the time domain signal output of the multiplier
%(modulated times delayed) in the correlation receiver. Plots
%in the time domain show that a simple comparator and clocked flip flop
instead of a multibit high speed flash ADC
%may be used to recover the 1001101 signal depending on integrator design and
level of
%peak voltage into mixer.
NFFYC=2.^(ceil(log(length(yc))/log(2)));
FFTYC=fft(yc,NFFYC);%pad with zeros
NumUniquePts=ceil((NFFYC+1)/2);
FFTYC=FFTYC(1:NumUniquePts);
MYC=abs(FFTYC);
MYC=MYC*2;
MYC(1)=MYC(1)/2;
MYC(length(MYC))=MYC(length(MYC))/2;
MYC=MYC/length(yc);
f=(0:NumUniquePts-1)*2*Fn/NFFYC;
%===================================================
% PLOTS
%===================================================
%plots for DPSK modulated fifth(ydiff)
figure(1)
subplot(2,2,1); plot(t,ydiff);xlabel('TIME');ylabel('AMPLITUDE');
title('DPSK modulated pulse train(01110110)');
grid on;
%axis([-1e-9,27e-9 -1 2]);
subplot(2,2,2); plot(f,MYDIFF);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 20e9 0 .0001]);%zoom in/out
subplot(2,2,3); plot(t,ydelayed);xlabel('TIME');ylabel('AMPLITUDE');
title('DPSK delayed pulse train(01110110)');
grid on;
%axis([-1e-9,27e-9 -1 2]);
subplot(2,2,4);
plot(f,20*log10(MYDIFF));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 15e9 -200 5]);
%plots for correlated pulses(yc)
figure(2)
subplot(2,2,1); plot(t,yc);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver correlator output-no LPF');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYC);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 7e9 0 .025]);%zoom in/out
subplot(2,2,3);
plot(f,20*log10(MYC));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);
%===========================================================
%CORRELATION RECEIVER COMPARATOR[ADC](before lowpass filter)
%===========================================================
pt=.1e-8;%sets level where threshhold device comparator triggers
H=5;%(volts)
L=0;%(volts)
LEN=length(yc);
for ii=1:LEN;
if yc(ii)>=pt;%correlated output(yc) going above pt threshold setting
pv(ii)=H;%pulse voltage
else;
pv(ii)=L;
end;
end ;
po=pv;%pulse out=pulse voltage
%figure(3)
subplot(2,2,4);plot(t,po);
axis([-1e-9 27e-9 -1 6])
title('Comparator output');xlabel('FREQUENCY');ylabel('VOLTAGE');
grid on;
%===================================================
%SETUP and INFO
%===================================================
%Check axis settings on plots.
%Change t=-1e-9:1/Fs:(xxxx) to 1e-9 or proper value for viewing
%Press F5 or run.
%With waveform in plot 2,2,1(Figure 1), set pulse width to
%.5e-9(tail to tail).
%Change t=-1e-9:1/Fs:(xxx) to something like 46e-9.Zoom out. I would
%comment in all plot axis and use them for zooming in and out.
%Press F5 and observe waveforms. Print or observe waveforms to compare with
next set of
%wave forms.
%===================================================================
% CORRELATION RECEIVER LOW PASS FILTER(INTEGRATOR)
%=======================================================================
rc=.5e-9;%time constant
ht=(1/rc).*exp(-t/rc);%impulse response
ycfo=filter(yc,1,ht)/Fs;%use this instead of ycfo=conv(yc,ht)/Fs for proper
dimension.
%The #=1 allows this. The LPF RC time constant(integrates over this time).
%Theory states that it should be set to the pulse width but should be set
%to a value that gives the best error free operation at the highest noise
%levels. Different filter types(butterworth,etc) may give different
%results.
%The 3DB or 1/2 power bandwidth on the RC LPF is f=1/(2*pi*RC). The noise
%bandwith is f=1/(4*rc).
yn=filter(noise,1,ht)/Fs;%looks at filtered noise only(Figure 4)
%new FFT for filtered correlated pulses(ycfo)
NFFYCFO=2.^(ceil(log(length(ycfo))/log(2)));
FFTYCFO=fft(ycfo,NFFYCFO);%pad with zeros
NumUniquePts=ceil((NFFYCFO+1)/2);
FFTYCFO=FFTYCFO(1:NumUniquePts);
MYCFO=abs(FFTYCFO);
MYCFO=MYCFO*2;
MYCFO(1)=MYCFO(1)/2;
MYCFO(length(MYCFO))=MYCFO(length(MYCFO))/2;
MYCFO=MYCFO/length(ycfo);
f=(0:NumUniquePts-1)*2*Fn/NFFYCFO;
%new FFT for filtered noise(yn)
NFFYN=2.^(ceil(log(length(yn))/log(2)));
FFTYN=fft(yn,NFFYN);%pad with zeros
NumUniquePts=ceil((NFFYN+1)/2);
FFTYN=FFTYN(1:NumUniquePts);
MYN=abs(FFTYN);
MYN=MYN*2;
MYN(1)=MYN(1)/2;
MYN(length(MYN))=MYN(length(MYN))/2;
MYN=MYN/length(yn);
f=(0:NumUniquePts-1)*2*Fn/NFFYN;
%plots for filtered correlated pulses(ycfo)
figure(3)
subplot(2,2,1); plot(t,ycfo);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver filtered correlator output');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYCFO);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 5e9 0 .35]);%zoom in/out
subplot(2,2,3);
plot(f,20*log10(MYCFO));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);
%=========================================================
% CORRELATION RECEIVER COMPARATOR[ADC](after low pass filter)
%=========================================================
pt1=1.7e-8;%sets level where threshhold device comparator triggers
H=5;%(volts)
L=0;%(volts)
LEN=length(ycfo);
for ii=1:LEN;
if ycfo(ii)>=pt1;%correlated output(ycfo) going above pt threshold
setting
pv1(ii)=H;%pulse voltage
else;
pv1(ii)=L;
end;
end ;
po1=pv1;%pulse out=pulse voltage
subplot(2,2,4);plot(t,po1);xlabel('FREQUENCY');ylabel('VOLTAGE');
axis([-1e-9 50e-9 -1 6]);
title('Comparator output (filtered) 1001101');
grid on;
%plots for filtered noise(yn) and impulse response of filter
figure(4)
subplot(2,2,1);plot(t,yn);xlabel('TIME');ylabel('AMPLITUDE');
title('Receiver filtered noise output');
grid on;
%axis([-1e-9,27e-9 -1 1]);
subplot(2,2,2); plot(f,MYN);xlabel('FREQUENCY');ylabel('AMPLITUDE');
grid on;
%axis([0 5e9 0 .25]);%zoom in/out
subplot(2,2,3);
plot(f,20*log10(MYN));xlabel('FREQUENCY');ylabel('20LOG10=DB');
grid on;
%axis([0 20e9 -120 0]);
subplot(2,2,4);plot(t,ht);xlabel('TIME');ylabel('AMPLITUDE');
title('Filter impulse response(ht)');
grid on;
%axis([0,1e-9 0 1]);
%=========================================================
%BER CALCULATIONS
%=========================================================
%I'm going to calibrate the noise generator and roughly determine the Eb/No
or SNR in DB
%that allows the system to operate almost error free(1e-3) in a noise
environment.
%This value of Eb/No is the number in DB that can be used in link
%calculations. The calibration is required because in an actual TX-RX the
received
%voltage into the correlation receiver at the mixer will be in the low
millivolt
%region due to the FCC spectral mask at -41.3dBm/MHz and low transmitter
power.
%It will not be the 2 volt peak-peak BPSK used here and must be recalibrated
if
%different than 2 volt peak-peak.
%The Eb/No value in DB is calculated as follows. Doing numerous runs by hand
and
%observing the LPF comparator output in figure 4, determine the proper
%setting of the comparator threshold setting, RC filter time constant and
%level of multiplier in the AWGN noise generator that gives almost error
%free operation. This will be considered Eb/No in DB.For DPSK theory this
value is ~9DB for BER of 1e-3.
%For a SNR of 9 DB, 20*LOG10(ratio of Vsigp-p/Vnoisep-p=9DB=20*LOG(0.6e3/0.213e-3)
%You can try a different calibration method if you don't think
%this is correct. Remember to recalibrate for new pulse widths and amplitude
changes
%into the mixer and pay attention to axis settings. There are a few to keep
track of.
%I did some preliminary link caculations with this set up and determined that
approx 0.6mv p-p
%would be present on the mixer input at Eb/No=9DB.
%========================================================
%FCC spectral mask -41.3dBm/MHz+10LOG10(~4000)=~-5dBm(aver TX power Pt)
%antenna gains 0DBi(50 ohms)
%lna 20DB gain
%NF 10 DB
%distance 1 meter
%(PL)path loss~45DB
%200Mbit rate(Rb)
%BW~318Mhz 3DB BW(LPF)(RC=.5e-9)
%Pn(receiver noise level)=KTB=-114dBm+NF+10log10(Rb)=-114dBm+10DB+23DB=-81dBm
%3DB to 10DB spread of pulse ~3 to 6GHz(use 4GHz)
%pw=.5e-9 fifth derevative
%fc=~7Ghz
%Eb/No=9DB(1e-3)
%power received(Pr)@ant=-5dBm-45DB(PL)=-50dBm over ~4GHz.
%Link margin=Pr-Pn-Eb/No
%Link margin@ 1 meter=-50dBm-(-81dBm)-(9DB)=22DB
%Emixerp-p=sqrt(1e-5mw*50)=2.23e2mvrms*1.41=0.03mvpeak*20DB(lna)gain=0.3mvpeak or 0.6mvp-p
Untitled
% Sample Experiment:
numberOfBits=50;
fs=50e9;
Ep=1;
tc=1e-9;
Tf=10;
Nf=2;
Td=2;
Nc=Tf;
AWGNSNR=10;
[allPulsesWithNoise SimulationTime DataSequence THCode] =...
TRUWBTXfinal(numberOfBits,fs,Ep,tc,Tf,Nf,Td,Nc,AWGNSNR,0);
subplot(2,1,1);plot(SimulationTime,allPulsesWithNoise)
subplot(2,1,2);plot(allPulses)
TRUWBTXfinal
% TR-UWB Transmitter
% Author: Caglar Arslan
% Date: 30-09-2007 (1st Version)
%
02-10-2007 (Revised)
%
03-10-2007 (Finalized)
%-------------------------------------------------------------------------% Simulation Experiment Parameters
% fs : Sampling frequency of the pulses
% Ep : Used for adjusting the energy of the pulse
% tc : Width of the pulse
% Tf : Frame length reference (A Real Number)
% Nf : Pulse Repetition Info
% Td : Data pulse delay reference
% Nc : TH Code bin number reference. Usually taken as Nc=Tf
% AWGNSNR : SNR value for AWGN (in dB)
% GaussianPulseOrder : Determines the shape of the pulse (2 for 2nd order,
% 3 for 3rd order)
% plotFlag : Logical flag for the plot of the pulse shape and the
% transmitted signal. Disable this for large number of bits for
% transmission.
% Sample Experiment:
% numberOfBits=50;
% fs=50e9;
% Ep=1;
% tc=1e-9;
% Tf=10;
% Nf=2;
% Td=2;
% Nc=Tf;
% AWGNSNR=10;
% [allPulsesWithNoise SimulationTime DataSequence THCode] =
TRUWBTXfinal(numberOfBits,fs,Ep,tc,Tf,Nf,Td,Nc,AWGNSNR,3,0);
function [allPulses SimulationTime DataSequence THCode] =
TRUWBTXfinal(numberOfBits,fs,Ep,tc,Tf,Nf,Td,Nc,GaussianPulseOrder,plotFlag);
% The Pulse Shape
plotFlag=0;
GaussianPulseOrder=2;
if GaussianPulseOrder==3
% Gaussian Pulse Monocycle 2nd Order
% 2 GHz Gaussian monopulse sampled at a rate of 100 GHz:
fc = 2E9; fs=100E9;
% center freq, sample freq
tc = gmonopuls('cutoff',fc);
% width of each pulse
t1 = -2*tc : 1/fs : 2*tc;
Y = gmonopuls(t1,fc);
end
% Gaussian Pulse 3rd Order
if GaussianPulseOrder==2
t=-5e-10:1/fs:5e-10;
a=tc /2.5;
Y=(1-(4*pi.*(t.^2))/a^2) .* exp(-2*pi.*(t.^2)/a^2) / sqrt(Ep);
end
if plotFlag==1
figure
plot(t,Y) %Plot of Gaussian Monocycle Pulse - 2nd Order Gaussian Pulse
end
%-------------------------------------------------------------------------Ts=Nf*Tf;
RAND1=randperm(Nc); RAND2=randperm(Nc);
myRand=RAND1(RAND2(1));
% Generate the Reference Locations
D1(1)=myRand -0.5; %Location of the first TR pulse
THCode(1)=myRand;
for i=2:numberOfBits
Rrand1=randperm(Nc); rand2=randperm(Nc);
myRand=Rrand1(rand2(1));
THCode(i)=myRand;
D1(i)=D1(i-1)+(Ts*(i-1)-D1(i-1)-tc)+ myRand;
%
D1(i)=Ts*(i-1)-tc+ myRand;
end
D2=D1+Td;
if (Nf>0)
k=1;
for i=1:length(D1)
for j=0:(Nf-1)
newD1(k)=D1(i)+Tf*j;
%newD2(k)=D2(i)+Tf*j;
k=k+1;
end
end
end
D1=newD1;
D2=D1+Td;
%D2=newD2; %Locations of the pulses with Nf
Dtr = D1' * 1e-9;
% locations of the TR pulses in ns.
Ddata = D2' * 1e-9;
% locations of the Data pulses in ns.
% Generate the TR Pulse Train
t = 0 : 1/fs : numberOfBits*Ts*1e-9; % signal evaluation time
SimulationTime=t;
yp = pulstran(t,Dtr,Y,fs);
% Generate the Modulation Info and Data Pulses
randOut=rand;
if randOut==1
modulationInfo=1;
else
modulationInfo=-1;
end
DataSequence(1:numberOfBits)=modulationInfo;
ypx=pulstran(t,Ddata,Y*modulationInfo,fs);
%--------------------allPulses= yp+ypx;
% allPulses=[zeros(1,300) yp+ypx];
% plot(t,yp)
% hold on
% plot(t,ypx,'r')
DPSK_UWB_system
%================================================
pw1=.5e-9;
%pulse width in nanosec,change to desired width
pw=pw1/2.5;
%Fudge factor for inaccurate PWs(approx. 4-5 for 1st der.
and
%approx. 2-3 for 2nd der.)
Fs=100e9;
%sample frequency
Fn=Fs/2;
%Nyquist frequency
t=-1e-9:1/Fs:1e-9; %time vector sampled at Fs Hertz. zoom in/out using (-1e9:1/Fs:xxxx)
A=1;
%================================================
% EQUATIONS
%================================================
% y=A*(t/pw).*exp(-(t/pw).^2);
%1st derivative of
Gaussian pulse=Gaussian monocycle
y =A*(1 - 4*pi.*((t)/pw).^2).* exp(-2*pi.*((t)/pw).^2); %2nd derivative of
Gaussian
%pulse=doublet(two zero crossings)
%================================================
%==================================================
% 1ST DERIVATIVE MONOCYCLE(PPM WITH 5 PULSES)
%==================================================
yp=y+ ...
A*((t-2.5e-9-.2e-9)/pw).*exp(-((t-2.5e-9-.2e-9)/pw).^2)+A*((t-5e9)/pw).*exp(-((t-5e-9)/pw).^2)+ ...
A*((t-7.5e-9-.2e-9)/pw).*exp(-((t-7.5e-9-.2e-9)/pw).^2)+A*((t-10e9)/pw).*exp(-((t-10e-9)/pw).^2);
% dddddd
%==================================================
% 2ND DERIVATIVE DOUBLET(PPM WITH 5 PULSES)
%==================================================
% yp=y+ ...
% A*(1-4*pi.*((t-2.5e-9-.2e-9)/pw).^2).*exp(-2*pi.*((t-2.5e-9-.2e-9)/pw).^2)+
...
% A*(1-4*pi.*((t-5.0e-9)/pw).^2).*exp(-2*pi.*((t-5.0e-9)/pw).^2)+ ...
% A*(1-4*pi.*((t-7.5e-9-.2e-9)/pw).^2).*exp(-2*pi.*((t-7.5e-9-.2e-9)/pw).^2)+
...
% A*(1-4*pi.*((t-10e-9)/pw).^2).*exp(-2*pi.*((t-10e-9)/pw).^2);
%==================================================
% FFT
%==================================================
y=yp;
NFFY=2.^(ceil(log(length(y))/log(2)));
FFTY=fft(y,NFFY);%pad with zeros
NumUniquePts=ceil((NFFY+1)/2);
FFTY=FFTY(1:NumUniquePts);
MY=abs(FFTY);
MY=MY*2;
MY(1)=MY(1)/2;
MY(length(MY))=MY(length(MY))/2;
MY=MY/length(y);
f=(0:NumUniquePts-1)*2*Fn/NFFY;
%===================================================
% PLOTS
%===================================================
subplot(2,2,1); plot(t,y);xlabel('TIME');ylabel('AMPLITUDE');
grid on;
%axis([-1e-9,4e-9 -1 1])
subplot(2,2,2); plot(f,MY);xlabel('FREQUENCY');ylabel('AMPLITUDE');
%axis([0 10e9 0 .1]);%zoom in/out
grid on;
subplot(2,2,3);
plot(f,20*log10(MY));xlabel('FREQUENCY');ylabel('20LOG10=DB');
%axis([0 20e9 -120 0]);
grid on;
%SETUP
%Enter desired pulse width in pw1(.5e-9).
%Change t=-1e-9:1/Fs:(xxxx) to 1e-9.
%Press F5 or run.
%With waveform in plot 2,2,1, set pulse width with fudge factor to .5e-9
%using #s corresponding to chosen waveform. Set from tail to tail.
%Change t=-1e-9:1/Fs:(xxx) to something like 20e-9.Zoom out. I would
%comment in all plot axis and use them for zooming in and out.
%Press F5 and observe waveforms. Print waveforms to compare with next set of
%wave forms.
%Pick another waveform by commenting out existing waveform and repeat as
above.
%When you compare the waveforms you will see that the second derivative
%doublet has a center frequency in the spread twice that of the first
%derivative monocycle.
%You would expect this on a second derivative. Picking a doublet waveform
%for transmission (by choice of UWB antenna design) pushes the fc center
frequency
%spread out by (two) allowing relief from the difficult design of narrower
pulse
%generating circuits in transmitters and receivers. If you chose a monocycle,
you would
%need to design your pulse circuits with a much narrower(factor of two)pulse
width to
%meet the tough FCC spectral mask from ~3 to 10GHz at-40 DB. I would guess a
%pulse width of ~ 0.4 to 0.45 nanosec using a doublet at the proper
amplitude(A)
%would meet the requirements.
%You can zoom in on the waveforms of plot 2,2,1 to see the PPM
%delays generating 01010. Use axis on plot 2,,2,1 for better
%zooming.Comment in the axis.
Download