my undergraduate thesis

85
i BER PERFORMANCE COMPARISON OF WALSH-HADAMARD CODE AND GOLD CODE IN DS-CDMA COMMUNICATION. SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR AN AWARD OF BACHELOR OF SCIENCE (BSc) DEGREE IN ELECTRONIC & ELECTRICAL ENGINEERING BOJESOMO ALABI SAKIRUDEEN EEG/2006/048 JANUARY 2012

Upload: bojesomo-sakirudeen

Post on 24-Jan-2015

1.511 views

Category:

Education


1 download

DESCRIPTION

My undergraduate thesis titled "BER comparison of walsh-hadamard code and gold code in DS-CDMA communication"

TRANSCRIPT

Page 1: My Undergraduate Thesis

i

BER PERFORMANCE COMPARISON

OF WALSH-HADAMARD CODE AND GOLD CODE

IN DS-CDMA COMMUNICATION.

SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR AN AWARD OF

BACHELOR OF SCIENCE (BSc) DEGREE IN ELECTRONIC & ELECTRICAL ENGINEERING

BOJESOMO ALABI SAKIRUDEEN EEG/2006/048

JANUARY 2012

Page 2: My Undergraduate Thesis

ii

CERTIFICATION

I hereby certify that the content of this report is a representation of the work done by BOJESOMO

Alabi Sakirudeen in partial fulfillment of the requirements for the degree of Bachelor of Science

under my supervision in the Department of Electronic and Electrical Engineering of the Obafemi

Awolowo University, Ile-Ife.

________________________ _______________________

Mr. A. A. Fisusi DATE

SUPERVISOR

Page 3: My Undergraduate Thesis

iii

DEDICATION

This concise report is dedicated to ALLAH (Subuhana Watahala) for HIS infinite mercy

and my parents for their support towards the realization of the program.

Page 4: My Undergraduate Thesis

iv

ACKNOWLEDGEMENT

I set out to learn and my thirst for knowledge was quenched by the help of people of

substance whose effort cannot be fully appreciated by the words of mouth.It gives me

immense pleasure to express my deep sense of gratitude to my supervisor Mr Abimbola

Fisusi for his invaluable guidance, motivation, constant inspiration and above all his ever

co-operating attitude enabled me in bringing up this thesis in the present elegant form.

I am extremely thankful to Prof. O. Osasona, Head, Department of Electronic &

Electrical Engineering and all members of Electronic & Electrical Engineering

Department for providing all kinds of possible help and advice during the course of this

work.

It is a great pleasure for me to acknowledge and express my gratitude to my parent for

their understanding, untainted support and endless encouragement during my study.

I am greatly thankful to all the staff members of the department and all my well wishers,

classmates and friends for their inspiration and help.

My special thank also goes to my project partner, Popoola Ebenezer ;who through his

contribution made this research a reality.

Lastly I sincerely thank all those who have directly or indirectly helped me with the work

reported herein.

Page 5: My Undergraduate Thesis

v

Table of Content Title page

i

Certification

ii Dedication

iii

Aknowledgement

iv Table of Content

v

List of Acronym

vi List of Figure

vii

List of Table

viii List of Plate

ix

Abstract

x

Chapter 1 INTRODUCTION 1

1.1 Background 1

1.2 Objectives of Study 2

1.3 Scope of Study 2

Chapter 2 LITERATURE REVIEW 3 2.1 Spread Spectrum 3 2.2 Direct Sequence Spread Spectrum 8 2.3 Spreading Codes 10 2.3.1 Pseudonoise Sequence 12 2.3.1.1 Properties of M-sequences 13 2.3.2 Gold Sequences (Codes) 14 2.3.3 Walsh codes 16 2.4 Channel Impairment 18

2.5 Bit Error Rate(BER) Performance 19

Chapter 3 METHODOLOGY 22 3.1 Message Generation 22

3.2 Spreading Sequence Generation and Spreading 22

3.2.1 Gold Sequence Generation 22 3.2.1.1 M-Sequences 22 3.2.2 Walsh Code Generation 27 3.3 Modulation and Channel Modeling 29 3.4 Receiver Modeling 29 3.5 Correlation Properties 31

Chapter 4 RESULTS 32 4.1 Correlation Analysis 32 4.2 BER Performance Analysis 32 4.3 Challenges Encountered 42

Chapter 5 CONCLUSION 43

Page 6: My Undergraduate Thesis

vi

Reference

45 Appendix Matlab Codes used in the report 48

Page 7: My Undergraduate Thesis

vii

List of Acronyms

BER Bit Error Rate

BPSK Binary Phase Shift Keying

CDMA Code Division Multiple Access

DS-CDMA Discrete Sequence Code Division Multiple Access

DS-SS Direct Sequence Spread Spectrum

FDMA Frequency Division Multiple Access

GMSK Gussian Minimum Shift Keying

GP Processing Gain

GUI Graphic User Interface

ICI Inter Channel Interference

LPD Low Probability of Detection

LPI Low Probability of Intercept

LPPF Low Probability of Position Fix

LPSE Low Probability of Signal Exploitation

ML Maximal-length

MUI Multi User Interference

PN Pseudonoise

PTP Point to Point

QPSK Quadrature Phase Shift Keying

SNR Signal to Noise Ratio

SS Spread Spectrum

TDMA Time Division Multiple Access

WGN White Guassian Noise

Page 8: My Undergraduate Thesis

viii

List of Figures

Fig 2.1 General Model of Spread Spectrum Digital Communication System

Fig:2.2 Transmitter and receiver model of CDMA system

Fig 2.3 Generation of a Gold Code set

Fig 3.1 message sequence of length 20

Fig 3.2 Gold code generation shift register implementation.

Fig 3.3 Gold code simulation output

Fig 3.4 walsh code simulation output

Fig 3.5 Block diagram of a Coherent BPSK demodulator

Fig 4.1 Correlation Properties of Walsh and Gold Codes

Fig 4.2 Performance of Gold Codes over AWGN Channel

Fig 4.3 Performance of Walsh Codes over AWGN Channel

Fig 4.4 Performance of Gold and Walsh Codes over AWGN Channel

Fig 4.5 Performance of Gold Codes over Rayleigh Channel

Fig 4.6 Performance of Walsh Codes over Rayleigh Channel

Fig 4.7 Performance of Gold and Walsh Codes over Rayleigh Channel

Fig 4.8 Multi-user Gold and Walsh Code over AWGN Channel

Fig 4.9 Multi-user Gold and Walsh Code over Rayleigh Channel

Page 9: My Undergraduate Thesis

ix

List of Tables

Table 2.1 Table of m_sequences for various shift register stage

Page 10: My Undergraduate Thesis

x

List of Plates

Plate A.1 Message sequence generation

Plate A.2 Gold Code Generation

Plate A.3 M_Sequence Calculating Function

Plate A.4 Walsh code generating function

Plate A.5 Walsh Code generating Script

Plate A.6 Correlation Properties of Spreading Codes

Plate A.7 BER Performance over AWGN Channel

Plate A.8 Multi-User BER Performance over AWGN Channel

Plate A.9 BER Performance over Rayleigh Channel

Plate A.10 Multi-User BER Performance over Rayleigh Channel

Page 11: My Undergraduate Thesis

xi

ABSTRACT

Code Division Multiple Access CDMA is a technology for digital transmission of radio signal in

telecommunication systems. In this technology, multiple users can transmit their data

simultaneously over a channel using same bandwidth. Each user is assigned a unique code for

transmission. There are different codes used for this purpose. The types of code used include

PN(Pseudonoise) sequence, Gold sequence and Walsh code generated using Matlab

Programming. Using Walsh code or Gold code, data was transmitted to receiver over Additive

White Guassian Noise (AWGN) and Fading channels. Here, transmitted data is generated

randomly using Matlab function. During transmission, modulation is done for both codes for

single user and multi users over AWGN and/or Multipath(frequency selective) channel .

Various spreading codes has been simulated for a digital communication system over AWGN

and Multipath Fading Channnel. Evaluation of m-sequences obtainable from a given number of

shift register stage and correlation of the sequences compared using matlab simulation. Bit error

rate (BER) performance of both codes(Gold and Walsh) considered over AWGN as well as

Rayleigh Channel.

Page 12: My Undergraduate Thesis

1

CHAPTER 1

INTRODUCTION

1.1 Background

Wireless personal communications has grown over the last few years and the method of

communication known as spread spectrum has gained a great deal of prominence. Spread spectrum

involves spreading the desired signal over a bandwidth much larger than the minimum bandwidth

necessary to send the signal. It was originally developed by the military as a method of

communications that is less sensitive to intentional interference or jamming by third parties, but has

become very popular in the realm of personal communications recently. Also, as technology

advances the security system of wireless communication need to be upgraded to avoid unintended

reception, hence spread spectrum techniques can be utilized in Code Division Multiple Access

(CDMA) to create multi-user communications systems with very good security of information. The

idea behind spread spectrum is that individual pseudorandom codes called user signatures are

generated at the transmitter for each user with which his/her message is spreaded in other to reduce

the effect of multipath and multi-user/ multi-access interference (MAI). The length of the user

signature strongly determines the level of security of the message signal, the longer the better.

This report will cover the details behind the method of Spread Spectrum communications, as well

as analyze two main types of coding systems used in Direct-Sequence Spread Spectrum (DS-SS),

Gold code and Walsh-Hadamard code in terms of their interference, jamming and bit error rate

performances.

Page 13: My Undergraduate Thesis

2

1.2 Objective of Study

The aim of this report is to give a general comparison between the bit error rate performance of

Gold code and Walsh-Hadamard coding system in Direct Sequence Code Division Multiple Access

Technique over additive white Gaussian noise (AWGN) channel and multipath fading channels.

1.3 Scope of Study

This report intends to give an appreciable light on DS-CDMA technology, its importance in

telecommunication and its advantages. Also, it will discuss spread spectrum, two methods of coding

which are Gold code and Walsh-Hadamard code: how they are generated both theoretically and

using Matlab programming language. Most importantly, this will lead to a comparison in the bit

error rate performance of the two coding technique taking into consideration the various source of

channel impairment from the environment such as Gaussian white noise, jamming, interference

and also multipath fading .

Page 14: My Undergraduate Thesis

3

CHAPTER 2

LITERATURE REVIEW

Soren(2010) studies various Spread Spectrum coding techniques in terms of their usage, generation

and resistance to jamming and interference. The study includes the effect of AWGN and Fading

channel with the simulated result of the Bit Error Rate Vs SNR done using Matlab(theoretical). The

results of the work indicate that after certain SNR, the bit error rate becomes zero. The BERTool, a

simulink model in Matlab is used to analyze the BER of various coding techniques with soft or hard

decoding. Result of this tool is majorly a theoretical result using the various theoretical expressions

relating the BER with other parameters of interest. Prapeep and Baskhar(2010) studied the

performance of a wideband CDMA system in the presence of Lognormal fading . The wideband

CDMA system, modeled using Gaussian Approximation is analyzed on a slow fading Lognormal

channel and simulated results are obtained for Bit Error Rate (BER) versus signal-to-noise ratio

(SNR in dB) for a fixed value of channel. Bellcore(1996) describe a number of important multi user

detectors for DS-CDMA . The article discuss the conventional DS-CDMA single user detector,

accounting for the need for multiuser detectors such as linear detectors, and Minimum Mean-

Squared Error (MMSE) Detector to combat the effect of multiple access interference.

2.1 Spread Spectrum

Spread spectrum (SS) techniques are methods in which energy generated at a single frequency is

spread over a wide band of frequencies. This is done to achieve transmission that is robust against

channel impairments, and to be able to resist natural interference or jamming and to prevent hostile

detection. These techniques were developed by military guidance and communication systems. The

Page 15: My Undergraduate Thesis

4

techniques are said to be spread spectrum if transmission bandwidth is much greater than minimum

bandwidth needed to transmit information. A system could achieve spread spectrum if it fulfills the

following requirements:

Signal occupies bandwidth much in excess of the minimum bandwidth necessary to send

information.

Spreading is accomplished by means of spreading code signal which is independent of the

data.

At the receiver, de-spreading is accomplished by the correlation of the received spread

signal with a synchronized replica of the spreading signal used to spread information.

The SS signal is able to resist interference and jamming. The interference rejection capability of

spread spectrum is achieved by:

Multiplying signal by spreading signal which spreads the signal bandwidth.

Multiplying signal by spreading signal twice recovers original signal.

Desired signal gets multiplied twice and interference gets multiplied only once, and that

helps in signal recovering as the noise and information would not be at the same

frequencies.

The increase in bandwidth above the minimum bandwidth in a spread spectrum system can be

thought of as applying gain to the desired signal with respect to the undesirable signals (Proakis,

2001). This is called the processing gain GP defined as

Where BWRF is the bandwidth that the signal has been increased, and BWinfo is the minimum

bandwidth necessary to transmit the information or data signal. Processing gain can be thought of as

2.1

Page 16: My Undergraduate Thesis

5

the improvement over conventional communication schemes due to the spreading done on the

signal.

Often, a better measure of this gain is given by the jamming margin,

MJ(dB)=GP(dB)– SNRmin

Which indicates the amount of interference protection offered before the signal is corrupted. Figure

2.1 highlight the key characteristics of any spread spectrum system.

Spread spectrum techniques are implemented where transmission has to be operated without

information being detected by anyone other than the intended receiver. Communications systems

designed for this task are known as low probability of detection ( LPD ) or low probability of

intercept filter (LPI). SS systems that are designed to present LPI may also be designed to expose

low probability of position fix (LPPF), thus even if the presence of the signal may be perceived,

direction of the transmitter is difficult to pinpoint. They can further be made to expose low

probability of signal exploitation (LPSE), meaning that identification of source is difficult to

determine. The goal of these systems is to use minimum signal power and optimum signaling

scheme that results in minimum probability of being detected, intercepted or demodulated. SS uses

wideband, noise-like signals and because the signals are noise-like, they are hard to detect. Further,

Spread Spectrum signals are harder to jam than narrowband signals (Soren, 2010).

Spread spectrum techniques use code signal to perform spreading and de-spreading, and these

spreading code signals are called pseudorandom or pseudo noise codes. They are called

pseudorandom because they are not random at all; they are deterministic periodic signals that are

known to both transmitter and receiver. Though these signals are said to be deterministic, they hold

randomness properties and they appear random to unauthorized users. The spreading function is

achieved through the use of a pseudorandom noise sequence (PN sequence).

2.2

Page 17: My Undergraduate Thesis

6

Fig 2.1 General Model of Spread Spectrum Digital Communication System

Channel

encoder

e

ee

Modulator Input

data

Pseudonoise

generator

Channel De-

modulator

Pseudonoise

generator

Channel

decoder

Output

data

Page 18: My Undergraduate Thesis

7

The data signal is combined with the PN sequence such that each data bit is encoded with several if

not all the bits in the PN sequence. In order to achieve the same data rate as was desired before

spreading, the new data must be sent at a rate equal to the original rate multiplied by the number of

PN sequence bits used to encode each bit of data. This increase in bandwidth is the processing gain,

which is a measure of the noise and interference immunity of this method of transmission. The

three major types of interference that can arise when using wireless networks are:

1. Noise,

2. Intentional interference from a jammer(Garg, 2007) or other source trying to disrupt

Communication.

3. Unintentional interference from other users of the same frequency band.

Noise can be considered as background white Gaussian noise (WGN), and can be said to have

constant power spectral density. Since the noise is white, the spreading of the bandwidth does not

have much of an effect here. The noise power is constant over the entire bandwidth, so increasing

the bandwidth actually lets more noise into the system, which might be seen as detrimental.

However, this is not really a problem because only the wanted signal is spreaded twice which needs

to being unspread while the noise will be spread at the receiver reducing the captured noise only a

section within the filter bandwidth.

Intentional interference comes from sources who are actively trying to corrupt the data

transmission by sending power transmissions in the same band as the intended transmission. The

big difference between intentional interference and noise is that intentional interference is, by its

very nature, a finite power signal, since it must be transmitted from a real source. Thus the

spreading performed on the data signal allows the signal to “hide” itself in a larger bandwidth,

Page 19: My Undergraduate Thesis

8

forcing the jamming signal to distribute its power over this new much larger bandwidth, and thus

intuitively diminishing the effect that the jamming signal has on the data signal.

The third major source of signal corruption comes from unintentional interference due to other

users using the same frequency band, and here, the system uses the PN sequence and spread

spectrum technique of CDMA to combat this type of interference. In a wireless communications

network, all the signals propagate through the air by way of electromagnetic waves, thus there is no

way to ensure that one user will receive only the signal he or she desires; that user will receive all

the signals being sent in that band. By giving each of the signals to be transmitted in the frequency

band its own code (CDMA), the effect of these other signals can be reduce at the receiver (when the

receiver correlates the input signal it receives with the code of the transmission it wants to receive,

only the desired signal will Remain).

Spread spectrum techniques can be classified into three main categories namely

Direct sequence spread spectrum

Frequency hopping spread spectrum and

Time hopping spread spectrum and the combination of two or the three techniques.

2.2 Direct Sequence Spread Spectrum

Direct sequence spread spectrum is a technique used in CDMA where each bit of the original signal

is represented by multiple bits in the transmitted signal, using a spreading code.

Direct sequence (DS) CDMA is used in the third-generation mobile communication standard to

provide high capacity and high transmission rate over conventional schemes such as frequency

division multiple access and time-division multiple access. However, due to inherent wide

bandwidth of the spread spectrum systems, severe frequency selective fading degrades system

Page 20: My Undergraduate Thesis

9

performances. When transmitting data in the downlink, DS-CDMA relies on the low or zero

correlation between the spreading codes to separate the different user signals. However, it suffers

from inter channel interference (ICI) which destroys the orthogonality among users, giving rise to

Multi User Interference (MUI) (Sadara and Bikash, 2009) which limits the capacity of the system

(Selvi and Ramar, 2009). Since the multi user interference is in actual fact caused by the multipath

channel, it can be suppress by linear chip level equalization, followed by correlation with the user‟s

spreading code (Soren, 2010). At the transmitter, the information is encoded using codes. The

encoded information is then transformed into a data modulated symbol sequence with a baseband

modulator. The modulated symbol sequence is spread in time domain by a chip sequence of

orthogonal code generator, usually Walsh code or PN sequence. The information is shaped and

passed through a transmitter for transmission.

At the receiver, the information is multiplied with the chip sequence by the correlators in the rake

receiver. The information is then summed and multiplied by locally generated spreading code. The

information is demodulated and decoded and original data can be recovered. In practice, BPSK

modulation scheme is used which can be represented as follows,

A d(t) cos(2 )

Where

A=amplitude of signal

fc = carrier frequency

d(t)=the discrete function that takes on the values +1 for one bit time if the corresponding bit stream

is 1 and the value -1 for one bit time if the corresponding bit in the bit stream is 0.

2.3

Page 21: My Undergraduate Thesis

10

To produce the DSSS signal, we multiply the BPSK signal in (2.3) by c(t) which is the PN sequence

taking on the values of +1 and -1.

At the receiver, PN sequence is multiplied with the received waveform to recover the exact

transmitted wave.

Now, if we allow both noise and a jamming signal sj(t) with finite power distributed evenly across

the frequency band, the received signal at the input to the receiver, Y(t), is

Where n(t) represent additive white noise.

Now, when the signal is correlated with the PN sequence, the data signal portion of y(t) is de-

spread giving us the original d(t). However, the effect of multiplying sj(t) and n(t) with the signal in

effect spreads the signal out to have bandwidth fc, whereas the signal d(t) now has returned to its

original frequency. So a filter following the signal correlation can recapture the signal d(t) with a

reduced amount of jamming power. The jamming power that can pass through the filter is now

decreased by a factor fc/f, which was introduced earlier as the processing gain Gp, i.e.

Gp=(BWRF/BWinfo)=(fc/f).

2.3 Spreading Codes

In DS-CDMA system, for de-spreading operation, the received data should be multiplied with the

same code in the receiver. So the other user codes in the same frequency band must be uncorrelated

2.4

2.6

2.5

Page 22: My Undergraduate Thesis

11

Transmitter Model:

Receiver Model:

Fig:2.2. Transmitter and receiver model of CDMA system

Channel

coding

Data

modulation

Chip

Shaping

data

Time domain spreading

Page 23: My Undergraduate Thesis

12

with the desired user code. For this reason the DS-CDMA codes have to be designed so as to posses

very low cross-correlation (Rusyn and Riley, 2010; Selvi and Ramar, 2009; Sivanesskumar and

Sukanesh, 2009).

Autocorrelation shows the measure of similarity between the code and its cyclic shifted copy.

Because of this reason, the codes that have the best properties of autocorrelation have frequently

been used in communication systems (Kandar and Sarkar, 2009). The auto-correlation function can

be expressed as below

Cross-correlation is the measure of similarity between two different codes. In other words cross-

correlation describes the interference between codes An and Bn .

Where an and bn are the elements of two different codes and have period N (Dinan and Jabbari,

1998).

2.3.1 Pseudonoise (PN) Sequence

A PN sequence is a periodic binary sequence of 1‟s and 0‟s. It has some characteristics that are

similar to random binary sequences (having equal # of 0‟s and 1‟s), very low correlation between

any two shifted version of the sequence and low cross-correlation between any two sequences.

Pseudo-random sequence is not random (deterministic) but it looks randomly for the user who

doesn‟t know the code.

2.7

2.8

Page 24: My Undergraduate Thesis

13

PN sequence is generated by a feedback shift register regulated by a single timing clock. Binary

sequences are shifted through the shift registers and the output of the various stages are logically

combined and feedback as the input to the first stage.

When the feedback logic consists of exclusive-OR gates, the shift register is called a linear and in

such a case, the zero state is not permitted. Therefore the period of a PN sequence produced by a

linear m-stage shift register cannot exceed N= 2m – 1. When a sequence of period 2

m -1 generated,

it is called a maximal-length (ML) sequence. For a given stage shift register, the number of possible

m-sequences is given by

Where (N) is the Euler totient function which represents the number of integers less than N which

are relatively prime (pk) to it (Dinan and Jabbari, 1998; Utlaut 1978). Below is a table of m-

sequences for some shift register stages.

2.3.1.1 Properties of M-sequences

1 Balance Property: An m-sequence has 2m-1

ones and 2m-1

-1 zeros.

2 Run Property: Here, the 'run' represents a subsequence of identical symbols (1's or 0's) within

one period of the sequence. The length of this subsequence is the length of the run. Among the

runs of 1's and 0's in each period of a maximum-length sequence, one half the run of each kind

are of length one, one-fourth are length two, one-eighth are of length three, etc. For a

2.9

2.10

Page 25: My Undergraduate Thesis

14

maximum-length sequence generated by a linear feedback shift register of length m, the total

number of runs is (N+1)/2 where N=2m-1.

3 Correlation Property: The periodic autocorrelation of a +1 m-sequence is

R( ) = 1 =0 mod(N)

Otherwise

Welch (1974) obtained the following lower bound on the cross-correlation between any pair of

binary sequences of period N in a set of M sequences as

2.3.2 Gold Sequences (Codes)

Gold codes can be generated by modulo-2 addition of two maximum-length sequences with the

same length. The code sequences are added chip by chip by synchronous clocking with the

generated code having the same length as the m-sequences which are added together.

Consider an m-sequence represented by a binary vector a of length N, and a second sequence a’

obtained by sampling every qth symbol of a. the second sequence is called the decimation of the

first and denoted by a’=a[q] . a’=a[q] will has period N (m-sequence) if and only if gcd (N,q)=1,

where „gcd‟ denotes the greatest common divisor. Any pair of m-sequence having the same length

N and can be related by a’=a[q] for some q are called preferred pair obeying the following

conditions.

1. N ≠ 0 (mod4)

2. q is odd and either q=2k + 1 or q=2

2k – 2

k + 1

3.

e

e

e

2.11

Page 26: My Undergraduate Thesis

15

Table 2.1: Table of m_sequences for various shift register stage

Number of shift register stages Sequence length N Number of m-sequences

2 3 1

3 7 2

4 15 2

5 31 6

6 63 6

7 127 18

8 255 16

9 511 48

10 1023 60

Page 27: My Undergraduate Thesis

16

The set of Gold codes for this preferred pair of m-sequence is defined by

{a,a’,a+a’,a+Da’,a+D2a’, … ,a+D

N-1 a’} where D is the delay element. An illustration of

generating a Gold set is shown in figure 2.3.

The N+1 elements of a Gold codes sets have the property that any pair of codes in the set have a

three-valued cross-correlation. In this set, except the sequences a and a‟, the rest are not m-

sequences. Hence, their autocorrelation functions are not two-valued, but it takes the same three

values as cross-correlation. The cross correlation spectrum between a preferred pair is three-valued ,

where those three values are –t(n), -1, t(n)-2 (Stallings, 2002)

Where

2.3.3 Walsh codes

The Hadamard code, named after Jacques Hadamard, is a system used for signal error detection and

correction. It is one of the family of [2n, n + 1, 2n − 1] codes. Especially for large n it has a poor

rate but it is capable of correcting many errors. Hadamard codes can be considered as a special case

of Reed–Muller codes. In particular, first order Reed–Muller code is equivalent to Hadamard codes.

These Hadamard codes are called Walsh codes.

Walsh functions are generated by mapping codeword rows of special square matrices called

Hadamard matrices. These matrices one row of all zeros, and the remaining rows each have equal

number of ones and zeros. Walsh functions can be constructed for block length N=2n. The

2.13

Page 28: My Undergraduate Thesis

17

sequence 1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 0

sequence 2 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 1 0

0 shift XOR 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 0

1 shift XOR 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 1

… 30 shift XOR 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 1 0 0 0 1 1 0 1 0 1 1

Fig 2.3 Generation of a Gold Code set

Gold sequence

[5 4 3 2]

seq2:N=25 - 1=31 chips

1 2 3 4 5

[5 3]

seq1:N=25 - 1=31 chips

1 2 3 4 5

Page 29: My Undergraduate Thesis

18

Hadamard matrix of desired length can be generated by the following recursive procedure:

Where N is a power of 2 and the overscore denotes the binary complement of the bits in the matrix.

In practice, Walsh sequences provide zero cross correlation when there is zero offset between the

sequences, but in order to provide zero offset; all users have to be synchronized in time(Stallings,

2002) .

2.4 Channel Impairment

This refers to the contribution of the channel through which the information carrying signal passes

from the transmitter to the receiver.

Because of the analog nature of the channel, the binary codeword generated via spreading codes are

always modulated using any of the digital modulation techniques.

Amplitude Shift Keying ASK

Frequency Shift Keying FSK

Phase Shift Keying PSK

BPSK, an example of PSK is mostly used for Spread Spectrum application due to its resistance to

frequency selective fading (Freeman, 2004; Paizi, 2006).

Small-scale fading or fading is used to describe the rapid fluctuations of the amplitudes, phases or

multipath delays of a radio signal over a short period of time or travel distance, so that large-scale

path loss effects may be ignored. Fading is caused by interference between two or more versions of

2.14

Page 30: My Undergraduate Thesis

19

the transmitted signal which arrive at the receiver at slightly different times. These waves, called

multipath waves, combine at the receiver antenna to give a resultant signal which can vary widely

in amplitude and phase, depending on the distribution of the intensity and relative propagation time

of the waves and the bandwidth of the transmitted signal.

Multipath in the radio channel creates small-scale fading effects. The three most important effects

are:

Rapid changes in signal strength over a small travel distance or time interval.

Rapid frequency modulation due to varying Doppler shifts on different multipath

signals.

Time dispersion (echoes) caused by multipath propagation delays.

2.5 Bit Error Rate (BER) Performance

BER is defined as source of performance measurement that specifies the number of bits corrupted

or destroyed as they are transmitted from its source to destination. So, in order to improve the

performance of a system, BER should be minimum. There are several factors that affect BER which

include bandwidth, SNR, multiuser, multipath, transmission speed and transmission medium.

Kumar et. al.(May 2011) investigated BER performance of CDMA cellular system based on IS-95

standard in the presence of additive white Gaussian noise (AWGN) and interference. The

performance is evaluated under two types of decision feedback receivers for the CDMA reverse

link. These two feedback receivers are:

(a) Hard decision Viterbi decoder in which coded bit is estimated based on Hamming Distance

method and

Page 31: My Undergraduate Thesis

20

(b) Soft decision Viterbi decoder in which Euclidean Distance method is used for coded bit

estimation.

From this comparison, the BER is found to be less with hard decision viterbi decoding as compared

with Soft decision viterbi decoding.

Ali et. al.(May 2011) evaluated the performance of Multi-Code CDMA using different code sets in

AWGN and in multipath fading channels. Compared to AWGN channel, the performance of the

Multi-Code system degrades drastically in multipath fading channel. This led to the proposal of a

Multi-Code Multi-Carrier CDMA system which retains the variable data rate capability of the

Multi-Code system and is robust to multipath fading like Multi-Carrier CDMA. The proposed

system has significantly better BER performance to the original Multi-Code CDMA system and

hence supports more users for the same BER in a fading channel. The rate adaptation algorithm

proposed ensures that the average data rate traces the instantaneous channel condition and thereby

improves the overall capacity of the system. Paizi(2006) studied and identified the PSK-based

digital modulation scheme (BPSK, QPSK or GMSK) that gives the best BER performance in a

multipath fading environment using computer simulation. Essentially, ideal and worst case

communication channel models were studied and simulation programs were written to simulate the

channels. Each PSK-based digital modulation understudy are modeled and simulated under

different channel conditions. Subsequently, a comparison study is carried out to obtain the BER

performance for each PSK-based transmission scheme under 1-path and 4-path multipath fading

conditions and to identify which modulation scheme gives best BER performance.

The comparison study showed that BER for BPSK and Quadrature Phase Shift Keying(QPSK) are

similar and they give the lowest BER under multipath fading. Nonetheless, Gaussian Minimum

Shift Keying(GMSK) BER is just slightly higher than that of BPSK and QPSK.

Page 32: My Undergraduate Thesis

21

Krishna et. al.(2005) presents a single correlator RAKE receiver for direct sequence code division

multiple access (DS-CDMA) systems. Contrary to conventional RAKE receivers where; multiple

correlators are used to de-spread the multipath signals and then to align and combine those signals

in a later stage before making a bit decision, the simplified receiver structure uses a single correlator

and single code sequence generator to recover the multipath. Modified Walsh-Hadamard codes are

used for data spreading to provide better un-correlation properties for the multipath signals. The

main advantage of this receiver structure is that it requires only a single correlator and a code

generator in contrary to the conventional RAKE receiver concept with multiple correlators. It is

shown in results that the proposed receiver achieves better bit error rates in comparison with the

conventional one for more than one multipath.

Alouini et. al.(1998) investigated the exact BER analysis of binary DS-CDMA systems operating

over generalized frequency-selective fading channels using alternate representations of the

Gaussian Q-function and the Marcum Q-function. Simulated results are applicable to systems

employing RAKE reception with coherent maximal-ratio combining as well as noncoherent and

differentially coherent equal-gain combining. The analyses assume independent resolvable fading

paths which are not necessarily identically distributed nor even distributed according to the same

family of distributions. The proposed approach gives new analytical expressions for BER under

very general channel conditions, in addition to simplifying previously-known results both

analytically and computationally.

Page 33: My Undergraduate Thesis

22

CHAPTER 3

METHODOLOGY

3.1 Message Generation

Information signals otherwise called message can either be analog or digital in nature depending on

the source. For instance, sound signals are analog while a pulse generated by pressing any key of a

calculator is discrete. For the purpose of this study, a message signal was modeled as digital but

randomized using Matlab programming language. The result of simulation is as follow while the

matlab code used is represented in plate A.1 (Appendix).

3.2 Spreading Sequence Generation and Spreading

The spreading code generation includes the simulation of Gold and Walsh-Hadamard codes

respectively. In the course of their generation, the number of messages (users) was put to

consideration and message(s) spread by the code.

3.2.1 Gold Sequence Generation

Gold sequence is the exclusive-OR output of two PN sequence of maximum length. Using the shift

register connection in fig. 3.2 below for the simulation with a single user, The Matlab codes (Plate

A.2) generated the expected spreading code and codeword.

3.2.1.1 M-Sequences

Not all shift register connections are of maximum length (N=2m-1), where m is the shift register

stage. M-sequences are maximum length PN sequences generated by some connection of the shift

Page 34: My Undergraduate Thesis

23

register and for an m-stage shift register; the number of possible m-sequences is given by the

equation below (Ipatov, 2005).

Page 35: My Undergraduate Thesis

24

message =

0 0 0 0 0 1 0 1 1 0 1 1 0 0 0 0 0 0 1 0

Fig 3.1 message sequence of length 20

Page 36: My Undergraduate Thesis

25

Fig 3.2 Gold code generation shift register implementation.

Gold sequence

[5 4 3 2]

seq2:N=25 - 1=31 chips

1 2 3 4 5

[5 3]

seq1:N=25- 1=31 chips

1 2 3 4 5

Page 37: My Undergraduate Thesis

26

PN1 1 1 1 1 1 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 0

PN2 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 1 0

Gold_code 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 0

Message 1 1 0 1 0 0 1 1 0 1

Codeword(bit1) 0 0 0 0 0 0 0 1 1 1 1 0 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 0 0 1 1

Fig 3.3 Gold code simulation output

Page 38: My Undergraduate Thesis

27

Where pk is from the set of prime factors of N.

For instance, for m=4, N=15, P=prime factors of 15( i.e factor(15)).

Hence, P=factor(15)= {3, 5},

Meaning, for m=2, we have 2 m_sequences using only two possible connections.

The Matlab function that executed this is written in Plate A.3.

3.2.2 Walsh Code Generation

Walsh sequences can be taken from the rows or column of the Hadamard matrix which is

orthogonal and symmetric. The Hadamard matrix has input [0,1] but for its simulation, it was best

to map [0,1] to [-1,1] domain.

The Matlab program in plate A.4 is a function that generated m numbers of walsh code of order 2n

by calling it with the syntax walsh (n,m,p) with p being a vector representing the required lines of

the walsh matrix.

Using the above function to generate a Walsh code to encode a 10 bit message and ploting the

outputs, the Matlab code in plate A.5 ensured and the output of the Matlab code was as follows;

3.1

3.2

Page 39: My Undergraduate Thesis

28

Message 1 1 0 1 1 0 0 1 0 0

Walshcode 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1

codeword(bit 1) 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1

Fig 3.4 walsh code simulation output

Page 40: My Undergraduate Thesis

29

3.3 Modulation and Channel Modeling

Modulation is the transformation of the codeword into a form that is transferable over the channel.

It entails impregnating the codeword sequence over a continuous wave. For the course of this study,

BPSK modulation was employed over a Gaussian channel.

The channel was modeled to be additive and interference was also considered for a multiuser

channel. Multipath propagation was modeled by delaying the transmitted signal by several

propagation delays to account for the different time taken for the signals in reaching the receiver.

The following codes were used for the simulation of two different messages encoder separately

with gold and Walsh codes and transmitted separately over both additive white Guassian channel

with/without multipath. In addition, fading channel was also considered.

3.4 Receiver Modeling

The received waveform is never the transmitted one due to the channel characteristic which

includes; intentional/unintentional interference, channel noise as well as multipath propagation as

the case may be.

The receiver was modeled as a coherent BPSK detector which includes

Local oscillator multiplied by the incoming received signal in the product modulator

Low-pass filter for filtering out the high frequency carrier for the envelope.

This was followed by de-spreading with the spreading code which was then led to detection and

decision stage done by an integrator (this was implemented in the course of the simulation by the

trapezium rule over the bit period Tb) and the decision block respectively(Simon, 2001). A detailed

block diagram of a coherent BPSK demodulator is as shown below in figure 3.5.

Page 41: My Undergraduate Thesis

30

Fig 3.5 Block diagram of a Coherent BPSK demodulator

Coherent Detector

Local Oscillator Spreading code

Product

Modulato

r

Low-

power

filter

Decision

rule

Received

wave Say 1 v > 0

Say 0 v < 0

Page 42: My Undergraduate Thesis

31

3.5 Correlation Properties

The working efficiency of any spreading sequence is a function of its correlation ratio. The ratio of

the maximum cross-correlation to the maximum auto-correlation should be very low for a better

code. Cross-correlation is a measure of likelihood of interference between different code while

autocorrelation is measure of resistance to asynchronous nature of the channel or the link.

Using 5-stage shift-register to generate 2 different gold codes and also generating 2 different walsh

codes of order 25. The Matlab script in plate A.6 was used to plot both autocorrelation and cross

correlation curve for both gold codes and walsh codes respectively.

Page 43: My Undergraduate Thesis

32

CHAPTER 4

RESULTS

4.1 Correlation Analysis

After running several simulations, fig.4.1 proved Gold code to have better autocorrelation than

Walsh code while the reverse was the case when their cross-correlation property was compared.

4.2 BER Performance Analysis

After observing the correlation properties, factors affecting the BER were taken into consideration

such as SNR, multiuser (k=number of users), multipath (L=number of paths), coding technique

(Gold and Walsh), code-length and transmission medium (Rayleigh fading channel as well as

AWGN channel ) so as to compare the BER of both Gold and Walsh coding system which is the

main purpose of this research.

At first, a single user (k=1), multipath (L=3), for both AWGN and Rayleigh channel was

experimented to give the result shown in fig. 4.2, 4.3 and 4.4 as well as fig. 4.5, 4.6 and 4.7

respectively; which show various responses as the signature length was varied accordingly i.e

increasing the signature length reduces the BER also showing walsh code to be better when

considering the effect of multipath interference. The same process was carried on multi-user (k=2,

4, 8 and 16) with other parameters been constant which gave results shown in fig. 4.8 and fig. 4.9

(Matlab codes for the simulated results are presented in plates A.7, A.8, A.9 and A.10

respectively.). This proves Gold code to be more robust when considering multi-user interference.

Page 44: My Undergraduate Thesis

33

Fig4.1 Correlation Property of Walsh and Gold code.

Page 45: My Undergraduate Thesis

34

Fig 4.2 Performance of Gold Codes over AWGN Channel

Page 46: My Undergraduate Thesis

35

Fig 4.3Performance of Walsh Codes over AWGN Channel

Page 47: My Undergraduate Thesis

36

Fig. 4.4Performance of Gold and Walsh over AWGN Channel

Page 48: My Undergraduate Thesis

37

Fig. 4.5 Performance of Gold over Rayleigh Channel

Page 49: My Undergraduate Thesis

38

Fig. 4.6 Performance of Walsh over Rayleigh Channel

Page 50: My Undergraduate Thesis

39

Fig. 4.7 Performance of Gold and Walsh over Rayleigh Channel

Page 51: My Undergraduate Thesis

40

Fig 4.8 Multi-user Gold and Walsh Code over AWGN Channel

Page 52: My Undergraduate Thesis

41

Fig 4.9 Multi-user Gold and Walsh Code over Rayleigh Channel

Page 53: My Undergraduate Thesis

42

4.3 Challenges Encountered

Spread spectrum analysis is a very wide subject which requires diversified approach in its research

methodology. Matlab programming is utilized in the course of this study for simulating real life

scenario of several discrete sequence code division multiple access analysis which includes;

Spreading sequence and spreading

Modulation

Channel modelling

Coherent demodulation and detection

De-spreading

Correlation and BER performance comparison of the spreading sequence

These above listed terms pose several challenges in the course of the study including,

Transformation of Expressions and block diagram into Matlab codes

The limits of the Matlab programming environment limit the study to low stage shift register

Implementation.

Linking of the written codes to a Graphical User Interface GUI for better presentation.

The time spent in compiling a block of code is much (e.g 2hrs) making debugging and

recompiling process frustrating.

Page 54: My Undergraduate Thesis

43

CHAPTER 5

CONCLUSION

This project as a whole has been able to show clearly the importance of spreading in CDMA

communication especially in DS-CDMA where either Gold or Walsh sequence is used to spread the

information. It has also shown the strength, weakness and application of the two coding systems if

subjected to the same environmental and channel impairment such as jamming, interference in

AWGN and multipath. The above statement was proved using the key tests for data communication

which are Correlation property (auto-correlation and cross-correlation) and Bit Error Rate

Performance.

After series of simulations the following points and comparison can be said assertively about Gold

and Walsh coding system

Gold code has a high auto-correlation (an advantage) and low cross-correlation ( a

disadvantage) property making it suitable for Multi-user CDMA communication while

Walsh code has low auto-correlation (a disadvantage) and low cross-correlation (an

advantage) which suits WCDMA communication.

Both coding systems have similar good performance with respect to AWGN and Rayleigh

channel.

Page 55: My Undergraduate Thesis

44

Most importantly, comparing the BER performance, Gold codes can be said to have better

performance considering multi-user interference while Walsh codes takes care of multi-path

interference better.

Page 56: My Undergraduate Thesis

45

References

Alouini, M., Simon, M. K. and Goldsmith, A. ‘A Unified Performance Analysis of DS-CDMA

Systems over Generalized Frequency-Selective Fading Channels’ IEEE Communication Magazine,

August 1998, p. 8

Ali, M. S., Islam, M. S., Hossain, M. A., Khalid, M. and Jewel, H. „BER Analysis of Multi-Code

Multi-Carrier CDMA Systems in Multipath Fading Channel‟ International Journal of Computer

Networks & Communications (IJCNC) Vol.3, No.3, May 2011, pp. 178-191

Bellcore, S. M. „Multi-User Detection for DS-CDMA Communications‟ IEEE Communication

Magazine , October 1996

Dinan, E. H. and Jabbari, B ''Spreading codes for Direct Sequence and Wideband CDMA cellular

networks'' IEEE Communications Magazine, September 1998

Freeman, R. L., „Telecommunication System Engineering‟, 4th edition, John Willey & Sons Inc.,

2004

Garg,V. K. „Wireless Communications and Networking‟, 1st edition, Elsevier Inc., 2007

Haykin, S „Communication Systems‟, 4th edition, John Willey & Sons Inc., 2001

Ipatov, V. P. „Spread Spectrum and CDMA: principles and applications‟, John Willey & .

Sons, Inc., 2005

Kandar, D. and Sarkar, C. K. „Simulation of Spread Spectrum Radar Using Rake at the Receiver

end‟ Progress in Electromagnetic Research Letters Vol.7, 2009, pp. 35-40

Page 57: My Undergraduate Thesis

46

Kumar, S., Tuteja, M. and Singh, R. „BER Performance Analysis of CDMA Reverse Link under

AWGN Channel‟ International Journal of Computer Applications Vol. 21, No. 2, May 2011, pp.

11-14

Krishna, K. M., Mitra, A. and Ardil, C. ‘A Simplified Single Correlator Rake Receiver for CDMA

Communications’ World Academy of Science, Engineering and Technology, 2005, pp. 106-109

Matlab R2009B, „A Production of Mathworks.com

Paizi, W. F. „BER Performance Study of PSK-Based Digital Modulation Schemes in Multipath

Fading Environment‟ Master Degree Thesis, Department of Electrical-Electronics &

Telecommunication, University of Technology, Malaysia, 2006

Prapeep, A. M. and Baskhar, V „Performance Analysis of Wideband CDMA System in a Lognormal

Fading Channel‟ International Journal of Civil Engineering Research . Vol. 1, No. 1 , 2010, pp.

11-18

Proakis, J. „Digital Communications‟, 4th edition, McGraw-Hill, 2001

Rusyn, T. and Riley, T. „A Co-channel Interference Model for Spread Spectrum Technologies‟

National Telecommunications and Information Administration Report, U. S. Department of

Commerce, June 2010

Sadara, P. D. and Bikash, K. D. „Channel Estimation in Multicarrier Communication System‟,

Graduation Degree Thesis, Department of Electronics & Communication Engineering ,National

institute of technology

ROURKELA , 2009

Selvi, S. T. and Ramar, K. „Performance Evaluation of Multiuser Detection for Uplink Wireless

Communications with various Multiple Access Schemes‟ Journal of Theoretical and Applied

Information Technology Vol.1, No.1,2009, pp. 724-730

Page 58: My Undergraduate Thesis

47

Sivanesskumar, S. and Sukanesh, R. „Performance Analysis of Multi-Carrier Code Division Multiple

Access System under Clipping Noise‟ European Journal of Scientific Research Vol. 38 ,No. 4 ,

2009, pp. 590-595

Soren, M. P. „Spread Spectrum Analysis for CDMA System‟, Graduation Degree Thesis,

Department of Electronics & Communication Engineering ,National institute of technology

ROURKELA, 2010

Stallings, W. „Wireless Communications and Networks‟, Prentice Hall, 2002

Utlaut, |W. F. „Spread Spectrum: Principles and Possible Application to Spectrum Utilization and

Allocation‟ ITU Telecommunication Journal, Vol. 45,1978, pp. 20-32

Welsh, L. R. , „Lower Bound on the Maximum Cross-Correlation of Signals‟ IEEE Trans. Info.

Theory, Vol. IT-20, May 1974, pp. 397-399

Page 59: My Undergraduate Thesis

48

APPENDIX

Matlab Codes used in the report

Page 60: My Undergraduate Thesis

49

%...........message signal

generation..........

%.........

message=randsrc(1,20);

for i=1:20

if message(i)==-1

message(i)=0;

End

End

message=message

stairs([message message(20)]);

axis([0 21 -1 2]);

%............end of program……..

Plate A.1 Message sequence generation

Page 61: My Undergraduate Thesis

50

%.......this code generate the gold sequence and code word

%...........

n=5; % using 5 stage shift register

initial_state=ones(1,n); %...initialregister state.....

a=initial_state;

c=initial_state;

connected_registers1=[3];

connected_registers2=[4 3 2];

b1=connected_registers1;

b2=connected_registers2;

[~, m1]=size(connected_registers1);

[~, m2]=size(connected_registers2);

x=2^n-1; % ........length or period of the code

PN1=zeros(1,x);

for i=1:x

temp=a(1,n);

for k=1:m1

t=b1(1,k);

temp=xor(a(1,t),temp);

End

PN1(1,i)=a(1,n);

for j=2:n

a(1,n+2-j)=a(1,n+1-j);

End

a(1,1)=temp;

End

PN2=zeros(1,x);

for i=1:x

temp=a(1,n);

for k=1:m2

t=b2(1,k);

temp=xor(a(1,t),temp);

End

PN2(1,i)=a(1,n);

for j=2:n

a(1,n+2-j)=a(1,n+1-j);

End

a(1,1)=temp;

End

Gold_code=xor(PN1,PN2);

gold=Gold_code;

Plate A.2 Gold Sequence Generation

Page 62: My Undergraduate Thesis

51

%...turning into -1 and 1 sequence........

for j=1:x

if (Gold_code(j)==0)

gold(i)=-1;

End

End

%......message itself...........

message=randsrc(1,10);

me=message;

for i=1:10

if message(i)==-1

me(i)=0;

End

end

%............generated codeword......

codeword=kron(message,gold);

code=codeword;

for i=1:numel(codeword)

if code(i)==-1

code(i)=0;

End

End

me %...............the message itself before spreading.......

[PN1;PN2;Gold_code] %........generating the PN sequence and Gold code

code(1:31) %........the message after being spreaded (first

bit).........

subplot(3,1,1)

stairs([me me(10)])

axis([1 11 -1 2])

title('message')

subplot(3,1,2)

stairs([Gold_code Gold_code(x)])

axis([1 32 -1 2])

title('gold code')

subplot(3,1,3)

stairs([code code(numel(code))])

axis([1 numel(code)+1 -1 2])

title('codeword')

%..............end of program……………

Plate A.2 Gold Sequence Generation (Cont’d)

Page 63: My Undergraduate Thesis

52

%........This function calculate the number of m_sequences obtainable with

%........a given number of shift register stage.

%........It can be called by 'm_sequences(n)' written on the command

%........prompt where n is the shift register state

function nx=m_sequences(n)

x=2^n-1;

p=factor(x);

k=numel(p);

for i=1:k

a=p(1,i);

for j=1:k

b=p(1,j);

if (a==b && j~=i)

p(1,j)=0;

End

End

End

Euler_x=x;

for i=1:k

if (p(1,i)~=0)

Euler_x=Euler_x*(p(1,i)-1)/p(1,i);

End

End

nx=Euler_x/n;

%........End of function...........

Plate A.3 M_Sequence Calculating Function

Page 64: My Undergraduate Thesis

53

%..... This function generate m rows of walsh codes of order 2^n........

%......It can be called by walsh(n,m,p)...................................

function [walsh_output walsh_output1 x]=walsh(n,m,p)

if (m==numel(p) && max(p)<=2^n)

if m<2^n

if n<=13

h=-1;

for i=1:n

h=[h h;h -h];

End

y=2^n;

s=p;

for i=1:m

walsh_set(i,:)=h(s(i),:);

End

walsh_set1=walsh_set;

for i=1:m

for j=1:y

if(walsh_set(i,j)==-1)

walsh_set1(i,j)=0;

End

End

End

walsh_output=walsh_set;

walsh_output1=walsh_set1;

Else

errordlg('please use shift register less than 14');

Plate A.4 Walsh code generating function

Page 65: My Undergraduate Thesis

54

%.........genarating a set of 4 walsh codes of order 2^5......

walsh_codes=walsh(5,4,[2 3 4 5]);

%.........using the third of the 4 codes generated for encodering...

walsh_code=walsh_codes(3,:);

%.........the message itself before encoding.........

me=randsrc(1,10);

%.........the codeword......

code=kron(me,walsh_code);

%.........mapping all the variables from [-1,1] to [0,1] for ploting

message=me;

for i=1:10

if me(i)==-1

message(i)=0;

End

End

codeword=code;

for i=1:numel(code)

if code(i)==-1

codeword(i)=0;

End

End

walshcode=walsh_code;

for i=1:numel(walshcode)

if walshcode(i)==-1

walshcode(i)=0;

End

End

%......ploting the output..................

subplot(3,1,1);

stairs([message message(numel(me))]);

axis([1 11 -1 2]);

title('message');

subplot(3,1,2);

stairs([walshcode walshcode(numel(walshcode))]);

axis([1 numel(walshcode)+1 -1 2]);

title('walsh code');

subplot(3,1,3);

stairs([codeword codeword(numel(codeword))]);

axis([1 numel(codeword)+1 -1 2]);

title('codeword');

Plate A.5 Walsh Code Generating Script

Page 66: My Undergraduate Thesis

55

Plate A.6 Correlation Properties of Spreading Codes

walsh_codes=walsh(5,2,[2 3]);%calling the function walsh

gold_codes=gold_pn(5,2 [2 3]);%calling the function gold_pn

%..........autocorrelation ................

[g_auto g_at]=xcorr(gold_codes(1,:));

[w_auto w_at]=xcorr(walsh_codes(1,:));

%..........cross correlation...............

[g_cross g_xt]=xcorr(gold_codes(1,:),gold_codes(2,:));

[w_cross w_xt]=xcorr(walsh_codes(1,:),walsh_codes(2,:));

%..........ploting the outputs............

subplot(2,2,1);

plot(g_at,g_auto);

axis([min(g_at) max(g_at) min(g_auto) max(g_auto)]);

title('Autocorrelation plot of gold code');

subplot(2,2,2);

plot(w_at,w_auto);

axis([min(w_at) max(w_at) min(w_auto) max(w_auto)]);

title('Autocorrelation plot of walsh code');

subplot(2,2,3);

plot(g_xt,g_cross);

axis([min(g_xt) max(g_xt) min(g_cross) max(g_cross)]);

title('cross correlation plot of gold code');

subplot(2,2,4);

plot(w_xt,w_cross);

axis([min(w_xt) max(w_xt) min(w_cross) max(w_cross)]);

title('cross correlation plot of walsh code');

Page 67: My Undergraduate Thesis

56

% Matlab code for BER Performance over AWGN Channel with

% Varying length of of codes,

% Gold or Walsh

handles.coding=1:3;

handles.user=1:2;

handles.channel=1:2;

handles.shift_stage=5:8;

handles.current_coding=handles.coding(1);

handles.current_user=handles.user(1);

handles.current_channel=handles.channel(1);

handles.current_shift_stage=handles.shift_stage(1);

handles.snr=-10:2:20;

handles.gber=[];

handles.wber=[];

for i_stage=1:numel(handles.shift_stage)

n=handles.shift_stage(i_stage);

wcodes=walsh(n,2,[2^(n-1) 2^n])/sqrt(2^n);

gcodes=gold_pn(n,2,[2^(n-1) 2^n-3])/sqrt(2^n-1);

user1tx=randi([0 1],1,3000);

handles.usertx=user1tx;

user1=user1tx;

u1=real(pskmod(user1,2));

gtx1=kron(u1,gcodes(1,:));

wtx1=kron(u1,wcodes(1,:));

%........the channel.........

handles.g_s_user=gtx1;

handles.w_s_user=wtx1;

handles.g_s_user=modulate(handles.g_s_user,900000000,3000000000,'fm');

handles.w_s_user=modulate(handles.w_s_user,900000000,3000000000,'fm');

%....path consideration........

%......multipath.......

handles.g_ber=zeros(numel(handles.snr),1);

handles.w_ber=zeros(numel(handles.snr),1); for i_snr=1:numel(handles.snr)

%.... Adding noise

g_s_ctx=awgn(handles.g_s_user,handles.snr(i_snr),'measured');

w_s_ctx=awgn(handles.w_s_user,handles.snr(i_snr),'measured');

Plate A.7 BER Performance over AWGN Channel

Page 68: My Undergraduate Thesis

57

g_out=[];

w_out=[];

for ii=1:3000

%.....multipath

g_s_path1=g_s_ctx(1+(ii-1)*(2^n-1):ii*(2^n-1));

g=g_s_path1;

g_s_path2=[zeros(1,3) g(4:(2^n-1))];

g_s_path3=[zeros(1,5) g(6:(2^n-1))];

w_s_path1=w_s_ctx(1+(ii-1)*(2^n):ii*(2^n));

w=w_s_path1;

w_s_path2=[zeros(1,3) w(4:(2^n))];

w_s_path3=[zeros(1,5) w(6:(2^n))];

%......FM Demodulation...............

g_s_crx=demod(g_s_path1,900000000,3000000000,'fm');

gm_s_crx1=g_s_crx;

gm_s_crx2=demod(g_s_path2,900000000,3000000000,'fm');

gm_s_crx3=demod(g_s_path3,900000000,3000000000,'fm');

w_s_crx=demod(w_s_path1,900000000,3000000000,'fm');

wm_s_crx1=w_s_crx;

wm_s_crx2=demod(w_s_path2,900000000,3000000000,'fm');

wm_s_crx3=demod(w_s_path3,900000000,3000000000,'fm');

%....the receiver..............

%.....multipath detection.....

%......rake receiver despreader operation..........

gm1_s_rx=gm_s_crx1.*gcodes(1,:);

wm1_s_rx=wm_s_crx1.*wcodes(1,:);

gm2_s_rx=gm_s_crx2.*[zeros(1,3) gcodes(1,4:(2^n-1))];

wm2_s_rx=wm_s_crx2.*[zeros(1,3) wcodes(1,4:(2^n))];

gm3_s_rx=gm_s_crx3.*[zeros(1,5) gcodes(1,6:(2^n-1))];

wm3_s_rx=wm_s_crx3.*[zeros(1,5) wcodes(1,6:(2^n))];

gm=gm1_s_rx;

wm=wm1_s_rx;

Plate A.7 BER Performance over AWGN Channel (cont’d)

Page 69: My Undergraduate Thesis

58

%....integrate and sum.........

%...........+..............

%........PSK demodulation.......

handles.gm_rx=floor(2*sum(gm)-(gm(1)+gm(2^n-1)));

handles.wm_rx=floor(2*sum(wm)-(wm(1)+wm(2^n)));

handles.gm_rx=pskdemod(handles.gm_rx,2);

handles.wm_rx=pskdemod(handles.wm_rx,2);

%...picking detected bit output

g_out=[g_out handles.gm_rx'];

w_out=[w_out handles.wm_rx'];

End

%....correlating output with input for BER Calculation

g_count=sum(kron(ones(1,1),user1tx)'==g_out');

w_count=sum(kron(ones(1,1),user1tx)'==w_out');

%....BER Calculation........

handles.g_ber(i_snr,:)=(3000*ones(1,1)-g_count)/3000;

handles.w_ber(i_snr,:)=(3000*ones(1,1)-w_count)/3000;

End

handles.gber=[handles.gber handles.g_ber];

handles.wber=[handles.wber handles.w_ber];

End

semilogy(handles.snr,handles.gber,'-*');

legend('gold-31','gold-63','gold-127','gold-255');

title('gold over AWGN channel L=3,K=1');

xlabel('SNR');ylabel('BER');

grid;

figure;

semilogy(handles.snr,handles.wber,'-*');

legend('walsh-32','walsh-64','walsh-128','walsh-256');

title('walsh over AWGN channel L=3,K=1');

xlabel('SNR');ylabel('BER');

Grid

semilogy(handles.snr,[handles.gber(:,1) handles.wber(:,1)],'-*');

grid;

legend('Gold-31','Walsh-32');

title('BER Performance over AWGN Channel (K=1,L=3)');

Plate A.7 BER Performance over AWGN Channel (cont’d)

Page 70: My Undergraduate Thesis

59

% Matlab code for BER Performance over AWGN Channel with

% Varying number of users

handles.coding=1:3;

handles.user=[2 2^2 2^3 2^4];

handles.channel=1:2;

handles.shift_stage=5:8;

handles.current_coding=handles.coding(1);

handles.current_user=handles.user(1);

handles.current_channel=handles.channel(1);

handles.current_shift_stage=8;

handles.snr=0:2:20;

handles.g_ber=zeros(numel(handles.user),1);

handles.w_ber=zeros(numel(handles.user),1);

for i_use=1:numel(handles.user)

n=5;

i_user=handles.user(i_use);

handles.pick=2:2^n-1;

wcodes=walsh(n,i_user,handles.pick(1:i_user))/sqrt(2^n);

gcodes=gold_pn(n,i_user,handles.pick(1:i_user))/sqrt(2^n-1);

user1tx=randi([0 1],1,2999);

handles.usertx=user1tx;

user1=user1tx;

u1=real(pskmod(user1,2));

gtx=[];wtx=[];

Page 71: My Undergraduate Thesis

60

for i_case=1:i_user

gtx1=kron(u1,gcodes(i_case,:));

wtx1=kron(u1,wcodes(i_case,:));

wtx=[wtx;wtx1];gtx=[gtx;gtx1];

End

%........the channel.........

handles.g_s_user=[];

handles.w_s_user=[];

for i_case=1:i_user

handles.g_s_user1=modulate(gtx(i_case,:),900000000,3000000000,'fm');

handles.w_s_user1=modulate(wtx(i_case,:),900000000,3000000000,'fm');

handles.g_s_user=[handles.g_s_user; handles.g_s_user1];

handles.w_s_user=[handles.w_s_user; handles.w_s_user1];

End

g_s_ctx=[];w_s_ctx=[];

for i_case=1:i_user

gcase=handles.g_s_user(i_case,:);

wcase=handles.w_s_user(i_case,:);

g_s_ctx1=awgn(gcase,10,1);

w_s_ctx1=awgn(wcase,10,1);

g_s_ctx=[g_s_ctx;g_s_ctx1];

w_s_ctx=[w_s_ctx;w_s_ctx1];

End

g_out=[];

w_out=[];

Page 72: My Undergraduate Thesis

61

for ii=1:2999

g_s_path1=zeros(1,2^n-1);

g_s_path2=zeros(1,2^n-1);

g_s_path3=zeros(1,2^n-1);

w_s_path1=zeros(1,2^n);

w_s_path2=zeros(1,2^n);

w_s_path3=zeros(1,2^n);

for i_case=1:i_user %...multiple signal over awgn channel

g_s_path1=sum([g_s_path1;g_s_ctx(i_case,(1+(ii-1)*(2^n-1):ii*(2^n-1)))]);

g=g_s_ctx(i_case,(1+(ii-1)*(2^n-1):ii*(2^n-1)));

g_s_path2=sum([g_s_path2;[zeros(1,3) g(4:(2^n-1))]]);

g_s_path3=sum([g_s_path3;[zeros(1,5) g(6:(2^n-1))]]);

w_s_path1=sum([w_s_path1;w_s_ctx(i_case,(1+(ii-1)*(2^n):ii*(2^n)))]);

w=w_s_ctx(i_case,(1+(ii-1)*(2^n):ii*(2^n)));

w_s_path2=sum([w_s_path2;[zeros(1,3) w(4:(2^n))]]);

w_s_path3=sum([w_s_path3;[zeros(1,5) w(6:(2^n))]]);

End

%%%% ....FM Demodulation......

g_s_crx=demod(g_s_path1,900000000,3000000000,'fm');

gm_s_crx1=g_s_crx;

gm_s_crx2=demod(g_s_path2,900000000,3000000000,'fm');

gm_s_crx3=demod(g_s_path3,900000000,3000000000,'fm');

w_s_crx=demod(w_s_path1,900000000,3000000000,'fm');

Page 73: My Undergraduate Thesis

62

wm_s_crx1=w_s_crx;

wm_s_crx2=demod(w_s_path2,900000000,3000000000,'fm');

wm_s_crx3=demod(w_s_path3,900000000,3000000000,'fm');

%....the receiver..............

%.....multipath detection.....

%......rake receiver despreader operation..........

gm1_s_rx=gm_s_crx1.*gcodes(1,:);

wm1_s_rx=wm_s_crx1.*wcodes(1,:);

gm2_s_rx=gm_s_crx2.*[zeros(1,3) gcodes(1,4:(2^n-1))];

wm2_s_rx=wm_s_crx2.*[zeros(1,3) wcodes(1,4:(2^n))];

gm3_s_rx=gm_s_crx3.*[zeros(1,5) gcodes(1,6:(2^n-1))];

wm3_s_rx=wm_s_crx3.*[zeros(1,5) wcodes(1,6:(2^n))];

gm=gm1_s_rx;

wm=wm1_s_rx;

%....integrate and sum.........

%...........+..............

%........PSK demodulation.......

handles.gm_rx=floor(2*sum(gm)-(gm(1)+gm(2^n-1)));

handles.wm_rx=floor(2*sum(wm)-(wm(1)+wm(2^n)));

handles.gm_rx=pskdemod(handles.gm_rx,2);

handles.wm_rx=pskdemod(handles.wm_rx,2);

%...picking detected bit output

g_out=[g_out handles.gm_rx'];

w_out=[w_out handles.wm_rx'];

Plate A.8 Multi-user BER Performance Over AWGN Channel (cont’d)

Page 74: My Undergraduate Thesis

63

End

%....correlating output with input for BER Calculation

g_count=sum(kron(ones(1,1),user1tx)'==g_out');

w_count=sum(kron(ones(1,1),user1tx)'==w_out');

%....BER Calculation........

handles.g_ber(i_use,:)=(2999-g_count)/2999;

handles.w_ber(i_use,:)=(2999-w_count)/2999;

End

semilogy(handles.user,handles.g_ber,'-*',handles.user,handles.w_ber,'-r*');

grid;

title('Multi-user Gold and Walsh over AWGN (L=3)');

legend('Gold-31','walsh-32')

ylabel('BER');

xlabel('K');

Plate A.8 Multi-user BER Performance Over AWGN Channel (cont’d)

Page 75: My Undergraduate Thesis

64

% Matlab code for BER Performance over AWGN Channel with

% Varying number of users

handles.coding=1:3;

handles.user=[2 2^2 2^3 2^4];

handles.channel=1:2;

handles.shift_stage=5:8;

handles.current_coding=handles.coding(1);

handles.current_user=handles.user(1);

handles.current_channel=handles.channel(1);

handles.current_shift_stage=8;

handles.snr=0:2:20;

handles.g_ber=zeros(numel(handles.user),1);

handles.w_ber=zeros(numel(handles.user),1);

for i_use=1:numel(handles.user)

n=5;

i_user=handles.user(i_use);

handles.pick=2:2^n-1;

wcodes=walsh(n,i_user,handles.pick(1:i_user))/sqrt(2^n);

gcodes=gold_pn(n,i_user,handles.pick(1:i_user))/sqrt(2^n-1);

user1tx=randi([0 1],1,2999);

handles.usertx=user1tx;

user1=user1tx;

u1=real(pskmod(user1,2));

gtx=[];wtx=[];

for i_case=1:i_user

gtx1=kron(u1,gcodes(i_case,:));

wtx1=kron(u1,wcodes(i_case,:));

wtx=[wtx;wtx1];gtx=[gtx;gtx1];

End

%........the channel.........

handles.g_s_user=[];

handles.w_s_user=[];

for i_case=1:i_user

handles.g_s_user1=modulate(gtx(i_case,:),900000000,3000000000,'fm');

handles.w_s_user1=modulate(wtx(i_case,:),900000000,3000000000,'fm');

handles.g_s_user=[handles.g_s_user; handles.g_s_user1];

handles.w_s_user=[handles.w_s_user; handles.w_s_user1];

Plate A.8 Multi-user BER Performance over AWGN Channel

Page 76: My Undergraduate Thesis

65

End

g_s_ctx=[];w_s_ctx=[];

for i_case=1:i_user

gcase=handles.g_s_user(i_case,:);

wcase=handles.w_s_user(i_case,:);

g_s_ctx1=awgn(gcase,10,1);

w_s_ctx1=awgn(wcase,10,1);

g_s_ctx=[g_s_ctx;g_s_ctx1];

w_s_ctx=[w_s_ctx;w_s_ctx1];

End

g_out=[];

w_out=[];

for ii=1:2999

g_s_path1=zeros(1,2^n-1);

g_s_path2=zeros(1,2^n-1);

g_s_path3=zeros(1,2^n-1);

w_s_path1=zeros(1,2^n);

w_s_path2=zeros(1,2^n);

w_s_path3=zeros(1,2^n);

for i_case=1:i_user %...multiple signal over awgn channel

g_s_path1=sum([g_s_path1;g_s_ctx(i_case,(1+(ii-1)*(2^n-1):ii*(2^n-1)))]);

g=g_s_ctx(i_case,(1+(ii-1)*(2^n-1):ii*(2^n-1)));

g_s_path2=sum([g_s_path2;[zeros(1,3) g(4:(2^n-1))]]);

g_s_path3=sum([g_s_path3;[zeros(1,5) g(6:(2^n-1))]]);

w_s_path1=sum([w_s_path1;w_s_ctx(i_case,(1+(ii-1)*(2^n):ii*(2^n)))]);

w=w_s_ctx(i_case,(1+(ii-1)*(2^n):ii*(2^n)));

w_s_path2=sum([w_s_path2;[zeros(1,3) w(4:(2^n))]]);

w_s_path3=sum([w_s_path3;[zeros(1,5) w(6:(2^n))]]);

End

%%%% ....FM Demodulation......

g_s_crx=demod(g_s_path1,900000000,3000000000,'fm');

gm_s_crx1=g_s_crx;

gm_s_crx2=demod(g_s_path2,900000000,3000000000,'fm');

gm_s_crx3=demod(g_s_path3,900000000,3000000000,'fm');

w_s_crx=demod(w_s_path1,900000000,3000000000,'fm');

Plate A.8 Multi-user BER Performance over AWGN Channel(cont’d)

Page 77: My Undergraduate Thesis

66

wm_s_crx1=w_s_crx;

wm_s_crx2=demod(w_s_path2,900000000,3000000000,'fm');

wm_s_crx3=demod(w_s_path3,900000000,3000000000,'fm');

%....the receiver..............

%.....multipath detection.....

%......rake receiver despreader operation..........

gm1_s_rx=gm_s_crx1.*gcodes(1,:);

wm1_s_rx=wm_s_crx1.*wcodes(1,:);

gm2_s_rx=gm_s_crx2.*[zeros(1,3) gcodes(1,4:(2^n-1))];

wm2_s_rx=wm_s_crx2.*[zeros(1,3) wcodes(1,4:(2^n))];

gm3_s_rx=gm_s_crx3.*[zeros(1,5) gcodes(1,6:(2^n-1))];

wm3_s_rx=wm_s_crx3.*[zeros(1,5) wcodes(1,6:(2^n))];

gm=gm1_s_rx;

wm=wm1_s_rx;

%....integrate and sum.........

%...........+..............

%........PSK demodulation.......

handles.gm_rx=floor(2*sum(gm)-(gm(1)+gm(2^n-1)));

handles.wm_rx=floor(2*sum(wm)-(wm(1)+wm(2^n)));

handles.gm_rx=pskdemod(handles.gm_rx,2);

handles.wm_rx=pskdemod(handles.wm_rx,2);

%...picking detected bit output

g_out=[g_out handles.gm_rx'];

w_out=[w_out handles.wm_rx'];

End

%....correlating output with input for BER Calculation

g_count=sum(kron(ones(1,1),user1tx)'==g_out');

w_count=sum(kron(ones(1,1),user1tx)'==w_out');

%....BER Calculation........

handles.g_ber(i_use,:)=(2999-g_count)/2999;

handles.w_ber(i_use,:)=(2999-w_count)/2999;

End

semilogy(handles.user,handles.g_ber,'-*',handles.user,handles.w_ber,'-r*');

grid;

title('Multi-user Gold and Walsh over AWGN (L=3)');

legend('Gold-31','walsh-32')

ylabel('BER');

xlabel('K');

Plate A.8 Multi-user BER Performance over AWGN Channel(cont’d)

Page 78: My Undergraduate Thesis

67

% Matlab code for BER Performance over Rayleigh Channel with

% Varying length of codes,

% Gold or Walsh

handles.coding=1:3;

handles.user=1:2;

handles.channel=1:2;

handles.shift_stage=5:8;

handles.current_coding=handles.coding(1);

handles.current_user=handles.user(1);

handles.current_channel=handles.channel(1);

handles.current_shift_stage=handles.shift_stage(1);

handles.snr=-10:2:20;

bitrate=5000000;

raych1=rayleighchan(1/bitrate,80);

g=doppler.gaussian(0.1);

raych1.DopplerSpectrum=g;

raych1.ResetBeforeFiltering=0;

raych1delay=raych1.ChannelFilterDelay;

raych2=rayleighchan(1/bitrate,80,0.1/bitrate,-3);

raych2.DopplerSpectrum=g;

raych2.ResetBeforeFiltering=0;

raych2delay=raych2.ChannelFilterDelay;

raych3=rayleighchan(1/bitrate,80,0.1/bitrate,-3);

raych3.DopplerSpectrum=g;

raych3.ResetBeforeFiltering=0;

raych3delay=raych3.ChannelFilterDelay;

handles.gber=[];

handles.wber=[];

for i_stage=1:numel(handles.shift_stage)

n=handles.shift_stage(i_stage);

wcodes=walsh(n,2,[2^(n-1) 2^n])/sqrt(2^n);

gcodes=gold_pn(n,2,[2^(n-1) 2^n-3])/sqrt(2^n-1);

user1tx=randi([0 1],1,3000);

handles.usertx=user1tx;

user1=user1tx;

u1=real(pskmod(user1,2));

gtx1=kron(u1,gcodes(1,:));

wtx1=kron(u1,wcodes(1,:));

Plate A.9 BER Performance over Rayleigh Channel

Page 79: My Undergraduate Thesis

68

%........the channel.........

handles.g_s_user=gtx1;

handles.w_s_user=wtx1;

handles.g_s_user=modulate(handles.g_s_user,900000000,3000000000,'fm');

handles.w_s_user=modulate(handles.w_s_user,900000000,3000000000,'fm');

handles.gray_ber=zeros(numel(handles.snr),1);

handles.wray_ber=zeros(numel(handles.snr),1);

for i_snr=1:numel(handles.snr)

%.....single path.........

g_s_ctx=awgn(handles.g_s_user,handles.snr(i_snr),1);

w_s_ctx=awgn(handles.w_s_user,handles.snr(i_snr),1);

gray_out=[];

wray_out=[];

for ii=1:3000

%...faded signal over rayleigh channel

gray_s_path1=filter(raych1,g_s_ctx(1+(ii-1)*(2^n-1):ii*(2^n-1)));

gray_s_path2=filter(raych2,g_s_ctx(1+(ii-1)*(2^n-1):ii*(2^n-1)));

gray_s_path3=filter(raych3,g_s_ctx(1+(ii-1)*(2^n-1):ii*(2^n-1)));

gray_s_crx=demod(gray_s_path1,900000000,3000000000,'fm');

gmray_s_crx1=gray_s_crx;

gmray_s_crx2=demod(gray_s_path2,900000000,3000000000,'fm');

gmray_s_crx3=demod(gray_s_path3,900000000,3000000000,'fm');

wray_s_path1=filter(raych1,w_s_ctx(1+(ii-1)*(2^n):ii*(2^n)));

wray_s_path2=filter(raych2,w_s_ctx(1+(ii-1)*(2^n):ii*(2^n)));

wray_s_path3=filter(raych3,w_s_ctx(1+(ii-1)*(2^n):ii*(2^n)));

wray_s_crx=demod(wray_s_path1,900000000,3000000000,'fm');

wmray_s_crx1=wray_s_crx;

wmray_s_crx2=demod(wray_s_path2,900000000,3000000000,'fm');

wmray_s_crx3=demod(wray_s_path3,900000000,3000000000,'fm');

%....the receiver..............

%.......despreader operation.........

Plate A.9 BER Performance over Rayleigh Channel(cont’d)

Page 80: My Undergraduate Thesis

69

%handles.gray_s_rx1=gray_s_crx.*gcodes(1,:);

%handles.wray_s_rx1=wray_s_crx.*wcodes(1,:);

%.....multipath detection.....

%......rake receiver despreader operation..........

gmray1_s_rx=...

gmray_s_crx1.*[gcodes(1,raych1delay+1:2^n-1) zeros(1,raych1delay)];

wmray1_s_rx=...

wmray_s_crx1.*[wcodes(1,raych1delay+1:2^n) zeros(1,raych1delay)];

%....integrate and sum..........

%...........+...................

%........PSK demodulation.......

handles.gmray1_s_rx=...

floor(2*sum(gmray1_s_rx)-(gmray1_s_rx(1)+gmray1_s_rx(2^n-1)));

handles.wmray1_s_rx=...

floor(2*sum(wmray1_s_rx)-(wmray1_s_rx(1)+wmray1_s_rx(2^n)));

handles.gmray_s_rx=pskdemod(handles.gmray1_s_rx,2);

handles.wmray_s_rx=pskdemod(handles.wmray1_s_rx,2);

%...picking detected bit output

gray_out=[gray_out handles.gmray_s_rx'];

wray_out=[wray_out handles.wmray_s_rx'];

End

%....correlating output with input for BER Calculation

gray_count=sum(kron(ones(1,1),user1tx)'==gray_out');

wray_count=sum(kron(ones(1,1),user1tx)'==wray_out');

%....BER Calculation........

handles.gray_ber(i_snr,:)=(3000*ones(1,1)-gray_count)/3000;

handles.wray_ber(i_snr,:)=(3000*ones(1,1)-wray_count)/3000;

End

handles.gber=[handles.gber handles.gray_ber];

handles.wber=[handles.wber handles.wray_ber];

End

semilogy(handles.snr,handles.gber,'-*');

legend('gold-31','gold-63','gold-127','gold-255');

title('gold over rayleigh channel L=3,K=1');

xlabel('SNR');ylabel('BER');

grid;

Plate A.9 BER Performance over Rayleigh Channel(cont’d)

Page 81: My Undergraduate Thesis

70

figure;

semilogy(handles.snr,handles.wber,'-*');

legend('walsh-32','walsh-64','walsh-128','walsh-256');

title('walsh over rayleigh channel L=3,K=1');

xlabel('SNR');ylabel('BER');

Grid

semilogy(handles.snr,[handles.gber(:,1) handles.wber(:,1)],'-*');

grid;

legend('Gold-31','Walsh-32');

title('BER Performance over Rayleigh Channel (K=1,L=3)');

Plate A.9 BER Performance over Rayleigh Channel(cont’d)

Page 82: My Undergraduate Thesis

71

% Matlab code for BER Performance over Rayleigh Channel with

% Varying number of users

handles.coding=1:3;

handles.user=[2 2^2 2^3 2^4];

handles.channel=1:2;

handles.shift_stage=5:8;

handles.current_coding=handles.coding(1);

handles.current_user=handles.user(1);

handles.current_channel=handles.channel(1);

handles.current_shift_stage=handles.shift_stage(1);

handles.snr=0:2:20;

bitrate=5000000;

raych1=rayleighchan(1/bitrate,80);

g=doppler.gaussian(0.1);

raych1.DopplerSpectrum=g;

raych1.ResetBeforeFiltering=0;

raych1delay=raych1.ChannelFilterDelay;

raych2=rayleighchan(1/bitrate,80,0.1/bitrate,-3);

raych2.DopplerSpectrum=g;

raych2.ResetBeforeFiltering=0;

raych2delay=raych2.ChannelFilterDelay;

raych3=rayleighchan(1/bitrate,80,0.1/bitrate,-3);

raych3.DopplerSpectrum=g;

raych3.ResetBeforeFiltering=0;

raych3delay=raych3.ChannelFilterDelay;

handles.gray_ber=zeros(numel(handles.user),1);

handles.wray_ber=zeros(numel(handles.user),1);

for i_use=1:numel(handles.user)

n=5;

i_user=handles.user(i_use);

handles.pick=2:2^n-1;

wcodes=walsh(n,i_user,handles.pick(1:i_user))/sqrt(2^n);

gcodes=gold_pn(n,i_user,handles.pick(1:i_user))/sqrt(2^n-1);

user1tx=randi([0 1],1,1111);

handles.usertx=user1tx;

user1=user1tx;

u1=real(pskmod(user1,2));

gtx=[];wtx=[];

for i_case=1:i_user

Plate A.10 Multi-user BER Performance over Rayleigh Channel

Page 83: My Undergraduate Thesis

72

gtx1=kron(u1,gcodes(i_case,:));

wtx1=kron(u1,wcodes(i_case,:));

wtx=[wtx;wtx1];gtx=[gtx;gtx1];

End

%........the channel.........

handles.g_s_user=[];

handles.w_s_user=[];

for i_case=1:i_user

handles.g_s_user1=modulate(gtx(i_case,:),900000000,3000000000,'fm');

handles.w_s_user1=modulate(wtx(i_case,:),900000000,3000000000,'fm');

handles.g_s_user=[handles.g_s_user; handles.g_s_user1];

handles.w_s_user=[handles.w_s_user; handles.w_s_user1];

End

g_s_ctx=[];w_s_ctx=[];

for i_case=1:i_user

gcase=handles.g_s_user(i_case,:);

wcase=handles.w_s_user(i_case,:);

g_s_ctx1=awgn(gcase,10,1);

w_s_ctx1=awgn(wcase,10,1);

g_s_ctx=[g_s_ctx;g_s_ctx1];

w_s_ctx=[w_s_ctx;w_s_ctx1];

End

gray_out=[];

wray_out=[];

for ii=1:1111

gray_s_path1=zeros(1,2^n-1);

gray_s_path2=zeros(1,2^n-1);

gray_s_path3=zeros(1,2^n-1);

wray_s_path1=zeros(1,2^n);

wray_s_path2=zeros(1,2^n);

wray_s_path3=zeros(1,2^n);

for i_case=1:i_user %...faded signal over rayleigh channel

gray_s_path1=sum([gray_s_path1;filter(raych1,g_s_ctx(i_case,...

(1+(ii-1)*(2^n-1):ii*(2^n-1))))]);

gray_s_path2=sum([gray_s_path2;filter(raych2,g_s_ctx(i_case,...

(1+(ii-1)*(2^n-1):ii*(2^n-1))))]);

gray_s_path3=sum([gray_s_path3;filter(raych3,g_s_ctx(i_case,...

(1+(ii-1)*(2^n-1):ii*(2^n-1))))]);

Plate A.10 Multi-user BER Performance over Rayleigh Channel(cont’d)

Page 84: My Undergraduate Thesis

73

wray_s_path1=sum([wray_s_path1;filter(raych1,w_s_ctx(i_case,...

(1+(ii-1)*(2^n):ii*(2^n))))]);

wray_s_path2=sum([wray_s_path2;filter(raych2,w_s_ctx(i_case,...

(1+(ii-1)*(2^n):ii*(2^n))))]);

wray_s_path3=sum([wray_s_path3;filter(raych3,w_s_ctx(i_case,...

(1+(ii-1)*(2^n):ii*(2^n))))]);

End

%%%%

gray_s_crx=demod(gray_s_path1,900000000,3000000000,'fm');

gmray_s_crx1=gray_s_crx;

gmray_s_crx2=demod(gray_s_path2,900000000,3000000000,'fm');

gmray_s_crx3=demod(gray_s_path3,900000000,3000000000,'fm');

wray_s_crx=demod(wray_s_path1,900000000,3000000000,'fm');

wmray_s_crx1=wray_s_crx;

wmray_s_crx2=demod(wray_s_path2,900000000,3000000000,'fm');

wmray_s_crx3=demod(wray_s_path3,900000000,3000000000,'fm');

%....the receiver..............

%.......despreader operation.........

gmray1_s_rx=...

gmray_s_crx1.*[gcodes(1,raych1delay+1:2^n-1) zeros(1,raych1delay)];

wmray1_s_rx=...

wmray_s_crx1.*[wcodes(1,raych1delay+1:2^n) zeros(1,raych1delay)];

%....integrate and sum.........

%...........+..............

%........PSK demodulation.......

handles.gmray1_s_rx=...

floor(2*sum(gmray1_s_rx)-(gmray1_s_rx(1)+gmray1_s_rx(2^n-1)));

handles.wmray1_s_rx=...

floor(2*sum(wmray1_s_rx)-(wmray1_s_rx(1)+wmray1_s_rx(2^n)));

handles.gmray_s_rx=pskdemod(handles.gmray1_s_rx,2);

handles.wmray_s_rx=pskdemod(handles.wmray1_s_rx,2);

%...picking detected bit output

gray_out=[gray_out handles.gmray_s_rx'];

wray_out=[wray_out handles.wmray_s_rx'];

End

Plate A.10 Multi-user BER Performance over Rayleigh Channel(cont’d)

Page 85: My Undergraduate Thesis

74

%....correlating output with input for BER Calculation

gray_count=sum(kron(ones(1,1),user1tx)'==gray_out');

wray_count=sum(kron(ones(1,1),user1tx)'==wray_out');

%....BER Calculation........

handles.gray_ber(i_use,:)=(1111-gray_count)/1111;

handles.wray_ber(i_use,:)=(1111-wray_count)/1111;

End

semilogy(handles.user,[handles.gray_ber handles.wray_ber],'-*');

grid;

title('Multi-user Gold and Walsh over Rayleigh Channel (L=3)');

legend('Gold-31','walsh-32')

ylabel('BER');

xlabel('K');

Plate A.10 Multi-user BER Performance over Rayleigh Channel(cont’d)