Sie sind auf Seite 1von 52

THE UNIVERSITY OF NAIROBI

DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

PROJECT TITLE: ACQUISITION OF DIRECT-SEQUENCE SPREAD-SPECTRUM


SIGNALS
PROJECT CODE: PRJ011
NAME: JOSEPH KIBUGI CHEGE
REGISTRATION NUMBER: F17/1408/2011
SUPERVISOR: PROF. V.K. ODUOL
EXAMINER: DR. P. AKUON

This project report is submitted in partial fulfilment of the requirement for the award of the
degree of Bachelor of Science in Electrical and Electronic Engineering of the University of
Nairobi.

Date of Submission: 13th May, 2016


ii

DECLARATION OF ORIGINALITY

NAME OF STUDENT: Joseph Kibugi Chege


REGISTRATION NUMBER: F17/1408/2011
COLLEGE: Architecture and Engineering
FACULTY: Engineering
DEPARTMENT: Electrical and Information Engineering
COURSE NAME: Bachelor of Science in Electrical and Electronic
Engineering
PROJECT TITLE: ACQUISITION OF DIRECT-SEQUENCE SPREAD-
SPECTRUM SIGNALS
PROJECT CODE: PRJ011

1. I understand what plagiarism is and I am aware of the university policy in this regard.
2. I declare that this final year project report is my original work and has not been submitted
elsewhere for examination, award of a degree or publication. Where other people’s work
or my own work has been used, this has been properly acknowledged and referenced in
accordance with the University of Nairobi’s requirements.
3. I have not sought or used the services of any professional agencies to produce this work.
4. I understand that any false claim in respect of this work shall result in disciplinary action,
in accordance with University anti-plagiarism policy.

Signature:

Date: 13th May, 2016.


iii

CERTIFICATION

This report was submitted to the Department of Electrical and Information Engineering,
University of Nairobi, with my approval as supervisor:

……………………………….
PROF. VITALICE K. ODUOL
Date…………………………………….
iv

ACKNOWLEDGEMENT
I would like to thank my supervisor, Prof. V. K. Oduol, without whom this work would not be
possible. His availability and ideas gave me the motivation I needed to complete this work.
Many thanks to my parents and siblings who supported me and put up with my frequent absence
as I worked on this project.
Finally, immense gratitude to the Almighty God, to whom all glory and honour rightly belongs.
v

LIST OF FIGURES
Figure 1: Feedback shift register. 5
Figure 2: PN sequence waveforms. Autocorrelation function (top). 6
Power spectral density (bottom).
Figure 3: DS-SS waveforms. Binary data (top). PN sequence (mid). 9
Spread binary data (bottom).
Figure 4: DS baseband model. Transmitter (top left). Channel (top right). 10
Receiver (bottom).
Figure 5: DS passband transmitter model. 11
Figure 6: DS passband receiver model. 12
Figure 7: Received DS signal. a) Before despreading. b) After despreading. 13
Figure 8: Block diagram of code synchronization system. 14
Figure 9: Digital matched filter. 16
Figure 10: Serial-search acquisition. 17
Figure 11: Block diagram of a non-coherent correlator 18
Figure 12: Delay-locked loop 19
Figure 13: Block diagram of DS-SS system 22
Figure 14: Block diagram of transmitter 22
Figure 15: PN generator 23
Figure 16: User data (top). PN sequence (bottom). 23
Figure 17: Spectrum of binary data (top). Spectrum of the spread signal (bottom). 24
Figure 18: Block diagram of receiver. 25
Figure 19: Transmitted (top) and received (bottom) waveforms. 25
Figure 20: Block diagram of synchronization system. 26
Figure 21: Block diagram of non-coherent correlator. 27
Figure 22: Threshold detector. 27
Figure 23: Output of threshold detector. 28
vi

Figure 24: Block diagram of tracking system. 28


Figure 25: Output of VCO. 29
Figure 26: Block diagram of search control unit. 29
Figure 27: Normal clock (top). Synchronized clock (bottom). 30
Figure 28: Transmitter PN sequence (top). Receiver PN sequence (bottom). 31
Figure 29: Error rate calculator and display. 32
Figure 30: Jittery clock in transmitter PN generator. 32
Figure 31: Jittery clock generator. 33
Figure 32: Jittery clock output. 33
Figure 33: BER performance. 36
vii

LIST OF TABLES
Table 1: Generator polynomials 7
Table 2: Characteristics of Gold sequences 8
Table 3: BER performance for system with normal clock 35
Table 4: BER performance for system with jittery clock 35
viii

TABLE OF CONTENTS

Declaration of Originality ii
Certification iii
Acknowledgement iv
List of Figures v
List of Tables vii

1 Introduction 1
1.1 Abstract 1
1.2 Problem Definition 1
1.3 Objectives 1
1.4 Scope 1
1.5 Justification 2
1.6 Report Organization 2

2 Literature Review 3
2.1 Spread-Spectrum Communication Systems 3
2.1.1 Origins 3
2.1.2 Definitions and Concepts 3
2.2 Direct-Sequence Spread-Spectrum Systems 4
2.2.1 Pseudo-Noise (PN) Sequences 4
2.2.2 Gold Sequences 8
2.2.3 Spectrum Spreading in DS-SS 9
2.2.4 DS-SS with Coherent Binary Phase-Shift Keying 11
2.3 Code Synchronization 13
2.3.1 Code Acquisition 14
2.3.2 Acquisition Methods 16
2.3.2.1 Matched-Filter Acquisition 16
2.3.2.2 Serial-Search Acquisition 17
ix

2.3.3 Code Tracking 18


2.4 Application of Spread Spectrum: CDMA 19

3 System Description 21
3.1 Model Realization 21
3.2 Description of DS-SS system 21
3.2.1 Transmitter Architecture 22
3.2.2 Channel 25
3.2.3 Receiver Architecture 25
3.2.4 Synchronization System 26
3.2.4.1 Acquisition System 26
3.2.4.2 Tracking System 28
3.2.4.3 Search Control Unit 29
3.2.5 Blocks for Performance Testing 31

4 System Performance 34
4.1 Theoretical BER for BPSK 34
4.2 Performance of DS-SS System 34

5 Conclusion 38

APPENDICES
A MATLAB S-Function File for Jittery Clock 39
B Abbreviations and Acronyms 42
C References 43
1

1. Introduction

1.1. Abstract

Spread-spectrum communication systems have been found to be extremely efficient at


attenuating interference and have found wide usage, from their early application in the
military to their current application in multiple-access systems such as code division
multiple access (CDMA). However, for a spread-spectrum system to work well,
synchronization of the spreading code at the transmitter and receiver must be achieved.
This project investigates one of the aspects of synchronization, referred to as acquisition,
with specific regard to one type of spread-spectrum system: so-called direct-sequence
spread-spectrum (DS-SS) system. The goal is to design a code acquisition method and to
demonstrate that it works.

1.2. Problem Definition

Synchronization of the spreading code is of utmost importance in any spread-spectrum


system. The proper operation of the system depends on how well synchronization is done.
A solution to the synchronization problem consists of two parts, referred to as acquisition
and tracking. Acquisition may be regarded as coarse synchronization and, being the first
step in the synchronization procedure, must work very efficiently, after which tracking
can be performed and synchronization ultimately achieved. This project focuses on the
problem of designing an efficient code acquisition method.

1.3. Objectives

 To study code acquisition in direct-sequence spread-spectrum communication


systems.
 To describe code acquisition and explain why it is necessary.
 To design and demonstrate a code acquisition method.

1.4. Scope

It is important to note that the synchronization aspects of acquisition and tracking are not
mutually exclusive, with both depending on each other for synchronization to be achieved.
With this crucial point in mind, the project will describe direct-sequence spread-spectrum
systems with regard to spreading sequences, transmitter and receiver design, acquisition
and tracking. Applications of direct-sequence spread spectrum systems in multiple-access
systems will also be described briefly. A special focus will be accorded to code acquisition
with the eventual result that a code acquisition method is designed and demonstrated.
2

1.5. Justification

A simulation of a direct-sequence spread-spectrum system will be performed to


demonstrate code acquisition.

1.6. Report Organization

Chapter 1 gives a general introduction to the project and describes the objectives and scope
of the project.

Chapter 2 presents the theoretical background of direct-sequence spread-spectrum systems


and gives a detailed treatment of code synchronization.

Chapter 3 describes the various parts that make up the system in detail.

Chapter 4 presents the performance of the system and makes a comparison with the
performance of a theoretical system.

Chapter 5 concludes the project and mentions some modifications that could be made to
the system.
3

2. Literature Review

2.1. Spread-Spectrum Communication Systems

2.1.1. Origins

Spread-spectrum communication systems owe their existence to a variety of events


which took place between 1920 and 1960. The earliest applications were military in
nature where such attributes of spread-spectrum systems as anti-jam capabilities and
low probability of intercept (LPI) of signals was desirable. Radar engineers in the
early 1920s knew about spectrum spreading for jamming avoidance and signal
discrimination [2]. The earliest patent according to the U.S. Patent Office that was
spread-spectrum in nature was filed by Alfred Goldsmith in 1924. Another widely
held view as to who exactly invented spread-spectrum systems attributes it to actress
Hedwig Eva Marie Kiesler, also known as Hedy Lamarr. She, together with pianist
George Antheil, filed a patent for a secret communication system in 1941, which
proposed a simple but reliable communication system based on the use of carrier
waves of different frequencies that was difficult to decipher [9]. Before the 1960s,
most of the work done on spread-spectrum techniques remained a secret and only in
the late 1970s did it become available to the public.

Spread-spectrum communication has become an increasingly popular technique and


is now used in multiple-access systems such as CDMA and in systems designed to
combat multipath, for instance, ground-based mobile radio environments.

2.1.2. Definitions and Concepts

One of the primary design objectives in any communication system is to minimize


the transmission bandwidth and to efficiently use power. This is because bandwidth
and power are limited communication resources. However, in some instances, it is
desirable to sacrifice the efficient use of bandwidth and power in order to meet other
design objectives, such as providing a secure form of communication in a hostile
environment, multiple-access capability and low probability of intercept, among
others.

These requirements are met by a class of signaling techniques referred to as spread-


spectrum techniques. An apt definition of spread spectrum is a means of transmission
in which the data sequence occupies a bandwidth in excess of the minimum
bandwidth required to send it. Furthermore, the spectrum spreading is accomplished
by means of a code which is independent of the data sequence. At the receiver, which
4

is operating in synchronism with the transmitter, the same code is used to despread
the spectrum and the data sequence is recovered [3].
Various types of spread-spectrum signaling techniques are available. These are:

 Direct sequence (DS) – The data sequence is used to modulate a wideband


code, which is a fast pseudo-randomly generated sequence, with the result that
the narrowband data sequence is transformed into a wideband noise-like
signal. The resulting wideband signal then undergoes a second stage of
modulation, where phase-shift keying is used.

 Frequency hopping (FH) – The spectrum of a data-modulated carrier is


widened by shifting the frequency in a pseudo-random manner. A common
modulation technique used for FH is M-ary frequency shift keying (MFSK).
Two characterizations of frequency hopping exist: slow FH, where several
symbols are transmitted on each frequency hop; and fast FH, where the carrier
frequency hops several times during the transmission of one symbol.

 Time hopping (TH) – In this technique, bursts of signal are initiated at pseudo-
random times.

There are also hybrid techniques that involve both DS and FH. A more detailed
discussion of DS-SS systems is now given.

2.2. Direct-Sequence Spread-Spectrum Systems

As stated above, both DS and FH systems require the use of a noise-like spreading code
referred to as a pseudo-random or pseudo-noise (PN) sequence. A brief discussion of PN
sequences and another type of spreading sequence, the Gold sequence, is given below.

2.2.1. Pseudo-Noise (PN) Sequences

A PN sequence is a periodic binary sequence with an autocorrelation that resembles,


over a period, the autocorrelation of a random binary sequence. Its autocorrelation
also roughly resembles the autocorrelation of bandlimited white noise [7]. Ideally,
one would want to use a truly random binary sequence. However, for the data to be
recovered, the receiver needs to know the code that was used for spreading. This
knowledge is unavailable in a non-deterministic process like a random binary
sequence, hence the use of PN sequences, which are deterministic.

PN sequences are generated by means of a feedback shift register. These registers are
made up of consecutive stages of bistable memory devices (flip-flops) and feedback
logic. The flip-flops are regulated by a single clock. The block diagram below
illustrates the basic features of a feedback shift register [6].
5

Figure 1 Feedback shift register

At each tick of the clock, the state of each flip-flop is shifted to the next one down the
line. At the same time, the logic circuit computes a Boolean function of the states of
the flip-flops. The result of this computation is fed back as the input to the first flip-
flop. The sequence generated is therefore determined by the length m of the shift
register. For m flip-flops, the maximum number of possible states of the shift register
is 2𝑚 . The PN sequence so generated must therefore eventually become periodic with
a period of at most 2𝑚 .

In practice, PN sequences are generated by linear feedback shift registers (LFSRs).


These are feedback shift registers in which the feedback logic consists of modulo-2
adders. For LFSRs, the zero state, which is the state in which all the flip-flops are in
state 0, is not allowed since the output would always consist entirely of zeros.
Therefore, the period of a PN sequence produced by such a feedback register
consisting of m flip-flops cannot be greater than 2𝑚 − 1. When the period is exactly
2𝑚 − 1, the PN sequence is referred to as a maximal-length sequence or an m-
sequence.

Maximal-length sequences have a few important salient properties. These are:

Balance property – In each period of an m-sequence, the number of 1s is always one


more than the number of zeros.

Run-length property – A run is a subsequence of identical binary symbols within each


period of the m-sequence. In each period of an m-sequence, the run-lengths of 1s and
0s are as expected in a coin-flipping experiment, that is, half of all run-lengths are
unity, a quarter are of length two, an eighth are of length three, and so on, as long as
these fractions represent meaningful numbers of runs.
6

Delay-and-add property – The modulo-2 sum of any m-sequence, when summed chip
by chip with a shifted version of the same sequence, produces another shifted version
of the same sequence.

Correlation property – The autocorrelation function of an m-sequence is periodic and


binary-valued. If 𝑇𝑐 is the duration assigned to each symbol in the m-sequence and
𝑁 = 2𝑚 − 1, then the following expressions represent the autocorrelation function
and the power spectral density, respectively [6]:

𝑁+1
1− |𝜏|, |𝜏| ≤ 𝑇𝑐
𝑁𝑇𝑐
𝑅𝑐 (𝜏) = (2.1)
1
{ − , 𝑒𝑙𝑠𝑒
𝑁


1 1+𝑁 2
𝑛 𝑛
𝑆(𝑓) = 2 𝛿(𝑓) + ∑ 𝑠𝑖𝑛𝑐 ( ) 𝛿 (𝑓 − ) (2.2)
𝑁 𝑁 2 𝑛=−∞ 𝑁 𝑁𝑇𝑐
𝑛≠0

The plots of these two waveforms are shown below [4]:

Figure 2 PN sequence waveforms. Autocorrelation function (top). Power spectral density


(bottom)
7

It can be seen that maximal length sequences exhibit many of the properties
possessed by a truly random binary sequence. As a matter of fact, in the limit, the
two sequences become identical as 𝑁 is made infinitely large. However, a large
𝑁 means an increasing storage requirement, which imposes a practical limit on the
size of 𝑁.
Certain conditions must be met for a maximal-length sequence to be generated.
Generally, maximal-length sequences are defined by polynomials in the binary
field 𝐺𝐹(2). In this field, a primitive polynomial is a polynomial that possesses the
property that the smallest integer n for which the polynomial divides 1 + 𝑥 𝑛 is 𝑛 =
2𝑚 − 1. It turns out that any polynomial of degree m will generate a maximal-
length sequence of period 𝑁 = 2𝑚 − 1 if and only if it is a primitive polynomial.
This is a necessary and sufficient condition. Furthermore, for a positive integer m,
the number of different primitive polynomials of degree m over 𝐺𝐹(2) is given by
𝜙𝑒 (2𝑚 − 1)
𝜆𝑚 = (2.3)
𝑚
where 𝜙𝑒 (𝑛) is the number of positive integers less than and relatively prime to n
(n > 0), also known as Euler’s totient function.
The table below shows some of the polynomials that generate maximal-length
sequences for different register lengths [1].
Register length Sequence Number of Polynomial
m N = 2m-1 polynomials generators
2 3 1 1 + x + x2
3 7 2 1 + x + x3
1 + x2 + x3
4 15 2 1 + x + x4
1 + x3 + x4
5 31 6 1 + x2 + x5
1 + x3 + x5
1 + x + x2 + x3 + x5
1 + x + x2 + x4 + x5
1 + x + x3 + x4 + x5
1 + x2 + x3 + x4 + x5
6 63 6 1 + x + x6
1 + x + x3 + x4 + x6
1 + x5 + x6
1 + x + x2 + x5 + x6
1 + x2 + x3 + x5 + x6
1 + x + x4 + x5 + x6

Table 1 Generator polynomials


8

While the autocorrelation properties of PN sequences are very good, the cross-
correlation properties are quite poor. Thus, PN sequences are not suitable for use in
multiple-access systems, which require that the cross-correlation between any two
users to be very low (ideally zero). A special type of PN sequences, referred to as
Gold sequences, meet this requirement.
2.2.2. Gold Sequences

These sequences are based on Gold’s theorem, stated below [11]:

Let 𝑓1 and 𝑓2 be a preferred pair of primitive polynomials of degree n whose


corresponding shift registers generate maximal linear sequences of period 2𝑛 − 1
and whose cross-correlation function 𝜃 satisfies the inequality

2(𝑛+1)⁄2 + 1, 𝑛 𝑜𝑑𝑑
|𝜃| ≤ { (2.4)
2(𝑛+2)⁄2 + 1, 𝑛 𝑒𝑣𝑒𝑛; 𝑛 ≠ 0 𝑚𝑜𝑑 4

Then the shift register corresponding to the product polynomial 𝑓1 ∙ 𝑓2 will generate
2𝑛 + 1 different sequences each of period 2𝑛 − 1 and such that the cross-
correlation function of any pair of such sequences satisfies the inequality above.
Gold sequences are generated by the modulo-2 addition of two maximal-length
sequences of the same length. The code sequences are added chip by chip by
synchronous clocking. A special set of Gold sequences is formed from preferred pairs
of m-sequences. These sequences have uniform and bounded cross-correlation which
is three-valued, as shown in the table below:

Register length Code length N Normalized cross- Frequency of


n correlation occurrence
Odd 2𝑛 − 1 −1⁄𝑁 ~0.50
(𝑛+1)⁄2 ~0.25
−(2 + 1)⁄𝑁
(𝑛+1)⁄2 ~0.25
(2 − 1)⁄𝑁
Even and not 2𝑛 − 1 −1 𝑁⁄ ~0.75
divisible by 4 −(2(𝑛+2)⁄2 + 1)⁄𝑁 ~0.125
(2(𝑛+2)⁄2 − 1)⁄𝑁 ~0.125

Table 2 Characteristics of Gold sequences


It can be seen from the table that for register lengths that are even and not divisible
by 4, the cross-correlation is −1⁄𝑁 75% of the time, which is quite a good
performance.
9

Gold sequences are used widely in multiple-access systems like CDMA, frequency-
hopping multiple access (FHMA) and ultra-wideband spread-spectrum
communication systems due to their excellent cross-correlation properties. However,
they are usually non-maximal and hence have autocorrelation functions that are worse
than those of m-sequences.

2.2.3. Spectrum Spreading in DS-SS

From Fourier theory, it is known that multiplying two signals in the time domain is
equivalent to convolving the spectra of the two signals in the frequency domain.
Accordingly, given a narrowband message signal 𝑏(𝑡) and a wideband PN signal
𝑐(𝑡), the product signal 𝑚(𝑡) will have a spectrum that is nearly the same as the
wideband PN signal. Thus, the PN signal performs the role of a spreading code.

The process of multiplying the message signal and the PN signal causes each message
bit to be chopped up into small time increments referred to as chips. This is illustrated
in the waveforms below:

Figure 3 DS-SS waveforms. Binary data (top). PN sequence (mid). Spread binary
data (bottom)
10

Consider the following baseband model of a DS system consisting of the transmitter,


channel and receiver [6].

Figure 4 DS baseband model. Transmitter (top left). Channel (top right). Receiver
(bottom)

The transmitted signal may be expressed as

𝑚(𝑡) = 𝑏(𝑡)𝑐(𝑡) (2.5)

The received signal 𝑟(𝑡) consists of the transmitted signal 𝑚(𝑡) plus additive
interference 𝑗(𝑡) introduced in the channel. Thus,

𝑟(𝑡) = 𝑚(𝑡) + 𝑗(𝑡) = 𝑐(𝑡)𝑏(𝑡) + 𝑗(𝑡) (2.6)

At the receiver, the signal 𝑟(𝑡) is demodulated. The demodulation involves


multiplication with a local PN sequence which is an exact replica of the sequence
used in the transmitter. Assuming that the two PN sequences operate in perfect
synchronism, the output 𝑧(𝑡) of the multiplier at the receiver is

𝑧(𝑡) = 𝑐 2 (𝑡)𝑏(𝑡) + 𝑐(𝑡)𝑗(𝑡) (2.7)

Assuming the PN sequence alternates between -1 and +1, squaring destroys the
alternation and thus

𝑧(𝑡) = 𝑏(𝑡) + 𝑐(𝑡)𝑗(𝑡) (2.8)

Thus, the message signal is recovered at the receiver. However, multiplication of the
interference 𝑗(𝑡) with the local PN sequence will spread its spectrum as it did the data
at the transmitter. Hence, at the receiver, the message is narrowband while the
interference is wideband. All that remains is to apply the multiplier output to a low-
11

pass filter with a bandwidth just large enough to accommodate the message signal,
filtering out almost all the power in the interference and significantly reducing its
effect at the receiver.

Hence, a DS spread-spectrum system is seen to be able to reject interference


effectively, as well as ensure low probability of intercept for the message signal. The
use of the spreading code produces a wideband transmitted signal that appears noise-
like to a receiver that has no knowledge of the spreading code.

2.2.4. DS-SS with Coherent Binary Phase-Shift Keying

Coherent BPSK is incorporated into the transmitter and the receiver to enable this
technique to be used in passband transmission. The figure below shows a block
diagram of the transmitter [4].

Figure 5 DS passband transmitter model

A message sequence {𝑏𝑘 } is a stream of 1s and 0s. This sequence is first fed to a polar
NRZ level encoder (not shown) which does the mapping 0 → −1, 1 → +1,
converting the unipolar sequence to a bipolar one. The bipolar sequence 𝑏(𝑡) is then
multiplied with the PN sequence 𝑐(𝑡). This is the first stage of modulation.

The second stage of modulation consists of a BPSK modulator which performs phase
modulation on the message signal 𝑚(𝑡) to yield a phase-modulated signal 𝑥(𝑡) which
is transmitted.

The figure below shows a block diagram of the receiver [4].


12

Figure 6 DS passband receiver model

At the receiver, two stages of demodulation are performed. The received signal 𝑦(𝑡)
can be represented as

2𝐸𝑠
𝑦(𝑡) = √ 𝑏(𝑡)𝑐(𝑡) cos(2𝜋𝑓𝑐 𝑡 + 𝜃) (2.9)
𝑇𝑆

Here, 𝐸𝑠 is the energy of the received signal, 𝑇𝑠 is the duration of one symbol of the
data sequence and 𝜃(𝑡) is the phase modulation, takes on values of 0 or 𝜋 depending
on the polarities of the data sequence and the PN sequence at any one time.
The transitions of the data symbols and the PN chips coincide such that the ratio of
𝑇𝑠 to 𝑇𝑐 (the chip time) is an integer. If the bandwidth of the received signal 𝑦(𝑡) is
𝐵𝑠𝑠 and that of a conventionally modulated signal 𝑏(𝑡)cos(2𝜋𝑓𝑐 𝑡) is 𝐵, then the
spreading due to 𝑐(𝑡) is found to yield 𝐵𝑠𝑠 ≫ 𝐵, that is, the signal occupies a
bandwidth in excess of the minimum bandwidth necessary to send it.
The first stage of demodulation involves coherent detection wherein the received
signal 𝑦(𝑡) and a locally generated carrier are applied to a product modulator,
followed by low-pass filtering. This reverses the phase-shift keying applied to the
transmitter signal. The second stage of demodulation involves despreading wherein
the low-pass filter output is multiplied by a locally generated replica of the PN
sequence and then integration is performed over a bit interval. Finally, a decision-
making device gives the final output sequence.
The figure below shows how the received signal together with interference (assumed
narrowband) appear before and after despreading occurs [4].
13

Figure 7 Received DS signal. a) Before despreading. b) After despreading


It can be seen that the received signal before despreading contains the desired signal
whose spectrum has been spread at the transmitter and narrowband interference.
However, after despreading, the spectrum of the interference is spread over a large
bandwidth while the desired signal now occupies a narrow bandwidth. Low-pass
filtering then extracts the desired signal and eliminates most of the original
interference energy.
An important figure of merit for a DS spread-spectrum system is referred to as the
processing gain, denoted as PG. The processing gain is a measure of the interference
rejection capability and is given as
𝑇𝑠 𝐵𝑠𝑠 𝐵𝑠𝑠
𝑃𝐺 = = = (2.10)
𝑇𝑐 𝐵 2𝑅𝑠
Here, 𝑅𝑠 is the data rate. Hence, the greater the processing gain of the system, the
greater will be its ability to suppress interference.
2.3. Code Synchronization

At the spread-spectrum receiver, the corresponding chips in the spreading sequence must
precisely or nearly coincide. Any misalignment causes the signal amplitude at the
demodulator to fall in accordance with the autocorrelation function, leading to signal
degradation. Use of precision clocks in the transmitter and the receiver may help to limit
the uncertainty but there is still the potential of synchronization problems due to clock
drift, range uncertainty and the Doppler shift.

There are various ways in which code synchronization in a spread-spectrum system may
be achieved. Separately transmitted pilot or timing signals or using feedback signals from
the receiver to the transmitter are some of the ways. However, both of these ways accrue
significant costs in power and overhead. A method which is more modest in power and
overhead is to use the received signal to acquire synchronization.
14

A commonly used method for synchronization is maximum likelihood estimation where


candidate values for phase offset and frequency offset are tested and those that maximize
a likelihood function are picked as the correct values.

Synchronization consists of two parts: acquisition and tracking. Code acquisition is the
operation by which the phase of the receiver-generated sequence is brought to within a
fraction of a chip of the phase of the received sequence. Code tracking is the operation by
which synchronization errors are further reduced or at least maintained within certain
bounds. Acquisition and tracking devices regulate the clock rate, adjusting the timing
offset of the local sequence to the timing offset of the received sequence. The figure below
shows a code synchronization system [1].

Figure 8 Block diagram of code synchronization system

2.3.1. Code Acquisition

Consider a received signal 𝑟(𝑡) given by

𝑟(𝑡) = 𝑠(𝑡) + 𝑛(𝑡) (2.11)

where 𝑠(𝑡) is the desired signal and 𝑛(𝑡) is white Gaussian noise. The desired signal
𝑠(𝑡) can be represented as

𝑠(𝑡) = √2𝑆𝑐(𝑡 − 𝜏) cos(2𝜋𝑓𝑐 𝑡 + 2𝜋𝑓𝑑 𝑡 + 𝜃) (2.12)

where 𝑆 is the average power, 𝑐(𝑡) is the PN waveform, 𝜃 is the random carrier phase
and 𝜏 and 𝑓𝑑 are the code phase offset and frequency offset, respectively, which must
be estimated.
If the received waveform 𝑟(𝑡) is expanded in terms of 𝑁 orthonormal basis functions,
an observation vector given by 𝒓 = [𝑟1 𝑟2 ⋯ 𝑟𝑁 ] will result. The likelihood function
for the unknown code phase offset 𝜏 and frequency offset 𝑓𝑑 will be given by the
15

conditional density function of r given 𝜏 and 𝑓𝑑 . Since the carrier phase 𝜃 is a random
variable, the likelihood function Λ(𝒓) will be given by the expectation of the
conditional density function with respect to 𝜃:

Λ(𝒓) = 𝐸𝜃 [𝑓(𝒓|𝜏, 𝑓𝑑 , 𝜃)] (2.13)

Thus, the maximum-likelihood estimates will be those values of 𝜏 and 𝑓𝑑 that


maximize the likelihood function. It can be shown that when an expansion in the
orthonormal functions is done, the likelihood function can be expressed as

2√2𝑆𝑅(𝜏, 𝑓𝑑 )
Λ[𝑟(𝑡)] = 𝐽0 ( ) (2.14)
𝑁0

where 𝐽0 () is the modified Bessel function of the first kind of order zero, 𝑁0 ⁄2 is the
variance of each coefficient in the expansion of 𝑟(𝑡) and

𝑇 2
𝑅(𝜏, 𝑓𝑑 ) = [∫ 𝑟(𝑡)𝑐(𝑡 − 𝜏) cos(2𝜋𝑓𝑐 𝑡 + 2𝜋𝑓𝑑 𝑡) 𝑑𝑡]
0
𝑇 2
+ [∫ 𝑟(𝑡)𝑐(𝑡 − 𝜏) sin(2𝜋𝑓𝑐 𝑡 + 2𝜋𝑓𝑑 𝑡)𝑑𝑡] (2.15)
0

Since 𝐽0 (𝑥) is a monotonically increasing function of 𝑥, 𝑅(𝜏, 𝑓𝑑 ) is a sufficient


statistic for maximum likelihood estimation. A device that implements this statistic is
termed a non-coherent correlator.

Thus, acquisition provides coarse synchronization by limiting the choices of the


estimated values to a finite number of quantized candidates. The frequency offset is
usually negligible (so long as 𝑁𝑓𝑑 𝑇𝑐 is relatively small [5]) hence the focus is on the
timing offset 𝜏.

One acquisition method is to use a parallel array of processors, each of which is


matched to quantized values of the timing offset. The largest processor output then
indicates which candidates are selected as estimates. Although quite fast, it is very
complex and costly. A much simpler method is to use serial searching where each of
the candidate offsets are searched serially. This method takes time for a decision to
be made. However, this method will be utilised in this project.
16

2.3.2. Acquisition Methods

A common feature of all acquisition methods is that the received signal and the locally
generated PN sequence are first correlated to establish a measure of similarity
between them. This measure is then compared to a threshold to determine if the two
signals are in synchronism. If they are, a verification algorithm is started. Some dwell
time is usually necessary while testing synchronism to avoid false locking. After this,
tracking can begin.

The two main acquisition methods are matched filter acquisition and serial-search
acquisition, also known as the sliding correlator. These are briefly described below.

2.3.2.1. Matched-Filter Acquisition

The figure below illustrates a digital matched filter that can be used for non-
coherent acquisition [4].

Figure 9 Digital matched filter

The received waveform is decomposed into in-phase and quadrature


components, each of which is applied to a separate branch. Each component is
passed through a filter, a sampler and a one-bit digitizer. The digitizer makes
hard decisions on the sample values by observing their polarities. The output of
the digitizer is then fed into a transversal filter, which consists of a shift register
and a correlator. The shift register stores the sequence chips and compares them
to the stored reference chips. The correlator outputs are then squared and
summed. Thus, this filter generates the statistic 𝑅(𝜏, 0).

Matched-filter acquisition gives the shortest acquisition time but is hardware-


intensive for parallel implementation. The hardware increases with the PN
codelength and hence this method is mostly used for short codes.
17

2.3.2.2. Serial-Search Acquisition

This method consists of a search among candidate code phases of a local


sequence till it is determined that the local sequence is nearly synchronized with
the received spreading sequence. The search positions are referred to as cells,
which are regions of timing uncertainty. The figure below illustrates the
implementation of serial-search acquisition [4].

Figure 10 Serial-search acquisition

The received signal together with the local PN sequence are applied to a non-
coherent correlator which generates the statistic 𝑅(𝜏, 0). If the received and
local spreading sequences are not aligned, the autocorrelation value is low and
hence the threshold value is not exceeded. The cell under test is thus rejected
and the phase of the local sequence is advanced or retarded by generating and
extra clock pulse or by blocking one.

If the received and local spreading sequences are aligned to within a certain
arbitrary value (say, half a chip), then the autocorrelation value will be high and
the threshold value will be exceeded. The search is then stopped and the cell is
selected as the correct one. Demodulation and tracking can then commence.

The amount of time required to test a cell is referred to as the dwell time and is
approximately equal to the integration period in the non-coherent correlator. An
acquisition system in which a single test determines whether a cell is accepted
as the correct one or not is termed a single-dwell system; one in which
subsequent verification tests are required before a decision is made is termed a
multiple-dwell system.

The figure below illustrates how a serial-search acquisition system may be


implemented using a non-coherent correlator [1].
18

Figure 11 Block diagram of a non-coherent correlator

2.3.3. Code Tracking

Code tracking will be very briefly discussed as it is not the subject of this project;
however, mention of it is important since acquisition and tracking are not mutually
exclusive but rather depend of each other for synchronization to be achieved.

Once receiver timing has been synchronized to within a fraction of a chip time, the
estimate should further be refined to approach zero. Corrections must be made
continuously because of the relative motion of transmitter and receiver and the
instability of clocks.

A popular method used for tracking is the delay-locked loop (DLL). This is shown in
the figure below [4].
19

Figure 12 Delay-locked loop

The locally generated PN sequence 𝑝𝑟 (𝑡) of the tracking loop is offset from the
incoming PN sequence 𝑝(𝑡) by a time 𝜏 < 𝑇𝑐 ⁄2. Within the DLL, two PN sequences
are delayed from each other by one chip time (𝑇𝑐 ), that is, 𝑝𝑟 (𝑡 + 𝑇𝑐 ⁄2 + 𝜏)
(advanced sequence) and 𝑝𝑟 (𝑡 − 𝑇𝑐 ⁄2 + 𝜏) (delayed sequence).

When 𝜏 is positive, the error signal causes the voltage-controlled clock to increase its
frequency, thereby forcing 𝜏 to decrease. Conversely, when 𝜏 is negative, the error
signal causes the voltage-controlled clock to decrease its frequency, thereby forcing
𝜏 to increase. In this way, tracking of the PN sequence is achieved.

2.4. Application of Spread-Spectrum: Code Division Multiple Access (CDMA)

CDMA is a multiple access technique for wireless communications that is implemented


by spread-spectrum techniques. Unlike time division multiple access (TDMA) which
requires time synchronization of individual users, or frequency division multiple access
(FDMA) which requires bandwidth allocation, all the users in a CDMA system have full
time and full bandwidth and can transmit simultaneously.

In a CDMA system, each user is assigned its own PN sequence which is approximately
orthogonal to all other sequences. The receiver performs a time correlation operation in
order to detect only the specific desired sequence. All other sequences appear as noise to
this particular receiver due to decorrelation. Of course, this receiver needs to have a
knowledge of the PN sequence used by the transmitter.

Thus, with the use of SS techniques, it is possible for multiple users to transmit
simultaneously in the same frequency band, and yet the data can be decoded by a receiver,
provided that the receiver uses a PN code that is identical to, and synchronized with, the
particular SS signal that is to be decoded. However, the quality of communication
20

decreases as the number of users increases. CDMA (unlike TDMA or FDMA) is said to
have a soft capacity limit since there is no absolute limit on the number of users; the system
performance degrades for all users as the number of users is increased, and improves as
the number of users is decreased.
21

3. System Description
This section describes in detail the complete direct-sequence spread-spectrum system. The
various parts of the system, namely, transmitter, receiver, channel, acquisition and tracking
together with the subsystems contained therein are presented in depth.

3.1. Model Realization

The system was modeled using Simulink, which is a companion software to MATLAB.
Simulink is extremely well-suited to modeling many kinds of systems due to its vast array
of packages tailor-made for various applications including, but not limited to,
communication systems, computer vision, robotics and control systems.

Simulink models systems using blocks which represent real-life systems. The software is
user-friendly since each block has a description and a way to vary various parameters,
making it quite versatile. It also contains visual tools such as displays, scopes, spectrum
analyzers, among others which further lend to its facility in use.

The Communications Blockset was mainly used in modeling the system, as well as other
commonly-used blocks and mathematical operations. This blockset contains blocks
pertaining to communication systems such as filters, modulators, demodulators, sequence
generators and channels as well as utility blocks such as bipolar-to-unipolar converters
and bit error rate calculators.

3.2. Description of DS-SS system

The following system specifications were used:

 Bit rate – 10 bits/second


 Chip rate – 1000 chips/second
 Length of PN sequence – 127 chips
 Modulation/Demodulation – Binary phase-shift keying (BPSK)
The system was broken down into four main sections:
 Transmitter
 Channel
 Receiver
 Synchronization (acquisition and tracking)
The complete system is shown below.
22

Figure 13 Block diagram of DS-SS system

3.2.1. Transmitter Architecture

The transmitter model is shown below.

Figure 14 Block diagram of transmitter

The user data was generated by a Bernoulli binary generator at the rate of 10
bits/second. The probability of 1s and 0s was equal hence this was a good
representation of real-life data which is usually random e.g. speech. The user data was
then multiplied by the PN sequence to spread its spectrum. BPSK modulation was
then carried out for passband transmission.

The PN generator was built out of seven D flip-flops to give a code length of 𝑁 =
27 − 1 = 127. The generator polynomial used was 1 + 𝑥 + 𝑥 7 which was gotten by
23

using the outputs of the first and seventh flip-flops in the feedback logic. The PN
generator is shown below.

Figure 15 PN generator

The clock was set to run at 1000 Hz so as to generate a PN sequence at a rate of 1000
chips/second. There was also an option of using a variable clock so as to observe the
performance of the system with regard to synchronization.

The waveforms below show the user data and the PN sequence.

Figure 16 User data (top). PN sequence (bottom)


24

Below, the spectra of the user data and of the spread sequence are shown. It can be
seen that the spectrum has been made ‘wider’. While the spectrum of the user data
has most of its energy from 0 – 5 𝐻𝑧, the spread signal occupies a bandwidth of
1 𝑘𝐻𝑧. This is the spreading mechanism. It can also be noted that the magnitude of
the spread signal is larger.

Figure 17 Spectrum of binary data (top). Spectrum of the spread signal


(bottom).
25

3.2.2. Channel

An additive white Gaussian noise (AWGN) channel was used in the DS-SS model.

3.2.3. Receiver Architecture

The figure below shows the receiver model.

Figure 18 Block diagram of receiver.

At the receiver, the phase-shift keying was undone using a BPSK demodulator. This
was followed by despreading using a synchronized PN sequence generated by a local
PN generator. Filtering and signal shaping was then done to receive an estimate of the
transmitted user data.

The figure below shows the transmitted and received user data for a signal-to-noise
ratio (SNR) of 10 𝑑𝐵.

Figure 19 Transmitted (top) and received (bottom) waveforms


26

It can be seen that the data can be recovered at the receiver after despreading using a
local PN generator.

3.2.4. Synchronization System

The figure below shows the synchronization system.

Figure 20 Block diagram of the synchronization system

It can be seen that there are three main sections in the synchronization system, namely,
the acquisition system (made up of the non-coherent correlator and the threshold
detector), the tracking system and the search control unit. Each of these is now
described separately.

3.2.4.1. Acquisition System

Serial-search acquisition with non-coherent correlation was used in the


acquisition system.

A non-coherent correlator was used since in a DS-SS system, the carrier


frequency is not normally known during time synchronization, disqualifying the
use of a coherent correlator. The internal components making up the non-
coherent correlator are shown in the figure below.
27

Figure 21 Block diagram of non-coherent correlator

The data from the channel is multiplied by an in-phase and quadrature sinusoidal
waveform at the carrier frequency to generate in-phase and quadrature
components of the received data. Each component is passed through a chip-
matched filter and sampled at the rate of the synchronized clock (more on this
later). The sampled components are then multiplied by the local PN sequence
and passed through a square-law detector and finally summed to generate
correlated data.

The correlated data is then taken to a threshold detector, shown in the figure
below.

Figure 22 Threshold detector.

The threshold detector consists of a filter and a comparator. The correlated data
is filtered and then compared to a threshold. The output of the comparator is
HIGH if the data is greater than or equal to the threshold and LOW if it is less
28

than the threshold. Thus, a 1 or a 0 is output from the threshold detector, as shown
in the figure below.

Figure 23 Output of threshold detector

3.2.4.2. Tracking System

The tracking system was implemented as a DLL, as shown in the figure below.

Figure 24 Block diagram of tracking system

The three inputs to the DLL are gotten from the non-coherent correlator. The
early PN sequence is the synchronized sequence while the late PN sequence is
gotten from the output of the sixth flip-flop in the local PN generator. These
sequences are correlated with the data from the channel using the filter and the
envelope detector. The two components are then summed and taken to a voltage-
29

controlled oscillator (VCO). The VCO produces a sinusoidal signal whose


frequency varies with the amplitude of the input signal. After signal shaping
using the limiter and the bipolar-to-unipolar converter, a square wave with
varying frequency results, as shown in the figure below.

Figure 25 Output of VCO.

Thus, the DLL uses the delayed and advanced PN sequences to produce a signal
which tracks the received sequence.

3.2.4.3. Search Control Unit

The figure below shows the search control unit.

Figure 26 Block diagram of search control unit


30

1
The clock in this unit had a period of a fifth of the chip time, i.e. 𝑇 = 5000 𝑠 =
𝑇𝑐
. This ensured that the serial search was performed over decision regions (or
5
cells) much less than a chip size, improving accuracy. The clock output is first
inverted to enable it to drive a negative-edge triggered flip-flop. The inverted
clock and the signal from the threshold detector serve as inputs to a NAND logic
gate. The logic gate gives a HIGH output whenever the clock and the detected
signal are 90° out of phase or are both LOW. Whenever the clock and the
detected signal are both HIGH, the output of the NAND gate is LOW.

The J-K flip-flop has shorted inputs hence it acts as a T flip-flop. Whenever the
input to a T flip-flop is HIGH, the output of the flip-flop is LOW and vice versa;
the flip-flop performs toggling. Thus, if the clock and the detected signal are not
synchronized, the search control unit generates an extra clock pulse, effectively
slowing down the clock. The output of the flip-flop is then modulo-2 added with
the signal from the tracking system, giving rise to a synchronized clock signal.

The figure below compares the normal clock and the synchronized clock.

Figure 27 Normal clock (top). Synchronized clock (bottom).

It is this synchronized clock that drives the local PN generator to give rise to a
synchronized PN sequence which can be used at the receiver to recover the data.
The figure below compares the transmitter and receiver PN sequences.
31

Figure 28 Transmitter PN sequence (top). Receiver PN sequence


(bottom).

It can be seen that the receiver PN sequence does not vary in the same manner
as the transmitter PN sequence due to the latter’s adjustment by the search
control unit.

3.2.5. Blocks for Performance Testing.

The Error Rate Calculator block form the Communications Blockset was used to test
the performance. This block computes the bit error rate using the transmitted and
received signals and outputs three sets of data: the bit error rate, the number of errors
detected and the number of symbols compared. These were displayed using the
Display block. The figure below illustrates this.
32

Figure 29 Error rate calculator and display

Thus, the simulation above yielded a bit error rate of 0.008 or 0.8%. Out of 1000
symbols compared, 8 errors were detected.

A jittery clock generator was also included in the transmitter PN generator as shown
below.

Figure 30 Jittery clock in transmitter PN generator

Selection between a normal clock and the jittery clock generator was possible using
a manual switch. The purpose of the jittery clock generator was to simulate a real-
world system where clock drift and instability would be unavoidable. The internal
structure of the jittery clock generator was as shown in the figure below.
33

Figure 31 Jittery clock generator

A MATLAB function was used [12] to create a clock with jitter to simulate a real
clock which would inevitably suffer from drift and instability. The Rate Transition
block was used to ensure that only discrete samples were used in the system. Most of
the blocks in the system required discrete samples hence the need for this block.

The figure below shows the output of the jittery clock generator.

Figure 32 Clock with jitter


34

4. System Performance

This section describes the performance of the direct-sequence spread-spectrum system. For a
spread-spectrum system, the parameters of interest are usually the acquisition time and the bit
error rate (BER). In this system, acquisition is instantaneous since no delay is introduced in
the channel. However, the BER performance of the system is investigated with regard to two
conditions: system driven by a normal clock and system driven by a jittery clock.

4.1. Theoretical BER for BPSK

The BER, also known as the probability of bit error, denoted by 𝑃𝑒 , is a measure of the
level of deterioration in a digital communication system. The BER for modulation
schemes in an AWGN channel is found using the 𝑄-function of the distance between the
signal points. The 𝑄-function is defined as [8]


1 𝑥2
𝑄(𝑧) = ∫ exp (− ) 𝑑𝑥 (4.1)
√2𝜋 2
𝑧

For a BPSK system, the theoretical BER is given by [2] [8]

2𝐸𝑏
𝐵𝐸𝑅𝐵𝑃𝑆𝐾 = 𝑄 (√ ) (4.2)
𝑁0
Here, 𝐸𝑏 is the energy per bit and 𝑁0 is the power spectral density of the noise in the
channel (in this case, white noise).

4.2. Performance of DS-SS system

Simulations were run on the DS-SS system using Simulink. Two conditions were
investigated, namely, system with normal clock and system with jittery clock. The number
of symbols compared was 104 . The tables below show the BER performance of the system
under both conditions.
35

Normal clock
𝑬𝒃 ⁄𝑵𝟎 (𝒅𝑩) BER
0 0.1594
1 0.1332
2 0.1051
3 0.0816
4 0.0590
5 0.0416
6 0.0252
7 0.0143
8 0.0071
9 0.0021
10 0.0008

Table 3 BER performance for system with normal clock

Jittery clock
𝑬𝒃 ⁄𝑵𝟎 (𝒅𝑩) BER
0 0.1594
1 0.1332
2 0.1051
3 0.0816
4 0.0590
5 0.0416
6 0.0252
7 0.0143
8 0.0071
9 0.0021
10 0.0008

Table 4 BER performance for system with jittery clock


36

The following MATLAB code snippet was written to plot the data above, as well as the
theoretical BER to provide a visual comparison between the systems.

% DS-SS system performance

% Theoretical BER for BPSK is given by Q(sqrt(2*Eb/No))


x = 0:10; % Eb/No
snr = 10.^(x/10);
y = qfunc(sqrt(2*snr));
semilogy(x,y);
hold on;

% BER against Eb/No for system with normal clock


y1 = [0.1594 0.1332 0.1051 0.0816 0.059 0.0416 0.0252 0.0143 0.0071 0.0021 0.0008];
semilogy(x,y1,'r-*');
hold on;

% BER against Eb/No for system with jittery clock


y2 = [0.1594 0.1332 0.1051 0.0816 0.059 0.0416 0.0252 0.0143 0.0071 0.0021 0.0008];
semilogy(x,y2,'g-o');
title('Bit error rate performance'); grid on;
xlabel('Eb/No (dB)'); ylabel('BER')
legend('Theoretical','Normal clock','Jittery clock');

The plots of the three systems are shown below.

Figure 33 BER performance

From the graphs above, it can be seen that for both systems, the performance is as expected:
the BER improves as the SNR is increased. For the system driven by a normal clock, it can
37

be seen that at an SNR of 10 dB, a BER of 0.0008 is achieved, which is quite close to the
figure usually used in industry which is around 10−5.

When the system is driven by a jittery clock, it is found to have exactly the same
performance as the system with the normal clock. This demonstrates that the acquisition
system works as expected and acceptable reception is gotten at the receiver.
38

5. Conclusion
This project was established to investigate code acquisition in direct-sequence spread-spectrum
communication systems. The serial-search acquisition method was implemented using a non-
coherent correlator. A working model was built using Simulink and was tested. It was
demonstrated in the previous chapter that the acquisition method works and the overall system had
a bit error rate performance comparable to that required in practice.
A fuller treatment of direct-sequence spread-spectrum communication systems would investigate
the performance of the system in fading channels, in addition to AWGN channels. Delays could
be introduced in the channel and the time the system took to acquire acquisition would be a
performance parameter. Further, the system could be modified to compute probabilities of false
alarm and false detection and these two parameters could be used to plot the receiver operating
characteristics of the system.
39

A. MATLAB S-Function File for Jittery Clock [12]


function jitterPulseSfun(block)
%jitterPulse
%
% This is a level-2 m-code S-Function that acts as a pulse generator with
% jitter.
%
% The user specifies
% 1) a nominal period for the pulse (i.e. the nominal time between rising
% pulses)
% 2) the time that the pulse may be (randomly) delayed or advanced at each
% time step. The block assumes a nominal 50% duty cycle, hence this must
% be less than 1/4 of the nominal period.
% 3) whether the pulse is initially high or low.
%

% Author: Phil Goddard (phil@goddardconsulting.ca)

%%
%% The setup method is used to setup the basic attributes of the
%% S-function such as ports, parameters, etc. Do not add any other
%% calls to the main body of the function.
%%
setup(block);

%endfunction

%% Function: setup ===================================================


%% Abstract:
%% Set up the S-function block's basic characteristics such as:
%% - Input ports
%% - Output ports
%% - Dialog parameters
%% - Options
%%
%% Required : Yes
%% C-Mex counterpart: mdlInitializeSizes
%%
function setup(block)

% Register number of ports


block.NumInputPorts = 0;
block.NumOutputPorts = 1;

% Setup port properties to be inherited or dynamic


%block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;

% Override output port properties


block.OutputPort(1).DatatypeID = 0; % double
block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).SamplingMode = 0; % no frames

% Register parameters
block.NumDialogPrms = 3;
block.DialogPrmsTunable = {'Nontunable','Nontunable','Nontunable'};

% Register sample times


% [0 offset] : Continuous sample time
% [positive_num offset] : Discrete sample time
%
40

% [-1, 0] : Inherited sample time


% [-2, 0] : Variable sample time
block.SampleTimes = [-2 0];

%% -----------------------------------------------------------------
%% Options
%% -----------------------------------------------------------------
% Specify if Accelerator should use TLC or call back into
% M-file
block.SetAccelRunOnTLC(false);

%% -----------------------------------------------------------------
%% The M-file S-function uses an internal registry for all
%% block methods. You should register all relevant methods
%% (optional and required) as illustrated below. You may choose
%% any suitable name for the methods and implement these methods
%% as local functions within the same file.
%% -----------------------------------------------------------------

block.RegBlockMethod('CheckParameters', @CheckPrms);
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
block.RegBlockMethod('Start', @Start);
block.RegBlockMethod('Outputs', @Outputs);
block.RegBlockMethod('Update', @Update);

%% -------------------------------------------------------------------
%% The local functions
%% -------------------------------------------------------------------

%% -------------------------------------------------------------------
%% Local Function to Error Check the Block Parameters
%% -------------------------------------------------------------------
function CheckPrms(block)

% The period must positive


period = block.DialogPrm(1).Data;
if ~strcmp(class(period), 'double') || (period <=0)
DAStudio.error('Simulink:block:invalidParameter');
end

% The advance/delay must be < 25% of the period


window = block.DialogPrm(2).Data;
if ~strcmp(class(window), 'double') || ...
(period <=0) || ...
(window >= period/4)
DAStudio.error('Simulink:block:invalidParameter');
end

% The initial value must be 0 or 1


initVal = block.DialogPrm(3).Data;
if ~strcmp(class(initVal), 'double') || ...
~(abs(initVal-0)<2*eps || abs(initVal-1)<2*eps)
DAStudio.error('Simulink:block:invalidParameter');
end

%% --------------------------------------------------------------------
%% Local Function to define the 3 Work Vectors used to store state info
%% --------------------------------------------------------------------
function DoPostPropSetup(block)
block.NumDworks = 3;

% The first work vector stores the current state


block.Dwork(1).Name = 'x0';
41

block.Dwork(1).Dimensions = 1;
block.Dwork(1).DatatypeID = 0; % double
block.Dwork(1).Complexity = 'Real'; % real
block.Dwork(1).UsedAsDiscState = true;

% The second work vector is used to store the next nominal sample time
block.Dwork(2).Name = 'NextNomTs';
block.Dwork(2).Dimensions = 1;
block.Dwork(2).DatatypeID = 0; % double
block.Dwork(2).Complexity = 'Real'; % real
block.Dwork(2).UsedAsDiscState = true;

% The third work vector is used to store the half the nominal period
block.Dwork(3).Name = 'HalfNomP';
block.Dwork(3).Dimensions = 1;
block.Dwork(3).DatatypeID = 0; % double
block.Dwork(3).Complexity = 'Real'; % real
block.Dwork(3).UsedAsDiscState = false;

%% --------------------------------------------------------------------
%% Local Function to read/store state info
%% --------------------------------------------------------------------
function Start(block)

% Populate the Dwork vectors


block.Dwork(1).Data = block.DialogPrm(3).Data;
block.Dwork(2).Data = (block.DialogPrm(1).Data)/2;
block.Dwork(3).Data = (block.DialogPrm(1).Data)/2;

%% --------------------------------------------------------------------
%% Local Function to define block outputs
%% --------------------------------------------------------------------
function Outputs(block)

% output the first state (i.e. 0 or 1)


block.OutputPort(1).Data = block.Dwork(1).Data;

% Calculate the time of the next sample hit, which is the next nominal time
% plus a random term the size of the user specified window.
block.NextTimeHit = block.Dwork(2).Data + ...
2*(rand-0.5)*block.DialogPrm(2).Data;

%% --------------------------------------------------------------------
%% Local Function to define block discrete state updates
%% --------------------------------------------------------------------
function Update(block)

% toggle the first state (i.e. 0 or 1)


if abs(block.Dwork(1).Data) > 2*eps
% If 1 then make it 0
block.Dwork(1).Data = 0;
else
% If 0 then make it 1
block.Dwork(1).Data = 1;
end

% determine the next nominal sample time


block.Dwork(2).Data = block.Dwork(2).Data + block.Dwork(3).Data;
42

B. Acronyms and Abbreviations

AWGN Additive white Gaussian noise


BER Bit error rate
BPSK Binary phase-shift keying
CDMA Code division multiple access
DLL Delay-locked loop
DS-SS Direct-sequence spread-spectrum
FH Frequency hopping
FHMA Frequency hopping multiple access
LFSR Linear feedback shift register
MFSK 𝑀-ary frequency-shift keying
NRZ Non-return-to-zero
PN Pseudonoise
SNR Signal-to-noise ratio
TDMA Time division multiple access
TH Time hopping
VCO Voltage-controlled oscillator
43

C. References

[1] M. A. Abu-Rgheff, Introduction to CDMA Wireless Communications, Oxford: Elsevier, 2007.

[2] R. A. Scholtz, "The Origins of Spread-Spectrum Communications," in IEEE Transactions on


Communications, Los Angeles, 1982.

[3] R. L. Pickholtz, D. L. Schilling and L. B. Milstein, "Theory of Spread-Spectrum Communications -


A Tutorial," in IEEE Transactions on Communications, New York, 1982.

[4] D. Torrieri, Principles of Spread-Spectrum Communication Systems, Boston: Springer, 2005.

[5] A. J. Viterbi, CDMA: Principles of Spread-Spectrum Communication, USA: Addison-Wesley


Publishing Company, 1995.

[6] S. Haykin, Communication Systems, USA: John Wiley and Sons, Inc., 2001.

[7] T. S. Rappaport, Wireless Communications: Principles and Practice, India: Pearson, 2010.

[8] L. W. Couch, Digital and Analog Communication Systems, India: Pearson Education, 2001.

[9] H. K. a. A. G. Markey, "Secret Communication System". United States of America Patent 397,412,
10 June 1941.

[10] J. Meel, "Spread Spectrum (SS): Introduction," Sirius Communications, Belgium, 1999.

[11] R. Gold, "Optimal Binary Sequences for SS Multiplexing," in IEEE Transactions on Information
Theory, United States of America, 1967.

[12] P. Goddard, "Goddard Consulting," [Online]. Available: http://www.goddardconsulting.ca.


[Accessed 8th May 2016].

Das könnte Ihnen auch gefallen