You are on page 1of 18

ESPTR PROJECT 2(T)

FINAL REPORT

TOPIC: MULTIPLE ACCESS OF CDMA FOR TWO USERS IN ADDITIVE WHITE GAUSSIAN NOISE.

By: AJAKUMBI BABA USMAN INDEX: 210760

JUNE 2011

INTRODUCTION:
CDMA known as the code division multiple access, is a channel method access that is used by different radio communication technologies. CDMA uses spread spectrum technology, and also a special coding scheme. This coding scheme is the one by which the transmitter is assigned a code, to allow multiple users to be multiplexed over the same physical channel of homogeneity. In other words, CDMA is a form of spread spectrum signaling because of the modulated code, the signal has a much higher bandwidth than the data that was communicated.

SREAD SPECTRUM COMMUNICATION IN CDMA:


CDMA is a form of Direct Sequence Spread Spectrum (DSSS) communication. In general, spread spectrum communication differs in three ways; Signal occupies a bandwidth much greater than that which is needed to send pieces of information via a carrier. This results to merits such as immunity to interference and jamming, and multi user access. The bandwidth is spread by means of a code that does not rely on the data. The independence of the code makes it different from standard modulation schemes, whereby the data modulation will always spread the spectrum. The receiver does not synchronize the code to recover the data. The use of an independent code and synchronous reception allows multiple users to access the same frequency band at the same time.

For the signal to be protected, we use a pseudo-random code. It is actually deterministic, because the receiver can reconstruct the code for synchronous detection. Pseudo-Random is also known as Pseudo-Noise (PN).

There are three ways to spread the signal bandwidth in CDMA; Frequency hopping: Signal is switched between different frequencies within the hopping bandwidth in pseudo-random manner, and the receiver predicts where to find the signal any time. Time hopping: Signal is transmitted in short pseudo-random bursts. The receiver knows when to expect the signals.

Direct sequence: The Digital data is directly coded at almost more higher frequency. The code is generated pseudo randomly, and receiver knows how to generate the same code, and correlates the code with the received signal.

ALGORITHM:
The algorithm that realizes the multiple access of CDMA in additive white Gaussian Noise is shown according to the following steps. Matlab Function CDMA (); it will accept augments; 2 Users and SNR in Decibel. Conversion of Binary sequence of each user to non-return-to-zero format.(NRZ). Codes for the CDMA transmitter and baseband for each of the users. Codes for PN generation of the users. Codes for creating BPSK modulation for each of the user. Plot to observe the FFT of BPSK sequence for each of the user. Codes for actualizing the AWGN channel. Codes for actualizing the Demodulation of the users sequences. Codes for Demodulating the BPSK sequence of each of the users.

Code and results of Testing:


The matlab code is shown below, and the plots.
function cdmamodem(user1,user2,snr_in_dbs) % >>>multiple access between 2 users using DS CDMA % >>>format is : cdmamodem(user1,user2,snr_in_dbs) % >>>user1 and user2 are vectors and they should be of equal length % user1=[1 0 1 0 1 0 1] , user2=[1 1 0 0 0 1 1],snr_in_dbs=-50 % >>>or snr_in_dbs=50 we can use any number close all %user1=[1 0 0 1 1 0] %user2=[1 1 0 1 0 0] %% to convert the binary sequences to bipolar NRZ format length_user1=length(user1); length_user2=length(user2);

for i=1:length_user1 if user1(i)==0 user1(i)=-1; end end for i=1:length_user2 if user2(i)==0 user2(i)=-1; end end fc=1; %%carrier frequency eb=2; %% energy per bit tb=1; %% time per bit of message sequence %%% CDMA transmitter for user1 t=0.01:0.01:tb*length_user1; %0.01 %%plotting base band signal for user1 basebandsig1=[]; for i=1:length_user1 for j=0.01:0.01:tb%0.01 if user1(i)==1 basebandsig1=[basebandsig1 1]; else basebandsig1=[basebandsig1 -1]; end end end figure plot(basebandsig1) axis([0 100*length_user1 -1.5 1.5]); title('original binary sequence for user1') %%%% BPSK MODULATION FOR USER 1 bpskmod1=[]; for i=1:length_user1 for j=0.01:0.01:tb bpskmod1=[bpskmod1 sqrt(2*eb)*user1(i)*cos(2*pi*fc*j)]; end end length(bpskmod1) figure plot(bpskmod1) %axis([0 100*length_user1 -2 2]); title(' BPSK signal for user 1 ') %% plot fft of BPSK sequence % figure % plot(real(fft(bpskmod1))) % title('FFT of BPSK signal for user1') %% PN generator for user1 %% let initial seed for user1 is 1000

seed1=[1 -1 1 -1]; %convert it into bipolar NRZ format spreadspectrum1=[]; pn1=[]; for i=1:length_user1 for j=1:10 %chip rate is 10 times the bit rate pn1=[pn1 seed1(4)]; if seed1 (4)==seed1(3) temp=-1; else temp=1; end seed1(4)=seed1(3); seed1(3)=seed1(2); seed1(2)=seed1(1); seed1(1)=temp; end % spreadspectrum1=[spreadspectrum1 user1(i)*pn1]; end % each bit has 100 samples. and each pn chip has 10 samples. there r % 10 chip per bit there fore size of pn samples and original bit is same pnupsampled1=[]; len_pn1=length(pn1); for i=1:len_pn1 for j=0.1:0.1:tb if pn1(i)==1 pnupsampled1=[pnupsampled1 1]; else pnupsampled1=[pnupsampled1 -1]; end end end length_pnupsampled1=length(pnupsampled1); sigtx1=bpskmod1.*pnupsampled1; figure plot(sigtx1) %axis([0 100*length_user1 -2 2]); title(' spread spectrum signal transmitted for user 1 ') %% plot fft of BPSK sequence figure plot(real(fft(sigtx1))) title('FFT of spread spectrum signal transmitted for user1') % % % % % rxcode1=pnupsampled1.*sigtx1; figure plot(rxcode1) %axis([0 100*length_user1 -2 2]); title(' spread spectrum signal transmitted for user 1')

% CDMA transmitter for user2 t=0.01:0.01:tb*length_user2; %0.01 %plotting base band signal for user2

basebandsig2=[]; for i=1:length_user2 for j=0.01:0.01:tb%0.01 if user2(i)==1 basebandsig2=[basebandsig2 1]; else basebandsig2=[basebandsig2 -1]; end end end figure plot(basebandsig2) axis([0 100*length_user2 -1.5 1.5]); title('original binary sequence for user2') % BPSK MODULATION FOR USER 2 bpskmod2=[]; for i=1:length_user2 for j=0.01:0.01:tb bpskmod2=[bpskmod2 sqrt(2*eb)*user2(i)*cos(2*pi*fc*j)]; end end figure plot(bpskmod2) %axis([0 100*length_user2 -2 2]); title(' BPSK signal for user 2') %% plot fft of BPSK sequence % figure % plot(real(fft(bpskmod2))) % title('FFT of BPSK signal for user2') %% PN generator for user2 %% let initial seed for user2 is 1000 seed2=[-1 1 -1 1]; %convert it into bipolar NRZ format spreadspectrum2=[]; pn2=[]; for i=1:length_user2 for j=1:10 %chip rate is 10 times the bit rate pn2=[pn2 seed2(4)]; if seed2 (4)==seed2(3) temp=-1; else temp=1; end seed2(4)=seed2(3); seed2(3)=seed2(2); seed2(2)=seed2(1); seed2(1)=temp; end % spreadspectrum2=[spreadspectrum2 user2(i)*pn2]; end pnupsampled2=[]; len_pn2=length(pn2); for i=1:len_pn2 for j=0.1:0.1:tb

if pn2(i)==1 pnupsampled2=[pnupsampled2 1]; else pnupsampled2=[pnupsampled2 -1]; end end end length_pnupsampled2=length(pnupsampled2); sigtx2=bpskmod2.*pnupsampled2; figure plot(sigtx2) %axis([0 100*length_user2 -2 2]); title(' spread spectrum signal transmitted for user 2 ') %% plot fft of BPSK sequence figure plot(real(fft(sigtx2))) title('FFT of spread spectrum signal transmitted for user2') % % % % % rxcode2=pnupsampled2.*sigtx2; figure plot(rxcode2) %axis([0 100*length_user2 -2 2]); title(' spread spectrum signal transmitted for user 2 ')

%signal by adding the above 2 signals composite_signal=sigtx1+sigtx2; %AWGN CHANNEL composite_signal=awgn(composite_signal,snr_in_dbs);

%% SNR of % dbs

%DMODULATION FOR USER 1 rx1=composite_signal.*pnupsampled1; figure plot(rx1) title(' rx1 ') % BPSK DEMODULATION FOR USER 1 demodcar1=[]; for i=1:length_user1 for j=0.01:0.01:tb demodcar1=[demodcar1 sqrt(2*eb)*cos(2*pi*fc*j)]; end end bpskdemod1=rx1.*demodcar1; figure plot(bpskdemod1) title('o/p of bpsk demod for user 1 ') len_dmod1=length(bpskdemod1); sum=zeros(1,len_dmod1/100); for i=1:len_dmod1/100 for j=(i-1)*100+1:i*100 sum(i)=sum(i)+bpskdemod1(j);

end end sum; rxbits1=[]; for i=1:length_user1 if sum(i)>0 rxbits1=[rxbits1 1]; else rxbits1=[rxbits1 0]; end end rxbits1 %DMODULATION FOR USER 2 rx2=composite_signal.*pnupsampled2; figure plot(rx2) title(' rx2 ') % BPSK DEMODULATION FOR USER 2 demodcar2=[]; for i=1:length_user2 for j=0.01:0.01:tb demodcar2=[demodcar2 sqrt(2*eb)*cos(2*pi*fc*j)]; end end bpskdemod2=rx2.*demodcar2; figure plot(bpskdemod2) title('o/p of bpsk demod for user 2 ') len_dmod2=length(bpskdemod2); sum=zeros(1,len_dmod1/100); for i=1:len_dmod2/100 for j=(i-1)*100+1:i*100 sum(i)=sum(i)+bpskdemod2(j); end end sum; rxbits2=[]; for i=1:length_user2 if sum(i)>0 rxbits2=[rxbits2 1]; else rxbits2=[rxbits2 0]; end end rxbits2

original binary sequence for user1 1.5

0.5

-0.5

-1

-1.5

10

20

30

40

50

60

70

80

90

100

Fig 1: Original binary sequence for the 1st user.


2.5 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2 -2.5 x 10
5

BPSK signal for user 1

10

20

30

40

50

60

70

80

90

100

Fig 2: Plot showing the BPSK signal for the 1st user.
2 1.5 1 0.5 0 -0.5 -1 -1.5 -2 -2.5 x 10
5

spread spectrum signal transmitted for user 1

10

20

30

40

50

60

70

80

90

100

Fig 3: Plot of the transmitted signal for the 1st user.

x 10

FFT of spread spectrum signal transmitted for user1

-2

-4

-6

-8

-10

10

20

30

40

50

60

70

80

90

100

Fig 4: Plot of FFT of spread spectrum of transmitted signal for the 1st user.
original binary sequence for user2 1.5

0.5

-0.5

-1

-1.5

10

20

30

40

50

60

70

80

90

100

Fig 5: Original Binary sequence for the 2nd user.


2.5 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2 -2.5 x 10
5

BPSK signal for user 2

10

20

30

40

50

60

70

80

90

100

Fig 6: Plot of BPSK signal for 2nd user.

2.5 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2 -2.5

x 10

spread spectrum signal transmitted for user 2

10

20

30

40

50

60

70

80

90

100

Fig 7:Plot of the spread spectrum of the transmitted signal for 2nd user.

x 10

FFT of spread spectrum signal transmitted for user2

-2

-4

-6

-8

10

20

30

40

50

60

70

80

90

100

Fig 8: Plot of FFT of the spread spectrum signal transmitted for the 2nd user.

5 4 3 2 1 0 -1 -2 -3 -4 -5

x 10

rx1

10

20

30

40

50

60

70

80

90

100

Fig 9: Plot of rx1

9 8 7 6 5 4 3 2 1 0 -1

x 10

o/p of bpsk demod for user 1 is

10

20

30

40

50

60

70

80

90

100

Fig 10: The output of BPSK for the 1st User


5 4 3 2 1 0 -1 -2 -3 -4 -5 x 10
5

rx2

10

20

30

40

50

60

70

80

90

100

Fig 11: Plot of rx2


x 10
5

o/p of bpsk demod for user 2

9 8 7 6 5 4 3 2 1 0 -1

10

20

30

40

50

60

70

80

90

100

Fig 12: The output BPSK demodulation for the 2nd user.

You might also like