% Title: UWB BPSK Analysis
% Author: J C
% Summary: Models an UWB TX and RX using BPSK.
% MATLAB Release: R13
% Description: This m file models an UWB system using BPSK.
% The receiver is a correlation receiver with a LPF integrator
% and comparators for threshhold selection.
%UWB-Run from editor debug(F5)-BPSK modulation and link analysis of
%UWB monocycle and doublet waveforms.Revised 1/2/05-JC
%This m file plots the time and frequency waveforms for BPSK 1st and 2nd derivative
%equations used in UWB system analysis. Adjustment factors are required to
%correct for inaccuracies in the 1st and 2nd derivative equations.
%Tail to tail on the time wave forms should be considered as the actual pulse width.
%7*PW1 has about 99.9% of the signal power. The frequency spreads and center
%frequencies(fc=center of the spread)are correct as you can verify(fc~1/pw1).
%Change pw(adjustment factor)and t for other entered(pw1) pulse widths and
%zooming in on the waveforms.A basic correlation receiver is constructed
%with an integrator(low pass filter-uses impulse response)showing the demodulated output
%information from a comparator(10101). Perfect sync is assumed in the correlation receiver.
%Noise is added with a variance of 1 and a mean of 0.
%See SETUP and other info at end of program.
%The program is not considered to be the ultimate in UWB analysis, but is
%configured to show basic concepts of the new technology. I would suggest that
%you review the previous files I published in the Mathworks file exchange concerning
%UWB to enhance your understanding of this technology. PPM(pulse position
%modulation) was analyzed in earlier files. PPM is an orthogonal waveform
%and not as efficient as BPSK which is an antipodal waveform with helpful
%properties in UWB usage. My assumption in this analysis is that the transmitting antenna
%produces a 2nd derivative doublet and that the receiving antenna passes
%the doublet thru to the mixer without integrating or differentating the signal, leaving
%a doublet. I believe the doublet also has helpful properties in UWB
%systems. I have included a reference at the end which is a must read.
%================================================
pw1=.2e-9;%pulse width in nanosec,change to desired width
pw=pw1/1.24;%Adjustment factor for inaccurate PWs(approx. 3-5 for 1st der. and
%approx. 1-3 for 2nd der.)
Fs=100e9;%sample frequency
Fn=Fs/2;%Nyquist frequency
t=-1e-9:1/Fs:30e-9;%time vector sampled at Fs Hertz. zoom in/out using (-1e-9:1/Fs:xxxx)
%================================================
% 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)
%================================================
%NOISE SETUP FOR BER AND SNR
%================================================
noise=(1e-50)*(randn(size(t)));%Noise-AWGN(0.2 gives approx Eb/No=Es/No=SNR= 7DB)
%for 2 volt peak to peak BPSK signal.Set to 1e-50 to disable
%================================================
%BPSK OR BI-PHASE MODULATION
%================================================
%The following series of equations sets the pulse recurring frequency(PRF)
%at 156MHz(waveform repeats every 6.41e-9 sec and a
%modulated bit stream(bit rate=156Mb/s)of 10101 (5 pulses,can add more)
%where a {1=0 degrees(right side up) and a 1 bit} and a {-1=180
%degrees(upside down) a 0 bit.}
%One could expand the # of pulses and modulate for a series of
%111111000000111111000000111111 which would give a lower bit rate. You could just
%change the PRF also.This series of redundent pulses also improves the processing gain
%of the receiver(under certain conditions)by giving more voltage out of the integrator
%in a correlation receiver. The appropriate sequence when using BPSK can also produce
%nulls in the spectrum which would be useful for interference rejection or to keep
%the UWB spectrum from interfering with other communication systems.
%For loops or some other method could be used to generate these pulses but for
%myself, I would get lost. This is a brute force method and I can easily copy and paste.
%I will leave other methods for more energetic souls. Since we have the transmitter
%implemented it's time to move on to the correlation receiver design and
%see if we can demodulate and get 10101 bits out at the 156Mb/s bit rate.
%==================================================
% 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-5e-9)/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-10e-9)/pw).*exp(-((t-10e-9)/pw).^2);
%==================================================
% 2ND DERIVATIVE DOUBLET(BPSK) WITH 5 PULSES)
%==================================================
%BPSK modulated doublet(yp)
yp=1*y+ ...
-1*(1-4*pi.*((t-6.41e-9)/pw).^2).*exp(-2*pi.*((t-6.41e-9)/pw).^2)+ ...
1*(1-4*pi.*((t-12.82e-9)/pw).^2).*exp(-2*pi.*((t-12.82e-9)/pw).^2)+ ...
-1*(1-4*pi.*((t-19.23e-9)/pw).^2).*exp(-2*pi.*((t-19.23e-9)/pw).^2)+ ...
1*(1-4*pi.*((t-25.64e-9)/pw).^2).*exp(-2*pi.*((t-25.64e-9)/pw).^2);
%unmodulated doublet(yum)
B=1;
yum=B*y+ ...
B*(1-4*pi.*((t-6.41e-9)/pw).^2).*exp(-2*pi.*((t-6.41e-9)/pw).^2)+ ...
B*(1-4*pi.*((t-12.82e-9)/pw).^2).*exp(-2*pi.*((t-12.82e-9)/pw).^2)+ ...
B*(1-4*pi.*((t-19.23e-9)/pw).^2).*exp(-2*pi.*((t-19.23e-9)/pw).^2)+ ...
B*(1-4*pi.*((t-25.64e-9)/pw).^2).*exp(-2*pi.*((t-25.64e-9)/pw).^2);
ym=yp+noise;%BPSK modulated doublet with noise
yc=ym.*yum;%yc(correlated output)=ym(modulated)times yum(unmodulated) doublet.
%This is where the correlation occurs in the receiver and would be the
%mixer in the receiver.
%==================================================
% FFT
%==================================================
%new FFT for BPSK modulated doublet(ym)
NFFYM=2.^(ceil(log(length(ym))/log(2)));
FFTYM=fft(ym,NFFYM);%pad with zeros
NumUniquePts=ceil((NFFYM+1)/2);
FFTYM=FFTYM(1:NumUniquePts);
MYM=abs(FFTYM);
MYM=MYM*2;
MYM(1)=MYM(1)/2;
MYM(length(MYM))=MYM(length(MYM))/2;
MYM=MYM/length(ym);
f=(0:NumUniquePts-1)*2*Fn/NFFYM;
%new FFT for unmodulated doublet(yum)
NFFYUM=2.^(ceil(log(length(yum))/log(2)));
FFTYUM=fft(yum,NFFYUM);%pad with zeros
NumUniquePts=ceil((NFFYUM+1)/2);
FFTYUM=FFTYUM(1:NumUniquePts);
MYUM=abs(FFTYUM);
MYUM=MYUM*2;
MYUM(1)=MYUM(1)/2;
MYUM(length(MYUM))=MYUM(length(MYUM))/2;
MYUM=MYUM/length(yum);
f=(0:NumUniquePts-1)*2*Fn/NFFYUM;
%new FFT for correlated pulses(yc)
%yc is the time domain signal output of the multiplier
%(modulated times unmodulated) in the correlation receiver. Plots
%in the time domain show that a simple comparator instead of high speed A/D's
%may be used to recover the 10101 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 modulated doublet(ym)
figure(1)
subplot(2,2,1); plot(t,ym);xlabel('TIME');ylabel('AMPLITUDE');
title('Modulated pulse train');
grid on;
%axis([-1e-9,27e-9 -1 2])
subplot(2,2,2); plot(f,MYM);xlabel('FREQUENCY');ylabel('AMPLITUDE');
%axis([0 10e9 0 .1]);%zoom in/out
grid on;
subplot(2,2,3); plot(f,20*log10(MYM));xlabel('FREQUENCY');ylabel('20LOG10=DB');
%axis([0 20e9 -120 0]);
grid on;
%plots for unmodulated doublet(yum)
figure(2)
sub