Gold Seq Project

download Gold Seq Project

of 23

Transcript of Gold Seq Project

  • 8/3/2019 Gold Seq Project

    1/23

    NATIONAL INSTITUTE OF TECHNOLOGY, DURGAPUR

    Gold Code SequencesProject Report

    2007-2008| Mohammed Zishan Ansari

    04/351| Shobhit Mangla

    04/355

    | Arijit Chattopadhyaya04/356

    | Deepak Gahlawat04/389

    | Puneet Shah04/390

    | Vaibhav Singh04/404

  • 8/3/2019 Gold Seq Project

    2/23

    2

    Acknowledgement

    We would like to express our gratitude to our Project guide Mr. A. Chandra for giving us

    the opportunity and suggesting us a very useful topic to be taken as the final year B.Tech

    project for the academic session 2007-2008. The work which we have done in this project

    wouldnt have been possible without his support. He guided us by enlightening our path

    through out the project and his attitude has been a moral booster for all of us and we could

    complete the project in stipulated time. It has been a pleasure to be working under him, and

    we would like to thank him for his support and guidance. Looking forward, to his support in

    all future endeavors.

  • 8/3/2019 Gold Seq Project

    3/23

    3

    IndexSl.

    No.Topic Page no.

    1. Acknowledgment 2

    2. Abstract 4

    3. Introduction 5

    4. Theory

    Spread Spectrum Fundamentals 5

    DSSS and FHSS 68

    Ways of generation of PN Sequence 9

    Maximal Length PN Sequence 10

    Gold Code 105. Transmitter Block 11

    6. Receiver Block 12

    7. Matlab Program & simulation for Baseband DSSS 1317

    8. Cross and Auto correlation of gold and PN sequences 18

    9. Matlab Program & simulation for cross & auto correlation 1821

    10. Conclusion 22

    11. Bibliography 23

    ABSTRACT:

  • 8/3/2019 Gold Seq Project

    4/23

    4

    In modern communication systems, spread spectrum is playing an increasingly important

    role day by day due to its inherent advantages like noise immunity and also due its practical

    applications like mobile communications in CDMA. Our project is in accordance with this

    increasingly important communication technology. This project aims to Generate Gold Code

    sequence and modulate a message signal to produce a corresponding spreaded baseband

    modulated signal which is actually used in much higher proportions for transmission of

    voice and data signals in technologies like CDMA. The project also incorporates a receiver

    unit which demodulates the entire received signal with the assistance of the same gold code

    to generate the original message signal. An addition to this primary aim of our project is to

    study the cross correlation of two Gold Codes sequences and two Pseudo Noise sequences to

    ascertain which is a better tool for modulating the given message signal in terms of better

    noise immunity and security with the help of graphs using the MATLAB programming

    language.

  • 8/3/2019 Gold Seq Project

    5/23

    5

    I. Introduction

    As the wireless personal communications field has grown over the last few years, the method ofcommunication 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 sendthe 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 personalcommunications recently. Spread spectrum methods can be combined with Code Division Multiple Access

    (CDMA) methods to create multi-user communications systems with very good interference performance.This paper will cover the details behind the method of Spread Spectrum communications, as well as analyze

    two main types of Spread Spectrum systems, Direct-Sequence Spread Spectrum (DS-SS) and Frequency-Hopped Spread Spectrum (FH-SS). Finally, a general comparison between the two will be given, trying to

    indicate the positives and negatives for each with respect to the other, and to indicate when one mightsystem might be preferable over the other.

    II. Spread Spectrum

    As stated before, spread spectrum systems afford protection against jamming (intentional interference) and

    interference from other users in the same band as well as noise by spreading the signal to be transmitted

    and performing the reverse de-spread operation on the received signal at the receiver. This de-spreadingoperation in turn spreads those signals which are not properly spread when transmitted, decreasing the effect

    that spurious signals will have on the desired signal.Spread Spectrum systems can be thought of as having two general properties: first, they spread the desired

    signal over a bandwidth much larger than the minimum bandwidth needed to send the signal, and secondly,this spreading is carried out using a pseudorandom noise (PN) sequence. In a general sense, we will see that

    the increase in bandwidth above the minimum bandwidth in a spread spectrum system can be thought of asapplying gain to the desired signal with respect to the undesirable signals. We can now define the processing

    gain GP as

    Where BWRFis 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 the improvementover conventional communication schemes due to the spreading done on the signal. Often, a better measure

    of this gain is given by thejamming margin,

    MJdB=GPdBSNRminWhich indicates the amount of interference protection offered before the signal is corrupted.

    The spreading function is achieved through the use of a pseudorandom noise sequence (PN sequence). Thedata signal is combined with the PN sequence such that each data bit is encoded with several if not all thebits 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 encodeeach 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.

    To see how the spreading process helps protect the signal from outside interference, let us look at the typesof interference that are possible. The three major types of interference that can arise when using wireless

    networks are: (1) noise, (2) intentional interference from a jammer or other source trying to disrupt

  • 8/3/2019 Gold Seq Project

    6/23

    6

    communications, and (3) unintentional interference from other users of the same frequency band. Noise canbe considered as background white Gaussian noise (WGN), and can be said to have power spectral density

    N0. 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 thesystem, which might be seen as detrimental. However, we will see that this is not really a problem.

    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 betweenintentional 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, 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 datasignal.

    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 the technique of CDMA to combat

    this type of interference. In a wireless communications network, all the signals propagate through the air byway of electromagnetic waves, thus there is no way to ensure that one user will receive only the signal he orshe 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) which is orthogonal to the other codes used in thatband, the effect of these other signals will effectively be zero 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 willRemain).

    The following sections will analyze and derive the specifics of the two major types of spread spectrumsystems, Direct Sequence and Frequency Hop. Since the mechanisms by which the above advantages are

    achieved vary between the two methods, the analysis has been left until those sections.

    III. Direct Sequence Spread Spectrum (DS-SS)

    Direct Sequence Spread Spectrum (DS-SS) is the most common version of spread spectrum in use today,

    due to its simplicity and ease of implementation. The two major spread spectrum methods differ mainly inthe way the encode the data with the PN sequence. In DS-SS, the carrier (data signal) is modulated by the

    PN code sequence, which is of a much higher frequency than the desired data rate.

    Let f be the frequency of the data signal, with appropriate pulse time T=1/f. Let the PN sequence betransmitted at a ratefc, so that the increase in the data rate is fc/f. The frequencyfc is known as the chipping

    rate, with each individual bit in the modulating sequence known as a chip. Thus the width of each pulse inthe modulating sequence is TC, or a chip time. The following figure illustrates the two signals, the data

    signal for one pulse width, and the PN sequence over the same time (since the PN sequence takes values of1, the indicated PN sequence also indicates a normalized version of the signal to be transmitted).

  • 8/3/2019 Gold Seq Project

    7/23

    7

    As a result, the frequency domain will look something like the diagram shown in Figure 2.

    Mathematically, the following happens. Let the data signal be D(t), transmitted at frequency f, and let the

    PN sequence be PN(t), with frequencyfc. So the transmitted signal is

    The PN sequence is designed such that it has very good autocorrelation properties:

    Where N is the length of the PN sequence, therefore, when the signal is correlated with the PN sequence at

    the receiver, the received signal will be recovered exactly (assuming that there is synchronization betweenthe send and receive PN sequences), i.e.

  • 8/3/2019 Gold Seq Project

    8/23

    8

    Now, if we allow both noise and a jamming signal J(t) with finite power distributed evenly across thefrequency band, the received signal at the input to the receiver, Y(t), is

    .

    Now, when the signal is correlated with the PN sequence, the data signal portion of Y(t) is de-spread givingus the original D(t). However, the effect of multiplying J(t) and N(t) with the signal in effect spreads the

    signal out to have bandwidthfc, whereas the signalD(t) now has returned to its original frequencyf=1/T. Soa 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 wasintroduced earlier as the processing gain GP, i.e. GP=(BWRF/BWinfo)=(fc/f).

    So we see that the data signal has been made immune to the effect of a malevolent third party jammer. As

    stated earlier, even though a factor offC/fmore noise was let into the system by the increased bandwidth, theeffect of that noise was also reduced by fc/f due to the processing gain of the system, and thus the effect of

    WGN has not been increased by this DSSS system.

    IV. Frequency-Hopped Spread Spectrum (FH-SS)

    Frequency-Hopped Spread Spectrum is the other major type of spread spectrum system in use today. In

    FHSS, the signal itself is not spread across the entire large bandwidth; instead the wide bandwidth is dividedinto N sub-bands, and the signal hops from one band to the next in a pseudorandom manner. The center

    frequency of the signal changes from one hop to the next, changing from one sub-band to another, as shownin Figure 4.

    As we can see, a large frequency band of width Nfb centered at FC has been divided into N sub-bands ofwidth fb. The bandwidth fb must enough to transmit the data signal D(t), and at a predetermined time

    interval, the center frequency of the data signal is changed from one sub-band to another in a pseudorandom

    manner. In the example given in the diagram, the data signal hops from band N (FC+(N/2)fb f

    FC+(N/2)fbto band 2 to band N-2, and so on. Usually, the width of each sub-band is set so that the

    amount of signal that overlaps with adjacent sub-bands is minimal, and is thus approximately the bandwidthof the original data signal.

    Two different kinds of FH-SS are used; slow FH and fast FH. In slow FH-SS, several bits are sent for eachhop, so the signal stays in a particular sub-band for a long time relative to the data rate. In fast-SS, the

  • 8/3/2019 Gold Seq Project

    9/23

    9

    reverse is true. The signal switches sub-bands several times for each bit transmitted, so the signal stays in asub-band for a very short time relative to the data rate. There are people who say that slow FH is not really a

    spread spectrum technique, since this does not really spread the system (since the time spent in one sub-band is very large, the corresponding width of the band can be small, thus possibly violating the first tenet

    of a spread spectrum system, namely that the spread bandwidth must be much greater than the un spreadbandwidth).

    In the fast FH case, again, the performance of the system with respect to white Gaussian Noise is notchanged, as in the DS-SS case. The noise power seen at the receiver is approximately the same as that in the

    un-hopped case, since each sub-band is approximately the same size as the original data signals bandwidth.And just as in the DS-SS case, the effect of a jammer is decreased by the spreading of the signal. Here, if we

    again assume that the jamming signal J(t) is distributed uniformly over the entire band, it is clear that theonly portion of the jamming signal that affects the data is the part within the band of width fb, and thus the

    jamming signal is reduced by the factor of the processing gain Gp which here is.

    Thus in the frequency hop case, the protection afforded is equal to the number of frequency bands used.

    However, in this case, the best way for a jammer to disrupt the signal is NOT to spread his power equallyover the entire band, but to concentrate his power among a few bands. In this case, the jammer is more

    effective, because he can assuredly disrupt certain bits of data. The probability of a bit being in error is thengiven byp=J/N, where J is the number of channels selectively jammed, and N is the number of frequencies

    available to the hopper, which is basically the probability that the jammer guessed which frequencies to jam correctly. This can still give high bit error rates (BER). For example, a possible scenario would be

    where the jammer jams 10 out of a possible 1000 frequencies, giving a highly unacceptable BER of 10 -2.

    However, fast FH allows us to very simply decrease the BER. If we choose to have a large number of chips

    per bit (here a chip represents a hop), then we can use a simple majority function to determine what the bitsent was. We are assuming that the number of available hop channels is a good deal larger than the numberof channels being jammed (define a successful jamming as when the power of the jamming signal is greater

    than or equal to that of the data signal). If the simple majority function is being used, then the formula forthe error rate becomes

    where c is the number of chips per bit (hops per bit), ris the number of chip errors necessary to cause a biterror (for a simple majority function, this is just c/2 rounded to the nearest integer),p is the probability of 1

    bit error (J/N), and q is the probability of no error for a chip, or 1-p. By just increasing the number of chipsper bit from 1 to 3 (thus ris 2) for our previous example, we find that the error rate is now

    Thus by just increasing the hopping rate from once per bit to three times per bit, the bit error rate can bedecreased dramatically. So the immunity to jamming provided by spread spectrum works in the FH-SS

    system as well, even for the clever jammer who tailors his interference to the particular system. The only

  • 8/3/2019 Gold Seq Project

    10/23

    10

    penalty to be paid here is the increased frequency with which the spread signal must be sent, and with thestate of technology today, that is easily surmounted.

    The PN sequence is used here to determine the hopping sequence. So in order to transmit the signal, the datasignal must be modulated up the center frequency of the band determined by the PN sequence. Therefore,

    the structure of the transmitter is as shown in Fig 5a. The Data signal is modulated up to the transmitfrequency by the frequency produced by the frequency synthesizer, which takes as its input the output of the

    PN sequence generator (a band-pass filter is also required at the output of the transmitter - it was omitted tosimplify the structure). The receiver structure is simply the reverse of the transmitter. The frequency

    synthesizer demodulates the signal down to an intermediate frequency (or base-band if desired), then thesignal is filtered so only the desired data signal is passed through, and finally the signal is decoded. Again,

    to get multiple users using the same wide frequency band, CDMA techniques must be used.

    V. Gold Sequences

    Gold sequences help generate more sequences out of a pair of m-sequences giving now many more differentsequences to have multiple users. Gold sequences are based on preferred pairs m-sequences. For example,

    take the polynomials and :

    Figure: Example of gold sequence generator using one preferred pair of m-sequences: and

    Remember m-sequences gave only one sequence of length . By combining two of these sequences, we

    can obtain up to 31 ( ) plus the two m-sequences themselves, generate 33 sequences (each one

    length ) that can be used to spread different input messages (different users CDMA).

    The m-sequence pair plus the Gold sequences form the available sequences to use in DSSS.

    The wanted property about Gold codes is that they are balanced (i.e. same number of 1 and -1s).

  • 8/3/2019 Gold Seq Project

    11/23

    11

    TRANSMITTER BLOCK

    The Transmitter part of the Matlab program had the following three basic blocks :-

    1) Generation of the message signal using the rand function of Matlab which generates a random arrayof numbers and stores them in a matrix of given dimension.

    2) Generation of Gold Code with the help of two PN (Pseudo Noise) sequences PN1 and PN2.3) Modulation of the message signal generated in step 1 with the Gold Code produced in step 2 to

    produce the Base Band modulated signal.

    Block Diagram of Transmitter

    GENERATION of GOLD CODE sequences

    The steps that were followed to generate the gold code are :-

    Two PN sequences PN1 and PN2 are produced, each of 20 bit long by XORing specificfollowing aprescribed pattern and shifting each of them continuously.For PN1 the XORing pattern was by taking bit1, 4, 6, 7, 13, 19For PN2 the XORing pattern was by taking bit1, 2, 3, 5, 7, 9, 10, 13, 14, 16, 17

    Each output bit from the two sequences were XORed and stored in an array called gold.

    MODULATOR

    GOLD CODE

    GENERATOR

    MESSAGE SIGNAL BASE BAND

    modulated SIGNAL

  • 8/3/2019 Gold Seq Project

    12/23

    12

    Modulation of the Message signal with GOLD Code

    The basic idea behind modulation was that we have to replace each 0 in the 20 bit message signal with the

    Original Gold Code and each 1 in the message signal with the Inverted 20 bit Gold Code thus converting the20 bot message signal into a 400 (20 x 20) bit spreaded signal.

    Message signal :

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

    Gold Code:

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

    Spreaded Signal:

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

    RECEIVER BLOCK

    What we are doing in receiver is that we are simply demodulating the received spreaded signal with the goldcode to produce the original message signal.

    Steps for DEMODULATION are:

    Since both the original message signal as well as the gold code are 20 bit long, we xor eachsuccessive 20 bit of the received spreaded signal with the 20 bit gold code and store the result in anarray.

    Since each 20 bit block of the message signal consists of either the gold code or the inverted goldcode, XORing with the gold code will give us a result either 0 or 1.

    If the result is 0, then we store 0 in an array called despreaded_signal and if the result is 1, we store1.

    The process is repeated for each set of 20 bit till all the 400 bits of the received signal are covered. The array despreaded signal ultimately gives us the original message signal.

    DEMODULATOR

    GOLD CODEGENERATOR

    RECEIVED SIGNAL MESSAGE SIGNAL

  • 8/3/2019 Gold Seq Project

    13/23

    13

    MATLAB Code for BASE BAND DSSS using Gold Code:

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    BASE BAND Direct Sequence Spread Spectrum using GOLD CODE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    clc;clear all;close all;%--------------------------------------------------------------------------%------------------------------TRANSMITTER-----------------------%--------------------------------------------------------------------------

    % Generating the bit pattern with each bit 6 samples longb=round(rand(1,20));pattern=[];for k=1:20

    if b(1,k)==0sig=zeros(1,6);

    elsesig=ones(1,6);

    endpattern=[pattern sig];

    endb1=b;message = b1message1 = pattern;subplot(3,2,1);

    plot(pattern);

    axis([-1 120 -.5 1.5]);

    ylabel('\bf Original Bit Sequence');title('\bf\it TRANSMITTED MESSAGE');%--------------------------------------------------------------------------% Generation of Gold code No. 1G=20; % Code lengthK=1; % Number of Codes or code sequences%..............Generation of first PN sequence...............

    lsr1 =randsrc(1,20,[0 1]);PN1=[];for j=1:G

    PN1=[PN1 lsr1(1)];temp1 = xor(lsr1(4),lsr1(1));temp2 = xor(lsr1(6),temp1);temp3 = xor(lsr1(7),temp2);temp4 = xor(lsr1(13),temp3);temp5 = xor(lsr1(19),temp4);

    for i=1:G-1lsr1(i)=lsr1(i+1); %----Shifting----

    endlsr1(20)=temp5;

    end%..............Generation of Second PN sequence..............

    lsr2 =randsrc(1,20,[0 1]);PN2=[];

    for j=1:GPN2=[PN2 lsr2(1)];temp1 = xor(lsr2(2),lsr1(1));temp2 = xor(lsr2(3),temp1);temp3 = xor(lsr2(5),temp2);temp4 = xor(lsr2(7),temp3);temp5 = xor(lsr2(9),temp4);temp6 = xor(lsr2(10),temp5);

    temp7 = xor(lsr2(13),temp6);

  • 8/3/2019 Gold Seq Project

    14/23

    14

    temp8 = xor(lsr2(14),temp7);temp9 = xor(lsr2(16),temp8);temp10 = xor(lsr2(17),temp9);temp11 = xor(lsr2(19),temp10);for i=1:G-1

    lsr2(i)=lsr2(i+1); %----Shifting----

    endlsr2(20)=temp11;

    end%..............Generation of Gold Codes....................Code_Matrix=[];for codes=1:K

    code=[];

    for j=1:Gcode=[code xor(PN1(j),PN2(j))];

    endCode_Matrix=[Code_Matrix code'];

    endgold_1 = Code_Matrix';Gold_Code = gold_1pattern=[];

    for k=1:20if gold_1(1,k)==0

    sig=zeros(1,6);else

    sig=ones(1,6);endpattern=[pattern sig];

    end

    gold = pattern;

    subplot(3,2,3);plot(gold);axis([-1 120 -.5 1.5]);ylabel('\bf Gold Code');%---------------------------------------% b1 = Message Matrix (1,20)% gold_1 = Gold Matrix (1,20)%---------------------------------------

    % Spreading the pattern with the gold codek=1;for i=1:20

    for j=1:20spread(1,k)=xor(b1(1,i),gold_1(1,j));k=k+1;

    endend

    spread;subplot(3,2,5);plot(spread);axis([-1 400 -.5 1.5]);ylabel('\bf Spreaded Sequence');

    %--------------------------------------------------------------------------

    %--------------------------------------------------------------------------

    %--------------------------------RECEIVER----------------------------%--------------------------------------------------------------------------subplot(3,2,2);plot(spread);axis([-1 400 -.5 1.5]);ylabel('\bf Received Sequence');title('\bf\it RECEIVED MESSAGE');

    %------GOLD CODE sequence used-----gold_2=gold_1;pattern=[];for k=1:20

  • 8/3/2019 Gold Seq Project

    15/23

    15

    if gold_2(1,k)==0sig=zeros(1,6);

    elsesig=ones(1,6);

    end

    pattern=[pattern sig];

    endgold = pattern;

    subplot(3,2,4);plot(gold);axis([-1 120 -.5 1.5]);ylabel('\bf Gold Code');

    %-------Demodulation to get original message signal---------gold_2inv = xor(1,gold_2);i=1;k=1;while k < 400

    s=0;for j=1:20

    temp(1,j) = xor(spread(1,k),gold_2(1,j));

    k=k+1;s=s+temp(1,j);

    endif(s==0)

    b2(1,i) = 0;else

    b2(1,i) = 1;

    end

    i=i+1;

    enddespreaded_signal = b2

    %-----Plotting Despreaded signal------pattern=[];for k=1:20

    if b2(1,k)==0sig=zeros(1,6);

    elsesig=ones(1,6);

    endpattern=[pattern sig];

    endsubplot(3,2,6);plot(pattern);axis([-1 120 -.5 1.5]);

    ylabel('\bf Despreaded Sequence');

    % Plotting the FFT of DSSS signal% figure,plot([1:400],abs(fft(spread)),[1:20],abs(fft(b2)))

  • 8/3/2019 Gold Seq Project

    16/23

    16

    MATLAB Simulation result:

    Modulation of message signal

    Waveforms for the Transmitter

  • 8/3/2019 Gold Seq Project

    17/23

    17

    MATLAB Simulation result:

    Demodulation of received signal

    Waveforms for the Receiver

  • 8/3/2019 Gold Seq Project

    18/23

    18

    Cross Correlation of Gold Code 1 & 2 and PN sequence 1 & 2

    This part is an addition to the original aim of the project which was to generate gold code and modulate a

    message signal and subsequently demodulate the received signal to get the original message signal.

    We need cross correlation of the 2 gold codes and 2 PN sequences to judge which one is better formodulating a signal for spread spectrum base band transmission in terms of randomness and hence in terms

    of better noise reduction and interference.

    To generate the gold code we use a prescribed sequence of XOR operation for the two PN sequences. Theyare :-

    For PN code 1 i.e. PN1 :- bits 1, 2, 3, 4, 7, 8

    For PN code 2 i.e. PN2 :- bits 1, 3, 5, 6, 7, 8

    Here in order to take a maximal length PN sequence, we have used the PN sequences as well as Gold Code

    of 8 bits.During Plotting we take 5 consecutive sets of both gold codes so that the ultimate cross correlation takes

    place between two gold codes each of 40 bit length and two PN sequences of 40 bit length.

    MATLAB Code for Cross and Auto Correlation of GOLD CODE 1 & 2 and

    Cross correlation of PN sequence 1 & 2

    %-----------------------------------------------%

    % CROSS and AUTO Correlation of GOLD CODE 1 & 2 %%-----------------------------------------------%

    clc;

    clear all;close all;%--------------------------------------------------------------------------% Generation of Gold codes

    G=8; % Code lengthK=2; % Number of Codes or code sequencesx=[];y=[];%..............Generation of first PN sequence...............Code_Matrix=[];

    for codes=1:Klsr1 =randsrc(1,8,[0 1]);PN1=[];for j=1:G

    PN1=[PN1 lsr1(1)];temp1 = xor(lsr1(1),lsr1(2));temp2 = xor(lsr1(3),temp1);temp3 = xor(lsr1(4),temp2);

    temp4 = xor(lsr1(7),temp3);temp5 = xor(lsr1(8),temp4);for i=1:G-1

    lsr1(i)=lsr1(i+1); %----Shifting----endlsr1(G)=temp5;

    end

  • 8/3/2019 Gold Seq Project

    19/23

    19

    %..............Generation of Second PN sequence..............lsr2 =randsrc(1,8,[0 1]);PN2=[];for j=1:G

    PN2=[PN2 lsr2(1)];

    temp1 = xor(lsr2(1),lsr1(3));

    temp2 = xor(lsr2(5),temp1);temp3 = xor(lsr2(6),temp2);

    temp4 = xor(lsr2(7),temp3);temp5 = xor(lsr2(8),temp4);for i=1:G-1

    lsr2(i)=lsr2(i+1); %----Shifting----end

    lsr2(G)=temp5;endcode=[];for j=1:G

    code=[code xor(PN1(j),PN2(j))];endCode_Matrix=[Code_Matrix code'];if codes==1

    x=code;else

    y=code;end

    endgold = Code_Matrix%--------------------------------------------------------------------------

    i=1;

    n=5;

    for k=1:nfor j=1:8

    gold_x(i)=x(j);i=i+1;

    endendi=1;for k=1:n

    for j=1:8gold_y(i)=y(j);i=i+1;

    endendi=1;for k=1:n

    for j=1:8

    PNS1(i)=PN1(j);i=i+1;

    endendi=1;

    for k=1:n

    for j=1:8PNS2(i)=PN2(j);

    i=i+1;end

    endM=i-1;%---------------------------------PLOTTING----------------------------------------l1 = M-1;l2 = M-1;l=-max(l1,l2):max(l1,l2);

    rxy=xcorr(gold_x,gold_y);subplot(4,1,1);plot(l,rxy);title('\bf\it Cross Correlation of Gold Code 1 & 2');

  • 8/3/2019 Gold Seq Project

    20/23

    20

    p=-l1:l1;rxx=xcorr(gold_x);subplot(4,1,2);plot(p,rxx);

    title('\bf\it Auto correlation of Gold Code 1');

    q=-l2:l2;

    ryy=xcorr(gold_y);subplot(4,1,3);plot(q,ryy);title('\bf\it Auto correlation of Gold Code 2');

    p=-l1:l1;rx=xcorr(PNS1,PNS2);subplot(4,1,4);plot(l,rx);title('\bf\it Cross correlation of PN1 and PN2');

    Output of Matlab program

    0 1

    0 10 1

    1 1

    0 0

    0 00 1

    1 1

    Here,

    Gold Code # 1 : 0 0 0 1 0 0 0 1

    Gold Code # 1 : 1 1 1 1 0 0 1 1

  • 8/3/2019 Gold Seq Project

    21/23

    21

    MATLAB Simulation result:

  • 8/3/2019 Gold Seq Project

    22/23

    22

    CONCLUSION:

    From the above results and Graphs we can safely conclude the following :

    1) We have successfully generated a Gold Code of 20 bit length and modulated a message signal, also of20 bit length with the Gold Code to produce a spreaded signal of length 400 bits.

    We have also successfully demodulated the spreaded signal using the same Gold Code sequence to

    produce the original message signal.

    2) We have successfully shown the following in the graphs representing the cross correlation and autocorrelation of two Gold Code sequences and cross correlation of two PN sequences :-

    Symmetrical Auto correlation to ensure the validity of the gold codes.

    Better Auto correlation of the Gold Codes over the PN sequences, thus proving that Gold Code ismore suitable for modulation and spreading of a message signal than the Pseudo Noise

    sequences.

  • 8/3/2019 Gold Seq Project

    23/23

    23

    Bibliography

    [1] Raymond L. Pickholtz, Donald L. Schilling, Laurence B. Milstein. Theory of SpreadSpectrum Communications -- A Tutorial, IEEE Transactions on Communications, Vol.

    COM-30, May 1982, pp. 855-884.[2] Robert C. Dixon. Spread Spectrum Communications, Second Edition, John Wiley and

    Sons, New York, 1984.[3] Edward A. Lee, David G. Messerchmitt, Digital Communications, Second Edition,

    Kluwer Academic Publishers, USA, 1994.

    [4] Marcus C. Wlden, Roger D. Pollard. On the Processing Gain and Pulse Compression

    Ratio of Frequency Hopping Spread Spectrum Waveforms, IEEE National TelesystemsConference Proceedings, 1993, pp. 215-219.

    [5] T.S.D. Tsui, T.G. Clarkson. Spread Spectrum Communication Techniques, Electronicsand Communication Engineering Journal, Februaru 1994.

    [6] Laurence B. Milstein, Donal L. Schilling. The Effect of Frequency-Selective Fading on a

    Noncoherent FH-FSK System Operating with partial Band Tone Interference , IEEETransactions on Communications, Vol. COM-30, May 1982, pp. 904-912.