Real Time Voice OFDM

Embed Size (px)

Citation preview

  • 7/27/2019 Real Time Voice OFDM

    1/131

    Real Time Voice Transmission Using

    OFDM Modulation

    Final Year Project Report

    Session 2007-08

    Project Coordinator

    Dr. K.M. Yahya

    Professor, Department of Electrical Engineering

    Chairman, Department of CISE

    Project Team

    Class # 03, Miss Rizwana ArshadClass # 10, Muhammad Usman Karim Khan

    Class # 45, Muhammad Suleman

    Department of Electrical and Electronics EngineeringNWFP UET, Peshawar, Pakistan

    NWFP UET, Final Year Project Report, 2007 Page 1

  • 7/27/2019 Real Time Voice OFDM

    2/131

    Acknowledgements

    First and far most, we thank ALLAH to enable us finish our

    project.

    Thanks to our supervisor Dr. K.M. Yahya for his kind

    cooperation.

    A special thanks to Mr. Muhammad Asad whose brilliance,and guidance and devotion to the project was exemplary.

    Thanks to Mr. Imran Ashraf and Mr. Moeen whose help and

    cooperation was a catalyst in bringing the project to its due

    end.

    Thanks to all the authors whose research and study material

    made us understand the concepts and made us eligible tofinish our job.

    NWFP UET, Final Year Project Report, 2007 Page 2

  • 7/27/2019 Real Time Voice OFDM

    3/131

    ABSTRACT

    Communication system is a field of rapid advancements with new technologiesreplacing the previous ones quite often. Orthogonal Frequency Division Multiplexing

    (OFDM) is one such technique which is rapidly finding its way in many wired and

    wireless communication systems. Owing to its popularity in modern communicationsystems, OFDM is a worthwhile research topic.

    The project focuses on the transmission of digital data between two nodes using

    Orthogonal Frequency Division multiplexing. The nodes are computer based. Speech willbe captured from the sound card and will be compressed using open source SPEEX

    codec. The compressed audio bit stream will be modulated using 16QAM modulation

    and will be combined with IFFT algorithm to form OFDM signal.

    The receiver at the other end will receiver the signal and will demodulate the

    signal. The demodulated data will be decoded by the SPEEX decoder and will be playedby the sound card.

    The pre requisite for this project is an in depth knowledge of Digital SignalProcessing, Visual C++, MATLAB (for simulation purposes) and WIN32 API.

    NWFP UET, Final Year Project Report, 2007 Page 3

  • 7/27/2019 Real Time Voice OFDM

    4/131

    Part1Abstract 3Contents 4

    List of Figures 7Chapter 1 Introduction 101.1 Purpose and Objective 11

    1.2 Scope 11

    1.3 OFDM Basics 11

    1.4 Our Project 12

    1.5 Tools and Skills 13

    1.6 Problems and Challenges Encountered 13

    Part2Chapter 2 OFDM system 14

    2.1 General Concept 15

    2.2 The importance of Orthogonality 15

    2.3 Comparison of Various Multiplexing Techniques 15

    2.4 The Block Diagram of an OFDM system 19

    Chapter 3 The OFDM Transmitter 213.1 The Block Diagram of OFDM Transmitter System 22

    3.2 Steps involved in Generation of an OFDM symbol 223.2-1 Data Source 22

    3.2-2

    Serial to Parallel 223.2-3 Symbol Mapping (Modulation) 22

    3.2-4 IDFT 23

    3.2-5 Guard Interval (GI) 233.2-6 DAC 23

    3.2-7 I/Q Modulation 23

    3.3 The Working Principles of OFDM Transmitter 233.3-1 The Importance of Orthogonality 273.3-2 Mathematical Treatment 27

    3.4 Fading 30

    3.5

    Intersymbol Interference 313.6 Intercarrier Interference 31

    3.7 Delay Spread and Use of Cyclic Prefixing to Mitigate it 31

    3.8 Modulation Scheme 34

    3.9 Interleaving 34

    3.10 Channel Estimation 35

    3.11 Adaptive Transmission 36

    NWFP UET, Final Year Project Report, 2007 Page 4

  • 7/27/2019 Real Time Voice OFDM

    5/131

    3.12 Design of the OFDM System 36

    3.13 Advantages of OFDM Transmitter Upon Other Schemes 37

    3.14 Drawbacks of an OFDM System 37

    Chapter 4 The OFDM Receiver 38

    4.1

    Block Diagram of an OFDM Receiver System 394.2 Steps Involved in Recovery of Data from the

    OFDM Symbol 394.2-1 A/D Converter 39

    4.2-2 Signal Detection 39

    4.2-3 GI removal 394.2-4 DFT 40

    4.2-5 Symbol Demapping (detection) 40

    4.2-6 Parallel To Serial 40

    4.3 The Working Principles of an OFDM Receiver 40

    4.4 Synchronization 48

    4.5

    Signal Detection 494.5-1 Energy Based Detection Schemes 49

    4.6 Symbol Timing 53

    4.7 Time Synchronization 53

    4.8 Sampling Clock Synchronization 544.8-1 Estimation 544.8-2 Correction 55

    4.9 Frequency and Phase Synchronization 554.9-1 Estimation 56

    4.9-2 Correction 56

    Part3Chapter 5 The OFDM Transmitter in C++ 57

    5.1 Block Diagram of the Transmitter System 58

    5.2 The First Sound Card 585.2-1 Technical Data 58

    5.2-2 Programming Notes 59

    5.2-3 Working 60

    5.3 Compressor 61

    5.3-1

    Technical Data 615.3-2 Programming Notes 615.3-3 Working 62

    5.4 Signal Mapping 625.4-1 Technical Data 625.4-2 Programming Notes 63

    5.4-3 Working 64

    5.5 IFFT 64

    NWFP UET, Final Year Project Report, 2007 Page 5

  • 7/27/2019 Real Time Voice OFDM

    6/131

    5.5-1 Technical Data 64

    5.5-2 Programming Notes 655.5-3 Working 66

    5.6 Guard Interval Insertion 665.6-1 Technical Data 67

    5.6-2

    Programming Notes 675.6-3 Working 68

    5.7 The Pilot Data Block 685.7-1 Technical Data 685.7-2 Programming Notes 69

    5.7-3 Working 69

    5.8 The 2nd Sound card 695.8-1 Technical Data 69

    5.8-2 Programming Notes 69

    5.8-3 Working 71

    5.9 Summary of the Procedure 72

    Chapter 6 The OFDM Receiver in C++ 736.1 Block Diagram of the Receiver System 74

    6.2 The 1st Sound Card 756.1.1 Technical Data 756.1.2 Programming Notes 76

    6.1.3 Working 77

    6.3 The Control Block 77

    6.4 The Signal Detection Block 786.4-1 Technical Data 786.4-2 Programming Notes 78

    6.4-3 Working 79

    6.5 The Correlation Block 796.5-1 Technical Data 79

    6.5-2 Programming Notes 80

    6.5-3 Working 81

    6.6 Hilbert Transform Block 816.6-1 Technical Data 81

    6.6-2 Programming Notes 81

    6.6-3 Working 83

    6.7 Synchronization Block 83

    6.7-1

    Technical Data 836.7-2 Programming Notes 836.7-3 Working 83

    6.8 The GI Removal Block 846.8-1 Technical Data 84

    6.8-2 Programming Notes 84

    6.8-3 Working 84

    6.9 The FFT Block 84

    NWFP UET, Final Year Project Report, 2007 Page 6

  • 7/27/2019 Real Time Voice OFDM

    7/131

    6.9-1 Technical Data 85

    6.9-2 Programming Notes 856.9-3 Working 85

    6.10 The Signal Demapper Block 866.10-1 Technical Data 86

    6.10-2

    Programming Notes 866.10-3 Working 87

    6.11 Decompressor 876.11-1 Technical Data 876.11-2 Programming Notes 88

    6.11-3 Working 88

    6.12 The 2nd Soundcard 886.12-1 Technical Data 89

    6.12-2 Programming Notes 89

    6.12-3 Working 90

    6.13 Summary of the Procedure 91

    Part4Chapter 7 The Shortcomings of the Project 93

    7.1 The Basic Parameters of Our project 94

    7.2 Parameters of Real OFDM 94

    7.3 The Transmitter 95

    7.4 The Receiver 95

    Part5Chapter 8 Visual C++ Implementation of

    Transmitter 968.1 The Implementation of Sound RecordingDlg.h 97

    8.2 The Implementation of Sound RecordingDlg.cpp 99

    Chapter 9 Visual C++ Implementation ofReceiver 106

    9.1 The Implementation of Sound detect and playDlg.h 107

    9.2

    The Implementation of Sound detect and playDlg.cpp 109Appendixes

    A FFTW 119

    B SPEEX Codec 123

    C The Secret Rabbit Code 126

    C Hilbert Transform 128

    References 131

    NWFP UET, Final Year Project Report, 2007 Page 7

  • 7/27/2019 Real Time Voice OFDM

    8/131

    List of Figures

    Fig 1.1, Single Carrier vs OFDM modulation technique

    Fig 1.2, The Proposed Project

    Fig 2.1, a Sine wave with areas marked in different colorsFig 2.2, Showing different modulation schemes and Multiple access schemes

    Fig 2.3, showing frequency spectrum of conventional and orthogonal frequency divisionmultiplexing

    Fig 2.4, blocks representing various processing involved in OFDM system

    Fig 3.1, the method of generating an OFDM symbol

    Fig 3.2, Serial to Parallel

    Fig 3.3, BPSK ConstellationFig 3.4, Proposed OFDM Transmitter, showing I and Q channels

    Fig 3.5, The spectrum of an individual subcarrier of the OFDM signal

    Fig 3.6, Symbolic picture of the individual subchannels for an OFDM system with Ntones over a bandwidth W.Fig 3.7, Example of Power spectral Density of a composite OFDM signal

    Fig 3.8, The multipath demonstration

    Fig 3.9, Channel Response to a Band of FrequenciesFig 3.10, Delay Spread

    Fig 3.11, comparing the timings and delay of Single Carrier and Parallel CarriersSchemes

    Fig 3.12, A Proposed Scheme to render Insignificant the effect of Delay Spread

    Fig 3.13, The Concept of Cyclic PrefixingFig 3.14, The Guard Interval representation on Frequency and Time axis

    Fig 3.15, Showing the Bit Error Rate marked against the Signal to Noise StrengthFig 3.16, Showing BER vs SNR for various Modulation TechniquesFig 3.17, Bits write and read structure for an 8x6 Interleaver

    Fig 3.18, plot of BER vs SNR with and without Interleaving

    Fig 3.19, Block type Pilot ArrangementFig 3.20, Comb type Pilot Arrangement

    Fig 3.21, Showing the Effect of attenuation at the far end frequencies due to the transfer

    function of the Transmitter or Receiver Hardware

    Fig 4.1, Blocks representing the Processes involved in treating an OFDM symbol at the

    Receiver

    Fig 4.2, BPSK Constellation DiagramFig 4.3, Illustration of Parallel To Serial Converter

    Fig 4.4, Single, Sliding window Scheme

    Fig 4.5, Double, Sliding window SchemeFig 4.6, Demonstrating the effect of GI and Correlation on detection of symbol Starting

    point

    Fig 4.7, The Loss of Synchronization between Transmitter and Receiver Sampling Clock

    Fig 4.8, The Synchronized Sampling Clock Synchronization Approach

    NWFP UET, Final Year Project Report, 2007 Page 8

  • 7/27/2019 Real Time Voice OFDM

    9/131

    Fig 4.9, The Non-Synchronized Sampling Clock Synchronization Approach

    Fig 4.10, The Carrier Frequency Offset

    Fig 5.1, The Implementation of Transmitter in C++

    Fig 5.2, QPSK Constellation Diagram

    Fig 5.3, The Structure of Arrays inData and outDataFig 5.4, Structure of the Array giData

    Fig 6.1, Implementation of OFDM Receiver in C++

    Fig 6.2, Schematic of Obtaining the Hilbert Transform

    Fig 6.3, Illustration of the FFT BlockFig 6.4, QPSK Constellation Diagram

    NWFP UET, Final Year Project Report, 2007 Page 9

  • 7/27/2019 Real Time Voice OFDM

    10/131

    Part1

    Chapter

    INTRODUCTION:The project focuses on the transmission of digital data between two nodes using

    Orthogonal Frequency Division Multiplexing (OFDM) technique. OFDM is a modulation

    and multiple access technique that has been explored over twenty years. Only recentlyhas it been finding way into commercial communication systems. OFDM is presently

    used in a number of wired and wireless communication systems. It is a special case of

    data transmission, where a single data stream is transmitted over a number of sub carriers(SCs) to increase robustness against frequency-selective fading or narrowband

    interference. OFDM is leading the engineers into a new era of digital transmission and is

    becoming the chosen modulation technique worldwide.

    NWFP UET, Final Year Project Report, 2007 Page 10

  • 7/27/2019 Real Time Voice OFDM

    11/131

    1.1 Purpose and Objective:The basic feature of this project is to implement the OFDM technique in real timetransmission of the speech signal. The objective of our project is to efficiently transmit

    data between two computer based nodes, in real time using the OFDM technique. This

    will provide a test bed for the future study of OFDM implementation.

    1.2 Scope:Multicarrier communication systems were first conceived and developed in 1960s, but itwas not until their all-digital implementation with the FFT that their attractive features

    were unraveled.The processing power of modern digital signal processors has increased

    to a point where OFDM has become feasible and economical.Examining the patents, journals and books on OFDM it is clear that this technique will

    have an impact on future of communication. Since many communication systems being

    developed use OFDM, it is a worthwhile research topic.Some examples of current applications using OFDM include GSTN (General Switch

    Telephone Network), cellular radio, DSL and ADSL modems, DAB (Digital Audio

    Broadcast) radio, DVB-T (Terrestrial Digital Video Broadcast), HDTV broadcast,HYPERLAN/2(High Performance Local Area Network Standard) and the wireless

    networking standards IEEE.

    1.3 OFDM Basics:This project will focus on OFDM research and simulation. OFDM is especially suitable

    for high speed communication due to its resistance to ISI. ISI occurs when a transmitter

    interferes with itself and the receiver cannot decode the transmission correctly.Because the signal reflects from large objects such as mountains or buildings, the receiver

    sees more than one copy of the signal. In communication technology, this is calledmultipath. Since the indirect paths take more time to travel to the receiver, the delayed

    copies of the signal interferes with the direct signal causing ISI.

    As communication systems increase their information transfer speed, the time for eachtransmission necessarily becomes shorter. Since the delay time caused by multipath

    remains constant, a limitation in high data rate communication avoids this problem by

    sending many low speed transmissions simultaneously. For example the following figure

    shows two ways to transmit the same four pieces of binary data.

    Fig 1.1, Single Carrier vs OFDM modulation technique

    NWFP UET, Final Year Project Report, 2007 Page 11

  • 7/27/2019 Real Time Voice OFDM

    12/131

    Suppose that this transmission takes four seconds, and then each piece of data in the left

    picture has duration of one second. On the other hand OFDM would send four piecessimultaneously as shown on right. In this case, each piece of data has duration of four

    seconds. This longer duration leads to fewer problems with ISI. Another reason to

    consider OFDM is low complexity implementation for high-speed system compared to

    traditional signal carrier techniques.

    1.4 Our Project:In this project the OFDM technique will be implemented. Two PCs will be used. EachPC will be configured with two soundboards. One soundboard will be used for the

    capturing of speech and for playing the speech data. The second sound card will act as anAD/DA converter. This will generate the analog OFDM signal from the output of the

    IFFT at the transmitter end. At the receiver end the sound card will receive the analog

    OFDM signal and will digitize it. The digitized OFDM signal will be demodulated byFFT routine. The block diagram of the overall system is shown in the figure.

    Fig 1.2, The proposed project

    As shown in the figure, the PC2 is configured as OFDM transmitter and PC1 is configured

    as a receiver. The sound card 1 in PC2 will capture the audio data at sampling rate of8000 samples/sec. The SPEEX codec will compress the data and will produce a bit-

    stream of 8kbps. The output of SPEEX codec will be modulated using QPSK modulation.OFDM signal will be generated using IFFT. The output of IFFT is then sent to the second

    sound card, which results in analog OFDM signal. The channel will be a wire connecting

    the two PCs. The speaker out from second sound card in PC2 will go into the line in ofthe sound card in PC1.

    At PC1 the analog OFDM signal will be digitized and then demodulated.

    Sound card

    Audio Capture

    SPEEX

    CODEC

    QPSK

    modulation

    OFDM via

    IFFT

    PC 2

    PC 1

    Sound card

    Audio play back

    SPEEX

    CODEC

    QPSKDemodulation

    OFDM via

    FFT

    Channel

    NWFP UET, Final Year Project Report, 2007 Page 12

  • 7/27/2019 Real Time Voice OFDM

    13/131

    1.5Toolsandskills:1. Two PCs, each with two sound cards

    2. C/C++ programming3. Usage of SPEEX, FFTW and Secret Rabbit Code libraries

    4. MATLAB and Simulink for simulation purposes.

    5.

    WIN32 API.

    6. Knowledge of Digital signal processing and Communication Systems.

    1.6 Problems and Issues Encountered:The project is implemented in C++. Each PC used in obviously not a communication

    transmitter and receiver and each PC does not posses the very means and the refinement

    of the real world implemented communication blocks. Thus it is very much required tooptimize the whole process, and by optimization of process it is meant that to optimize

    the coding.

    One obvious difference that is there between a PC and a real world system is that in the

    PC, only one processor is there. This means that at one time, only one process can becarried out (or the process fallow eachother in series). This further requires optimizing

    the coding and implementation to the best level. An observable reader will notice that the

    sound cards are not perfect transmitting and receiving hardwares, because of theresampling restrictions, frequency drifts with time etc.

    NWFP UET, Final Year Project Report, 2007 Page 13

  • 7/27/2019 Real Time Voice OFDM

    14/131

    Part 2

    Chapter

    The OFDM SystemBefore going into details of the OFDM transmitter and receiver separately, it will be

    intuitive to discuss some of the points that are relatively easy to grasp and thus lay the

    foundation for understanding the in depth concepts that may be hard to come by.

    NWFP UET, Final Year Project Report, 2007 Page 14

  • 7/27/2019 Real Time Voice OFDM

    15/131

    2.1 General Concept:OFDM is a multicarrier, wideband modulation scheme, i.e. the data is modulated not byjust a single frequency, rather the data is sent on a number of frequencies and these

    frequencies bare a special relationship with each other. OFDM is therefore thought as

    serving a dual purpose; it is a multiplexing and modulation technique.

    The general concept of OFDM system is not very different. It corresponds to assigning ofvarious frequencies to the user, with all the frequencies time divided, to carry the user

    digital data. But assignment of a large number of frequencies to a single user may not be

    efficient in terms of the bandwidth of the system. To save the bandwidth, we employfrequencies that are orthogonal to each other (details later) and save much of the

    bandwidth, and thus the name ORTHOGONAL frequency division multiplexing.

    2.2 The Importance of OrthogonalityAny function (t) is orthogonal to any other function *(t) if

    (t) x *(t) dt = 0

    All the subcarriers are sine waves. The area under one period of sine or cosine wave, or

    any other sinusoidal with some phase angle, is zero. This can be shown diagrammatically.

    Fig 2.1, a Sine wave with areas marked in different colors

    If we take any sinusoidal of frequency of integer m and multiply it with a sinusoidal with

    a frequency of integer n, then they form an orthogonal group, if m and n are not equal,i.e.

    sin(mt) x sin(nt) dt = 0 if m n

    This idea is the key to understanding OFDM. The orthogonality allows simultaneous

    transmission on a lot of subcarrires in a tight frequency space without interference fromeachother.

    2.3 Comparison of various Multiplexing techniques:We can compare the different multiplexing techniques with that of OFDM in a

    diagrammatic way. Shown below are most basic multiplexing techniques of FDM and

    TDM. There is also a combination of both these scheme, variously applied. The

    NWFP UET, Final Year Project Report, 2007 Page 15

  • 7/27/2019 Real Time Voice OFDM

    16/131

    comparison of the various modulation techniques and the OFDM technique is imminent.

    OFDM uses parallel data streams, and uses many narrowband overlapping digital signalsin parallel.

    Frequency Division Multiple Access (FDMA), users differentiated by different color

    schemes

    Time Division Multiple Access (TDMA), users differentiated by different color schemes

    NWFP UET, Final Year Project Report, 2007 Page 16

  • 7/27/2019 Real Time Voice OFDM

    17/131

    FDMA and TDMA, users differentiated by different color schemes

    FDMA/Time Division Duplexing

    NWFP UET, Final Year Project Report, 2007 Page 17

  • 7/27/2019 Real Time Voice OFDM

    18/131

    TDMA/Frequency Division Duplexing

    Orthogonal Frequency Division Multiple Access (OFDMA)

    Fig 2.2, Showing different modulation schemes and Multiple access schemes

    Let us now talk in terms of the bandwidth. OFDM uses orthogonal carriers and thespectrum of the carriers overlap. But owing to the orthogonality of the carriers, the

    receiver is able to distinguish between the two adjacent and overlapping carriers. The

    time to send each symbol is increased (symbol length is increased). So OFDM is not only

    NWFP UET, Final Year Project Report, 2007 Page 18

  • 7/27/2019 Real Time Voice OFDM

    19/131

    helpful in saving the bandwidth of the whole system, but also tackles the problems

    related to fading and sampling errors (the details will be provided in the coming text).

    Conventional Frequency Division Multiplexing multicarrier modulation technique

    Orthogonal Frequency Division Multiplexing multicarrier modulation technique

    Fig 2.3, showing frequency spectrum of conventional and orthogonal frequency division

    multiplexing

    2.4 The Block Diagram of an OFDM System:

    Fig 2.4, blocks representing various processing involved in OFDM system

    The basic block diagram of a typical OFDM transceiver, excluding many of the sub-

    blocks, is shown above. There are some specifications particular to the OFDM system.

    One can see that the usual methods of serial to parallel and signal mapping to the

    constellation diagram is applied in the OFDM system. But the use of other blocks maynot yet be clear.

    NWFP UET, Final Year Project Report, 2007 Page 19

  • 7/27/2019 Real Time Voice OFDM

    20/131

    The main problem with the reception of radio signal is fading caused by the multipath

    propagation. Also there is intersymbol interference (ISI), frequency selective fading andintercarrier interference (ICI). Further constraints are limited bandwidth, low power

    consumption, network management and multi-cellular operation. The OFDM system

    employs method to tackle all these issues and problems.

    NWFP UET, Final Year Project Report, 2007 Page 20

  • 7/27/2019 Real Time Voice OFDM

    21/131

    Chapter

    THE OFDM TRANSMITTERThe aim of this chapter is to provide some theoretical background to OFDM transmitter.

    In this chapter, we give the block diagrams of the transmitter system and also sometheory behind the concepts. Pilots and Guard Interval addition is also discussed here.

    NWFP UET, Final Year Project Report, 2007 Page 21

  • 7/27/2019 Real Time Voice OFDM

    22/131

    3.1 The block diagram of OFDM Transmitter system:The block diagram of a simplex point to point OFDM transmitter is hereby shown.

    Fig 3.1, the method of generating an OFDM symbol

    3.2 Steps Involved in Generation of an OFDM symbol:Although the explanation of all the blocks is covered individually in the coming text, it isintuitive to get a grasp of the fundamentals of these.

    Assumptions:In this system, we employ the following assumptions.

    A cyclic prefix is used. The impulse response of the channel is shorter that the cyclic prefix. Transmitter and receiver are perfectly synchronized, although the effects of

    impairments in synchronization will be discussed in the next chapter.

    Channel noise is additive, white and Gaussian. The fading is slow enough for channel to be considered constant during one

    OFDM symbol interval.

    3.2-1 Data Source:

    The data source generates the data that is required to be sent on the link. Data may be

    analog; hence, it is necessary to convert this analog data into a digital form. So the datasource can be accounted as an ADC.

    The various components of the data source thus can be as under.

    Analog source: if data is in analog form, this component is responsible to get that data. Itcan be a transducer system like a microphone etc.

    Sampler: the analog data is fed into the sampler, which quantizes the data, and producesthe binary code representation of every sample of the input.

    3.2-2 Serial to Parallel:

    The data incoming is now divided into parallel streams and then fed to the symbolmapping block.

    3.2-3 Symbol Mapping (Modulation):

    The digital data from the source is fed to the mapper, which maps the incoming data onto

    the constellation diagram. These constellations can be taken according to any phase shift

    NWFP UET, Final Year Project Report, 2007 Page 22

  • 7/27/2019 Real Time Voice OFDM

    23/131

    keying (PSK) or QAM signaling set (symbol mapping). There are N constellation points

    present.

    3.2-4 IDFT:

    The input to IDFT is N data constellation points, where N is the number of DFT points.

    The N output samples of the IDFT, being in time domain (TD), form the baseband signal

    carrying the data symbols on a set of N orthogonal subcarriers (SCs). In a real system,however, not all of these N possible SCs can be used for data.

    Usually, N is taken as an integer to the power of two, enabling the application of the

    highly efficient (inverse) FFT algorithms for modulation and demodulation.Both the real and imaginary components are generated.

    3.2-5 Guard Interval (GI):

    The GI is nothing but the copy of the trailing data of an OFDM symbol. GI is added to

    the start of the symbol. So GI is used as a cyclic prefix whose length should exceed the

    maximum excess delay of the multipath propagation channel. Due to the cyclic prefix,the transmitted signal becomes periodic, as the starting and end points are equivalent and

    the effect of the time-dispersive multipath channel becomes equivalent to a cyclicconvolution, discarding the GI at the receiver.

    GI is added to both real and imaginary part of the symbols.

    3.2-6 DAC:

    The data after GI insertion is carried out to DAC, which converts the digital signal into ananalog signal to be transmitted on the link.

    3.2-7 I/Q modulation:

    Now the real and imaginary parts are used to modulate I and Q channels. These signals

    are then summed to give the transmission signal which is sent on the link.

    3.3 The Working Principles of OFDM Transmitter:The best way to understand an OFDM system is through an example.

    Let us consider that the OFDM system is consisting of four subcarriers. Each carrier is

    modulated using the incoming data.It is to be noted that for any carrier of frequency cn, we have

    cn = n * c1i.e.

    c2 = 2 * c1c3 = 3 * c1c4 = 4 * c1

    In this way, all the frequencies are orthogonal to eachother and they do not cause

    interference when they are added together.Let us consider that we have some serially generated bits with the sequence

    1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1

    NWFP UET, Final Year Project Report, 2007 Page 23

  • 7/27/2019 Real Time Voice OFDM

    24/131

    These bits generated are then converted from serial to parallel.

    Fig 3.2, Serial to Parallel

    Using this conversion, we have actually created a table containing bits in specified rows

    and columns. The table is as shown.

    c1 c2 c3 c41 1 0 01 1 1 0

    1 0 0 0

    0 1 0 10 1 1 1

    Each column represents the bits that are to be carried by the respective subcarrier.Let us pick the BPSK as our modulation scheme. Its a simple matter of extending the

    ongoing discussion to other schemes like QPSK, QAM etc as well. Even we can use

    TCM, which provides coding in addition to modulation.

    Fig 3.3, BPSK Constellation

    Consider each of the carriers separately.

    NWFP UET, Final Year Project Report, 2007 Page 24

  • 7/27/2019 Real Time Voice OFDM

    25/131

    Carrier 1 c1:

    By looking at the table, c1 frequency needs to transmit the bits

    1, 1, 1, 0, 0

    which should be superimposed on the BPSK carrier.

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    Carrier 2 c2:Carrier 2 is modulated by the bits

    1, 1, 0, 1, 1

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    Carrier 3 c3:

    Carrier 3 is modulated by the bits

    0, 1, 0, 0, 1

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    NWFP UET, Final Year Project Report, 2007 Page 25

  • 7/27/2019 Real Time Voice OFDM

    26/131

    Carrier 4 c4:

    The bits that modulate the carrier c4 are

    0, 0, 0, 1, 1

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    After the generation of these modulated carriers, all of them are added together.

    These four carriers are added using the IFFT block.

    The IFFT block combines the carrier signals in the time domain. It is so because IFFTblock converts all the sinusoidal frequencies presented to its input into a composite time

    domain signal.

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-4

    -3

    -2

    -1

    0

    1

    2

    3

    4

    An OFDM symbol

    NWFP UET, Final Year Project Report, 2007 Page 26

  • 7/27/2019 Real Time Voice OFDM

    27/131

    The Real and Imaginary parts are transmitted on the I and Q channels respectively. The

    technique is shown below.

    Fig 3.4, Proposed OFDM Transmitter, showing I and Q channels

    3.3-1 The importance of orthogonality:The orthogonal part of the OFDM name indicates that there is a precise mathematical

    relationship between the frequencies of the carriers in the system. In a normal FDM

    system, the many carriers are spaced apart in such way that the signals can be receivedusing conventional filters and demodulators. In such receivers, guard bands have to be

    introduced between the different carriers, and the introduction of these guard bands in the

    frequency domain results in a lowering of the spectrum efficiency.It is possible, however, to arrange the carriers in an OFDM signal so that the sidebands of

    the individual carriers overlap and the signals can still be received without adjacent

    carrier interference. In order to do this the carriers must be mathematically orthogonal.The receiver acts as a bank of demodulators, translating each carrier down to DC, the

    resulting signal then being integrated over a symbol period to recover the raw data. If the

    other carriers all beat down to frequencies, which, in the time domain, have a whole

    number of cycles in the symbol period (), then the integration process results in zerocontribution from all these carriers. Thus the carriers are linearly independent (i.e.

    orthogonal) if the carrier spacing is a multiple of 1/.

    3.3-2 Mathematical treatment:

    After the qualitative description of the system, it is valuable to discuss the mathematical

    definition of the modulation system. This allows us to see how the signal is generated andhow receiver must operate, and it gives us a tool to understand the effects of

    imperfections in the transmission channel. As noted above, OFDM transmits a large

    number of narrowband carriers, closely spaced in the frequency domain. In order to avoid

    a large number of modulators and filters at the transmitter and complementary filters anddemodulators at the receiver, it is desirable to be able to use modern digital signal

    processing techniques, such as fast Fourier transform (FFT).

    NWFP UET, Final Year Project Report, 2007 Page 27

  • 7/27/2019 Real Time Voice OFDM

    28/131

    Fig 3.5, The spectrum of an individual subcarrier of the OFDM signal

    Fig 3.6, Symbolic picture of the individual subchannels for an OFDM system with N

    tones over a bandwidth W. There is no crosstalk as the maximum of a subcarrier occur atminimums of all other subcarriers

    Fig 3.7, Example of Power spectral Density of a composite OFDM signal

    NWFP UET, Final Year Project Report, 2007 Page 28

  • 7/27/2019 Real Time Voice OFDM

    29/131

    Mathematically, each carrier can be described as a complex wave:

    s(t) = A(t) exp[ j( t + (t) ) ]

    OFDM consists of many carriers. Thus the complex signals s(t) is represented by:

    s(t) = 1 A(t) exp[ j( t + (t) ) ]

    N

    Where

    = o + n

    If we consider the waveforms of each component of the signal over one symbol period,then the variables A(t) and (t) take on fixed values, which depend on the frequency of

    that particular carrier, and so can be rewritten:

    A(t) A

    (t)

    If the signal is sampled using a sampling frequency of 1/T, then the resulting signal isrepresented by:

    s(kT) = 1 A(t) exp[ j( (o + n)kT + )]N

    At this point, we have restricted the time over which we analyze the signal to N samples.It is convenient to sample over the period of one data symbol. Thus we have a

    relationship:

    = NT

    If we put wo = 0, we see that

    s(kT) = 1 A(t) exp (j) exp[ j(n)kT]

    N

    Comparing this equation with the equation of IFFT, i.e.

    g(kT) = 1 G(n/NT) exp[j2nk/N]N

    we see that both are equal, if

    f = /2 = 1/NT = 1/

    This is the same condition that was required for orthogonality (see Importance of

    orthogonality). Thus, one consequence of maintaining orthogonality is that the OFDM

    signal can be defined by using Fourier transform procedures.

    NWFP UET, Final Year Project Report, 2007 Page 29

  • 7/27/2019 Real Time Voice OFDM

    30/131

    3.4 Fading:If the path from transmitter to receiver either has reflections or obstructions, we get whatare known as fading effects. Basically, a copy of signal reaches the receiver with a delay,

    in addition to the original signal, because of multiple paths available to the signal to flow

    and rebound. These multiple paths also change the gain of the signal. There can be many

    copies. The resultant signal, which reaches the receiver, is now the combination of theoriginal signal plus the time-delayed copies of the original signal. Thus, the signal is

    degraded because of the phase shift caused by multi path environment.

    Fig 3.8, The multipath demonstration

    Delay spread is defined as the maximum time delay that occurred in the hostile

    environment. This spread changes from time to time.In the figure below, we show the channel response in ideal case and when there are deep

    fades. We see that because of these fades, some frequencies are not allowed to pass andothers get through with little attenuation. This form of channel response is known asfrequency selective fading, as there are sharp fades and the response of the channel is not

    uniform for all the frequencies. It is to be noted that this response changes with the

    environment. It isnt necessary that the fades be always at the same frequencies.

    Fig 3.9, Channel Response to a Band of Frequencies

    OFDM system offers an advantage over ordinary transmission techniques when the

    environment produces deep fades. In other transmission techniques, if the frequency of

    NWFP UET, Final Year Project Report, 2007 Page 30

  • 7/27/2019 Real Time Voice OFDM

    31/131

    transmission lies in the deep fade, information is lost. While in OFDM system, only a

    subcarrier is affected. The information can be recovered using proper coding techniques.

    3.5 Intersymbol Interference:In telecommunication, the term intersymbol interference (ISI) has the following

    meanings:

    1. In a digital transmission system, distortion of the received signal, which is manifested

    in the temporal spreading and consequent overlap of individual pulses to the degree thatthe receiver cannot reliably distinguish between changes of state, i.e., between individual

    signal elements.At a certain threshold, intersymbol interference will compromise the

    integrity of the received data.

    2. The disturbance caused by extraneous energy from the signal in one or more keying

    intervals that interferes with the reception of the signal in another keying interval.

    3.6 Intercarrier Interference:

    OFDM requires very accurate frequency synchronisation between the receiver and thetransmitter; any deviation and the sub-carriers are no longer orthogonal, causing inter-

    carrier interference (ICI), i.e. cross-talk between the sub-carriers. Frequency offsets are

    typically caused by mismatched transmitter and receiver oscillators, or by Doppler shift

    due to movement. Whilst Doppler shift alone may be compensated for by the receiver,the situation is worsened when combined with multipath, as reflections will appear at

    various frequency offsets, which is much harder to correct. This effect typically worsens

    as speed increases, and is an important factor limiting the use of OFDM in high-speedvehicles.

    3.7 Delay Spread and use of Cyclic Prefixing to Mitigate it:The orthogonality of subchannels in OFDM can be maintained and individual

    subchannels can be completely separated by the FFT at the receiver when there are nointersymbol interference (ISI) and intercarrier interference (ICI) introduced by

    transmission channel distortion. In practice these conditions can not be obtained.

    The multipath delay causes the signal quality to degrade. The original signal is delayed

    by an amount such that is causes interference with the symbol arriving right after it. Thisis called Inter Symbol Interference (ISI).

    Fig 3.10, Delay Spread

    NWFP UET, Final Year Project Report, 2007 Page 31

  • 7/27/2019 Real Time Voice OFDM

    32/131

    Thus, this is a sort of noise. The delay spread only contaminates the start of the next

    coming OFDM symbol.One key principle of OFDM is that since low symbol rate modulation schemes (i.e. where

    the symbols are relatively long compared to the channel time characteristics) suffer less

    from intersymbol interference caused by multipath, it is advantageous to transmit a

    number of low-rate streams in parallel instead of a single high-rate stream.The high rate scheme has the disadvantage as seen from the following figures that

    because of multipath fading, symbols interfere with eachother and the receiver may not

    be able to recognize the arriving signal accordingly.On the other hand, low rate techniques like OFDM employ longer symbol durations to

    combat the effects of interference caused by multipath. As seen, the symbols are now

    more immune to the delay spread.

    Single Carrier High Rate Scheme

    Parallel bit Low Rate Scheme

    Fig 3.11, comparing the timings and delay of Single Carrier and Parallel CarriersSchemes

    One may think that a useful approach can be to delay the sending of the next OFDMsignal by an amount of Delay spread plus some tolerance. This is the guard interval (GI),

    as shown by colored area in the figure.

    NWFP UET, Final Year Project Report, 2007 Page 32

  • 7/27/2019 Real Time Voice OFDM

    33/131

    Fig 3.12, A Proposed Scheme to render Insignificant the effect of Delay Spread

    It is extremely difficult if not impossible to design such hardware that can neglect the

    discontinuities in the analog signal as shown above.

    What we need is

    The start of the OFDM symbol should be out of the delay spread zone so it shouldnot be corrupted.

    Start the signal at a new boundary, whose edge falls outside this zone.We cannot leave this area of delay spread and we cannot run the symbol longer. So we

    need to fill the indicated area with something. The answer to this is the introduction of

    cyclic prefixing.In this method, we slide the start of the OFDM symbol to edge of the delay spread and

    the GI is filled with the copy of the tail end of the OFDM symbol.

    The reason that the guard interval consists of a copy of the end of the OFDM symbol isso that the receiver will correlate the incoming data, for the detection of symbol start and

    frequency, phase and sampling rate offsets.

    Fig 3.13, The Concept of Cyclic Prefixing

    Now the total time of the symbol becomes

    Ttotal = T + Tg

    Where Tg is the time allotted for the GI.

    NWFP UET, Final Year Project Report, 2007 Page 33

  • 7/27/2019 Real Time Voice OFDM

    34/131

    We do not add this cyclic prefix to each of the subcarrier. Cyclic prefix is added to the

    composite OFDM symbol. This prefix is anything from one tenth to one forth of theoriginal OFDM symbol.

    It is the responsibility of the receiver to remove the GI from incoming analog signal.

    The guard-interval also reduces the sensitivity to time synchronization problems.

    3.8 Modulation SchemeThe modulation scheme in an OFDM system can be selected based on the requirement ofpower or spectrum efficiency. The type of modulation can be specified by the complex

    number

    dn = an + jbn ,

    where dn is the mapped data sequence and is complex. The symbols an and bn can be

    selected to (1, 3) for 16QAM and 1 for QPSK. In general, the selection of themodulation scheme applying to each subchannel depends solely on the compromise

    between the data rate requirement and transmission robustness. Another advantage of

    OFDM is that different modulation schemes can be used on different subchannels forlayered services.

    3.9 Interleaving:Interleaving aims to distribute transmitted bits in time or frequency or both to achievedesirable bit error distribution after demodulation. What kind of interleaving pattern is

    needed depends on the channel characteristics. Communication channels are divided into

    fast and slow fading channels.A channel is fast fading if the impulse response changes approximately at the symbol rate

    of the communication system, whereas a slow fading channel stays unchanged for severalsymbols.

    The reason why interleaving is used on OFDM is to attempt to spread the errors out in the

    bit-stream that is presented to the error correction decoder, because when such decodersare presented with a high concentration of errors the decoder is unable to correct all the

    bit errors, and a burst of uncorrected errors occurs.

    Interleaving necessarily introduces delay into the system because bits are not received in

    the same order as the information source transmits them.Frequency (subcarrier) interleaving increases resistance to frequency-selective channel

    conditions such as fading. For example, when a part of the channel bandwidth is faded,

    frequency interleaving ensures that the bit errors that would result from those subcarriersin the faded part of the bandwidth are spread out in the bit-stream rather than being

    concentrated. Similarly, time interleaving ensures that bits that are originally close

    together in the bit-stream are transmitted far apart in time, thus mitigating against severefading as would happen when travelling at high speed.

    However, time interleaving is of little benefit in slowly fading channels, such as for

    stationary reception, and frequency interleaving offers little to no benefit for narrowbandchannels that suffer from flat-fading (where the whole channel bandwidth is faded at the

    same time).

    NWFP UET, Final Year Project Report, 2007 Page 34

  • 7/27/2019 Real Time Voice OFDM

    35/131

    Block interleaving operates on one block of bits at a time. The number of bits in the block

    is called interleaving depth.Deinterleaving is the opposite operation of interleaving; that is, the bits are put back into

    the original order.

    3.10 Channel Estimation:Channel estimation is the task of estimating the frequency response of the radio channel

    the transmitted signal travels before reaching the receiver antenna.The channel can be estimated using pilots. Pilots are known symbols, or data, upon which

    the transmitter and receiver both have agreed.

    For pilot-symbol-aided channel estimation techniques, first the channel coefficients thatbelong to the pilot subcarriers are estimated. Then, these estimates are interpolated over

    the entire frequency-time grid.

    The pilots can be sent using two techniques.

    Regular pilot subcarriers that are similar to the WLAN pilots subcarriers; knowndata is constantly transmitted on them.

    Use the so-called scattered pilots; known data is transmitted only intermittently onthe subcarrier. Then interpolating the frequency response of the subcarriers that

    do not have training information from the known subcarriers performs the channel

    estimation.Pilot symbol assisted modulation (PSAM) obtain a channel estimation using pilots that

    are interspersed with the transmitted data symbols.

    However, it causes data rate reduction or bandwidth expansion. Therefore, spectrallyefficient channel estimation techniques should be considered.

    Fig 3.19, Block type Pilot Arrangement

    NWFP UET, Final Year Project Report, 2007 Page 35

  • 7/27/2019 Real Time Voice OFDM

    36/131

    Fig 3.20, Comb type Pilot Arrangement

    3.11 Adaptive Transmission:The resilience to severe channel conditions can be further enhanced if information about

    the channel is sent over a return-channel. Based on this feedback information, adaptive

    modulation, channel coding and power allocation may be applied across all sub-carriers,or individually to each sub-carrier. In the latter case, if a particular range of frequencies

    suffers from interference or attenuation, the carriers within that range can be disabled or

    made to run slower by applying more robust modulation or error coding to those sub-carriers.

    3.12 Design of the OFDM SystemThe main reason that the OFDM technique has taken a long time to become a prominence

    has been practical. It has been difficult to generate such a signal, and even harder toreceive and demodulate the signal.

    The proposal of a realistic OFDM-based communications system was one of the goals of

    this research project. Therefore, we elaborate here on some hardware related design

    considerations, which are often neglected in theoretical studies. Elements of thetransmission chain that have impact on the design of the transmitted OFDM signal

    include the following:

    The time-dispersive nature of the mobile channel. The transmission scheme must be

    able to cope with this. The bandwidth limitation of the channel. The signal should occupy as little bandwidth

    as possible and introduce a minimum amount of interference to systems on adjacentchannels.

    The transfer function of the transmitter/receiver hardware. This transfer function

    reduces the useable bandwidth compared to the theoretical one given by the sampling

    theorem. That is, some oversampling is required.

    NWFP UET, Final Year Project Report, 2007 Page 36

  • 7/27/2019 Real Time Voice OFDM

    37/131

    Fig 3.21, Showing the Effect of attenuation at the far end frequencies due to the transfer

    function of the Transmitter or Receiver Hardware

    Phase jitter and frequency offsets of the up- and down-converters, and Dopplerspreading of the channel.

    3.13 Advantages of an OFDM Transmitter upon otherSchemes:

    The OFDM transmission scheme has the following key advantages:

    Makes efficient use of the spectrum by allowing overlap By dividing the channel into narrowband flat fading subchannels, OFDM is more

    resistant to frequency selective fading than single carrier systems are.

    Eliminates ISI and IFI through use of a cyclic prefix. Using adequate channel coding and interleaving one can recover symbols lost due

    to the frequency selectivity of the channel.

    Channel equalization becomes simpler than by using adaptive equalization

    techniques with single carrier systems. It is possible to use maximum likelihood decoding with reasonable complexity, as

    discussed in OFDM is computationally efficient by using FFT techniques to

    implement the modulation and demodulation functions.

    OFDM is a spectrally efficient modulation technique It is conveniently implemented using IFFT and FFT operations It handles frequency selective channels well when combined with error correction

    coding

    3.14 Drawbacks of an OFDM system:

    In terms of drawbacks OFDM has the following characteristics: The OFDM signal has a noise like amplitude with a very large dynamic range;therefore it requires RF power amplifiers with a high peak to average power ratio.

    It is more sensitive to carrier frequency offset and drift than single carrier systemsare due to leakage of the DFT.

    NWFP UET, Final Year Project Report, 2007 Page 37

  • 7/27/2019 Real Time Voice OFDM

    38/131

    Chapter

    THE OFDM RECEIVERIn this chapter, we discuss the theories related to the working of an OFDM receiver.

    Various signal detection techniques are discussed along with there quantitative approach.

    Also, the effect of frequency shifts and synchronization impairments is analyzed.

    NWFP UET, Final Year Project Report, 2007 Page 38

  • 7/27/2019 Real Time Voice OFDM

    39/131

    4.1 Block Diagram of an OFDM Receiver System:The following figure shows the simplified block diagram of an OFDM receiver system.

    Fig 4.1, Blocks representing the Processes involved in treating an OFDM symbol at the

    Receiver

    4.2 Steps Involved in Recovery of Data from the OFDM

    Symbol:Here, we discuss the basic principles that are encountered while recovery of information

    is carried out in the receiver system.

    4.2-1 A/D Converter:

    An A/D converter converts the analog input to its corresponding digital output. There aremany techniques of analog to digital conversion related to the hardware employed.

    Output is on a single wire and it is fed to the signal detection and decision block.

    4.2-2 Signal Detection:

    This block estimates the presence of an OFDM signal, which triggers the rest of the

    circuitry. Signal detection is an energy-based scheme that constantly computes the energy

    from its input from A/D block. If this energy is beyond a certain threshold, the arrival ofsignal is signaled and the receiver gets ready to perform the other steps necessary for the

    regeneration of data. Else, the receiver goes into standby or sleep mode if there is no

    indication of signal from the signal detection block.

    The other function performed by this block is the time synchronization of the incoming

    OFDM signal. It indicates the start of the OFDM symbol, so that the blocks following it

    are capturing the correct data.

    4.2-3 GI Removal:

    The GI is inserted in the transmitter, and this is the redundant data that must be removedbefore processing the signal. Although GI can be termed as redundant, this GI is very

    NWFP UET, Final Year Project Report, 2007 Page 39

  • 7/27/2019 Real Time Voice OFDM

    40/131

    essential for an OFDM system to combat the errors arising from the intersymbol

    interference and from the delay spread produced by the environment because of themultiple paths available for signal to flow.

    4.2-4 DFT:

    This block performs the discrete Fourier Transform on the incoming time domain signal.Digital, sampled data from A/D is driven into the DFT block, which produces its

    frequency components at the output. There are N outputs equal to N number of DFT

    points. This block extracts the SCs and each SC is given to a separate line on the outputof the DFT block. Specifically speaking, the DFT block is used to demodulate the data

    constellation on the orthogonal SCs as IDFT block is used to modulate the data.

    Usually, N is taken as an integer to the power of two, i.e.N = 2

    m

    where m is an integer, enabling the application of the highly efficient FFT algorithms for

    modulation and demodulation.Both the real and imaginary components are generated.

    This block also separates the pilot carriers that are essential for error correction and alsofrequency synchronization of the OFDM SCs.

    4.2-5 Symbol Demapping (detection):

    The output of the FFT block is fed to the symbol demapping circuit. This block is the

    inverse of the symbol-mapping block in the transmitter. At the transmitter, the symbolmapper plots the incoming bits on the constellation diagram and generates the complex

    symbols at the output. Here at the receiver, the demapper gets the complex data from the

    FFT block, and then, it generates the output bits that represent the points on theconstellation diagram, corresponding to the complex input.

    The rotation of the symbols, arising from the ISI and ICI and also AWGN channel is

    being corrected by the pilot data estimates.

    4.2-6 Parallel to Serial:

    This block corresponds to the serial to parallel block in the transmitter. The input to this

    block is a parallel data set from the demapper. The parallel stream of data is converted to

    serial form in this block.This generates the output of the receiver, which was intended to be transmitted from the

    transmitter.

    4.3 The Working Principles of an OFDM Receiver:

    We discuss the basic working algorithm for an OFDM receiver with the help of a simpleexample.Here, the same assumptions apply as were discussed before in the Steps Involved in the

    Generation of OFDM symbol of the previous chapter.

    In a classical parallel data system, the total signal frequency band is divided into N

    nonoverlapping frequency subchannels. Each subchannel is modulated with a separatesymbol and, then, the N subchannels are frequency multiplexed. There are three schemes

    that can be used to separate the subbands:

    NWFP UET, Final Year Project Report, 2007 Page 40

  • 7/27/2019 Real Time Voice OFDM

    41/131

    1. Use filters to completely separate the subbands. This method was borrowed from the

    conventional FDM technology.2. Use Discrete Fourier transform (DFT) to modulate and demodulate parallel data. The

    individual spectra are now sinc functions and are not band limited. The FDM is achieved,

    not by bandpass filtering, but by baseband processing. Using this method, both

    transmitter and receiver can be implemented using efficient FFT techniques that reducethe number of operations from N2 in DFT, down to NlogN.

    Let us consider that we have an OFDM system with four SCs, and we are using BPSK as

    the modulation scheme. Suppose an OFDM symbol arrives at the input of A/D. Afterdetection, time synchronization and GI removal, it becomes as shown below.

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-4

    -3

    -2

    -1

    0

    1

    2

    3

    4

    (The A/D converts this signal into its digital representation. And then the Signal Detector

    detects this signal.)

    This signal is passed on to the FFT block.

    As we have assumed, the transmitter and receiver are in perfect synchronization. So thesampling frequency of both transmitter and receiver is the same. The FFT block collects

    data for 4 samples and process this data further after this much time.The FFT block generates the harmonic components present inside this digital signal and

    this is sent on each of the output line of FFT.

    Let us separately discuss the each collection interval of the FFT block and lets have a

    look at the outputs after each of these time intervals.

    NWFP UET, Final Year Project Report, 2007 Page 41

  • 7/27/2019 Real Time Voice OFDM

    42/131

    From Time 0 to 1:

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-4

    -2

    0

    2

    4

    The OFDM signal during 1

    sttime unit

    0 0.2 0.4 0.6 0.8 1-1

    0

    11st output

    0 0.2 0.4 0.6 0.8 1-1

    0

    12nd output

    0 0.2 0.4 0.6 0.8 1-1

    0

    13rd output

    0 0.2 0.4 0.6 0.8 1-1

    0

    14th output

    Individual Outputs of FFT Block

    NWFP UET, Final Year Project Report, 2007 Page 42

  • 7/27/2019 Real Time Voice OFDM

    43/131

    From Time 1 to 2:

    1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2-3

    -2

    -1

    0

    1

    2

    3

    The OFDM signal during 2

    ndtime unit

    1 1.2 1.4 1.6 1.8 2-1

    0

    11st output

    1 1.2 1.4 1.6 1.8 2-1

    0

    12nd output

    1 1.2 1.4 1.6 1.8 2-1

    0

    13rd output

    1 1.2 1.4 1.6 1.8 2-1

    0

    14th output

    Individual Outputs of FFT Block

    NWFP UET, Final Year Project Report, 2007 Page 43

  • 7/27/2019 Real Time Voice OFDM

    44/131

    From Time 2 to 3:

    2 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3-3

    -2

    -1

    0

    1

    2

    3

    The OFDM signal during 3rd

    time unit

    2 2.2 2.4 2.6 2.8 3-1

    0

    11st output

    2 2.2 2.4 2.6 2.8 3-1

    0

    12nd output

    2 2.2 2.4 2.6 2.8 3-1

    0

    13rd output

    2 2.2 2.4 2.6 2.8 3-1

    0

    14th output

    Individual Outputs of FFT Block

    NWFP UET, Final Year Project Report, 2007 Page 44

  • 7/27/2019 Real Time Voice OFDM

    45/131

    From Time 3 to 4:

    3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 4-4

    -3

    -2

    -1

    0

    1

    2

    3

    4

    The OFDM signal during 4

    thtime unit

    3 3.2 3.4 3.6 3.8 4-1

    0

    11st output

    3 3.2 3.4 3.6 3.8 4-1

    0

    12nd output

    3 3.2 3.4 3.6 3.8 4-1

    0

    13rd output

    3 3.2 3.4 3.6 3.8 4-1

    0

    14th output

    Individual Outputs of FFT Block

    NWFP UET, Final Year Project Report, 2007 Page 45

  • 7/27/2019 Real Time Voice OFDM

    46/131

    From Time 4 to 5:

    4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5-3

    -2

    -1

    0

    1

    2

    3

    The OFDM signal during 5

    thtime unit

    4 4.2 4.4 4.6 4.8 5-1

    0

    11st output

    4 4.2 4.4 4.6 4.8 5-1

    0

    12nd output

    4 4.2 4.4 4.6 4.8 5-1

    0

    13rd output

    4 4.2 4.4 4.6 4.8 5-1

    0

    14th output

    Individual Outputs of FFT Block

    The entire individual outputs when are joined together in time domain give rise to the

    signals as shown in the following figures.

    NWFP UET, Final Year Project Report, 2007 Page 46

  • 7/27/2019 Real Time Voice OFDM

    47/131

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    1

    stOutput

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    2

    ndOutput

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    3

    rdOutput

    0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5-1

    -0.5

    0

    0.5

    1

    4

    thOutput

    NWFP UET, Final Year Project Report, 2007 Page 47

  • 7/27/2019 Real Time Voice OFDM

    48/131

    These outputs are continuously fed to the demapper circuit, which maps them and

    generates the respective outputs using the constellation diagram of BPSK.

    Fig 4.2, BPSK Constellation Diagram

    Fig 4.3, Illustration of Parallel To Serial Converter

    The demappers output can be tabulated as fallows.

    Time Output 1 Output 2 Output 3 Output 4

    0 1 1 1 0 0

    1 2 1 1 1 02 3 1 0 0 0

    3 4 0 1 0 1

    4 5 0 1 1 1

    The Parallel to Serial Block converts this parallel stream of data into serial stream and the

    output is the serial data that was fed to the input of the transmitter.

    4.4 Synchronization:Synchronization is an essential task for any digital communication system. Without

    accurate synchronization algorithms, it is not possible to reliably receive the transmitteddata. From the digital baseband algorithm design engineer's perspective, synchronizationalgorithms are the major design problem that has to be solved to build a successful

    product.

    OFDM is used for both broadcast type systems and packet switched networks, like

    WLANs. These two systems require somewhat different approach to the synchronization

    problem. Broadcast systems transmit data continuously, so a typical receiver, like

    NWFP UET, Final Year Project Report, 2007 Page 48

  • 7/27/2019 Real Time Voice OFDM

    49/131

    European Digital Audio Broadcasting (DAB) or Digital Video Broadcasting (DVB)

    system receivers, can initially spend a relatively long time to acquire the signal and thenswitch to tracking mode. On the other hand, WLAN systems typically have to use so

    called "single-shot" synchronization; that is, the synchronization has to be acquired

    during a very short time after the start of the packet. This requirement comes from the

    packet switched nature of WLAN systems and also from the high data rates used. Toachieve good system throughput, it is mandatory to keep the receiver training information

    overhead to the minimum.

    The OFDM signal waveform makes most of the synchronization algorithms designed for

    single carrier systems unusable, thus the algorithm design problem has to be approached

    from the OFDM perspective. This distinction is especially visible on the sensitivitydifference to various synchronization errors between single carrier and OFDM systems.

    The frequency domain nature of OFDM also allows the effect of several synchronization

    errors to be explained with the aid of the properties of the Discrete Fourier Transform(DFT). Another main distinction with single carrier systems is that many of the OFDM

    synchronization functions can be performed either in time- or frequency-domain. Thisflexibility is not available in single carrier systems. The trade-offs on how to perform the

    synchronization algorithms are usually either higher performance versus reducedcomputational complexity.

    4.5 Signal Detection:By signal detection, we mean to find the approximate start of the signal. Thus, this is the

    first of the synchronization algorithms. Afterwards, for the receiver, it depends upon thequality of the signal to detect the true value sent from the transmitter.

    The test may form a shape that if a test parameters exceed a certain threshold Th, the

    signal is present, else not. Like, we can write the format of the test as,

    H < Th : No Data

    H > Th : Data Present

    4.5-1 Energy based Detection Schemes:One of the simplest algorithms for detection of a signal is the calculation of energy

    present, inside a band of symbols. This is so because when there is no signal present, the

    energy of the signal is just that of the noise, which is very less as compared to energywhen a signal exists.

    The receiver can then decide whether signal exists or not based on the amount of energycalculated. A threshold is there, and if the energy exceeds that threshold, the signal

    detector alarms the arrival of a signal to the rest of the receiver circuitry.

    Sliding Window:

    When there is no signal, the receiver input is noise, given by

    rn = wn

    NWFP UET, Final Year Project Report, 2007 Page 49

  • 7/27/2019 Real Time Voice OFDM

    50/131

    When the signal reaches the receiver, the receiver input then becomes

    rn = wn + sn

    Now the decision is based on some window of length L, through which we calculate the

    energy of the signal by

    where mn is the decision variable.

    Calculation of mn can be simplified by noting that mn is a moving sum.Therefore, we can also calculate mn recursively.

    Fig 4.4, Single, Sliding window Scheme

    TheL in the sliding window is application dependant and also, the designer keeps in

    mind the effect of environment and the various attributes of the OFDM signal. Thiswindow sizeL can be made equivalent to the size of the GI.

    Shown below is the MATLAB simulation of arbitrary data and its energy calculation

    with window of size 4.

    0 5 10 15 20 25 30 35 40 45 500

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    Index

    x[n]

    0 5 10 15 20 25 30 35 40 450

    50

    100

    150

    200

    250

    Index

    Energy

    As seen, the start of the signal is indicated by a sharp increase in the energy of theincoming signal. The receiver can pick this information from the signal and can indicate

    to the receiver the start of an OFDM signal at the input of the receiver.

    NWFP UET, Final Year Project Report, 2007 Page 50

  • 7/27/2019 Real Time Voice OFDM

    51/131

    This simple method suffers from a significant drawback; namely, the value of the

    threshold depends on the received signal energy. When the receiver is searching for anincoming packet, the received signal consists of only noise. The level of the noise power

    is generally unknown and can change when the receiver adjusts its Radio Frequency (RF)

    amplifier settings or if unwanted interferers go on and off in the same band as the desired

    system. When a wanted packet is incoming, its received signal strength depends on thepower setting of the transmitter and on the total path loss from the transmitter to the

    receiver.

    Double Sliding Window:

    This method incorporates two adjacent sliding windows of received energy. The principle

    of working of this type of algorithm is to make mn, the decision variable, the ratio of total

    energy contained in the two sliding windows.

    Fig 4.5, Double, Sliding window Scheme

    Window 1 and 2 are considered stationary relative to the incoming data that slides over

    them to the right.

    The response is flat when noise is received, because both windows contain ideally the

    same amount of energy. Once the signal slides in the window 1, the variable mn increasesas energy contained in the sliding window 1 is now much greater than that of window 2.

    mn is the greatest when all of the signal is contained in window 1 and window 2 only

    contains noise.Once the signal slides pass window 1 into window 2, the variable mn starts to decrease.

    And the response again becomes flat when signal exists in both the sliding windows.

    The value of energy in the window 1 is given by

    and the value of energy in the window 2 is generated by the equation

    NWFP UET, Final Year Project Report, 2007 Page 51

  • 7/27/2019 Real Time Voice OFDM

    52/131

    Then the value of the parameter mn is given by

    which shows that mn is an energy ratio.Shown in the following figures is the MATLAB simulation result of a sequence x[n] with

    the window size ofL = 8.

    0 10 20 30 40 50 600

    5

    10

    15

    20

    25

    30

    Index

    Energy

    ratio

    0 10 20 30 40 50 60 70 800

    2

    4

    6

    8

    10

    12

    14

    Index

    x[n]

    The figure clearly shows how the value of mn does not depend on the total received

    power. After the peak, the response levels off to the same value as before the peak,although the received energy level is much higher.

    An additional benefit of this approach is that, at the peak point of mn the value of an

    contains the sum of signal energy S and noise energy N and the bn value is equal to noise

    energy N, thus the value of mn at the peak point can be used to estimate the receivedSNR.

    NWFP UET, Final Year Project Report, 2007 Page 52

  • 7/27/2019 Real Time Voice OFDM

    53/131

    4.6 Symbol Timing:Symbol timing refers to the task of finding the precise moment of when individualOFDM symbols start and end. The symbol timing result defines the DFT window; i.e.,

    the set of samples used to calculate DFT of each received OFDM symbol. The DFT result

    is then used to demodulate the subcarriers of the symbol.

    4.7 Time Synchronization:An obvious way to obtain time synchronization is to introduce a kind of time stamp intothe seemingly irregular and noise-like OFDM time signal. The EU147 DAB system

    which can be regarded as the pioneer OFDM system uses quite a simple method that

    even allows for traditional analog techniques to be used for coarse time synchronization.At the beginning of each transmission frame, the signal will be set to zero for the duration

    of (approximately) one OFDM symbol. This null symbol can be detected by a classical

    analog envelope detector (which may also be digitally realized) and tells the receiverwhere the frame and where the first OFDM symbol begin.

    In the wireless LAN systems IEEE 802.11a and HIPERLAN/2, a reference OFDM

    symbol of length 2TS is used for time synchronization and for the estimation of thechannel coefficients circuit that are needed for coherent demodulation. The OFDM

    subcarriers are modulated with known data.

    Another smart method to find the time synchronization without any time stamp is based

    on the guard interval. We note that an OFDM signal with guard interval has a regularstructure because the cyclically extended part of the signal occurs twice in every OFDM

    symbol of duration TS this means that the OFDM signal s[n] given has the property

    s[n] = s[n + N]

    We may thus correlate s[n] with s[n + N] using a sliding window of length equal to the

    length of the guard interval. This procedure is fallowed for one OFDM symbol lengthafter the detection of signal.

    Fig 4.6, Demonstrating the effect of GI and Correlation on detection of symbol Startingpoint

    Then the maximums that are generated using these correlation windows are stored and atthe end, the index of the sliding window for which the highest peak occurred denotes the

    start of the OFDM symbol.

    NWFP UET, Final Year Project Report, 2007 Page 53

  • 7/27/2019 Real Time Voice OFDM

    54/131

    However, owing to statistical nature of the OFDM symbol, we may not get peak for the

    GI. In that case, to get the time synchronization, we use the pilot signals. The pilots aresent such that the first pilot sent contains some specific frequencies. The next pilot sent

    has frequencies with 180 in phase opposition to the 1st

    pilot. Then the peak will only

    occur for the correlation window with starting index of GI. And hence, the start of the

    frame is at hand.This type of synchronization is useful for broadcasting of OFDM signal or the OFDM

    signal that is continuous.

    4.8 Sampling Clock Synchronization:The oscillators generating the clock pulses for the sampling instances of A/D and D/A arenever synchronized and they have never the same period. This suggests that the shifting

    of the sampling instances occurs at the receiver, although slowly, relative to transmitter.

    Due to this error, the two main impairments occur.

    The slow shift of the symbol timing point causes the SCs to rotate. This effectoccurs for every type of digital transmission.

    The loss of SNR due to ICI generated by the slightly incorrect instants causes theSCs to loss orthogonality. This effect is special to OFDM system.

    Fig 4.7, The Loss of Synchronization between Transmitter and Receiver Sampling Clock

    4.8-1 Estimation:

    The estimation of the sampling frequency errors can be done using the pilot SCs. Pilot

    symbols are known data that are transmitted with the original signal to enable receiver toperform synchronization operations and estimate the channel characteristics as well.

    The rotation of the pilot SCs can then be used to correct the rotation encountered by the

    other SCs of the system and the frequency offset is estimated by using the knowledge

    between the phase rotation caused by the offset and pilot SC index.If T is the sampling time of transmitter and T is the sampling time of receiver, then the

    sampling time offset is given by

    t = T-T

    T

    NWFP UET, Final Year Project Report, 2007 Page 54

  • 7/27/2019 Real Time Voice OFDM

    55/131

    Because of this offset, the symbols are rotated and the information is corrupted. The

    rotation caused by the sampling frequency offset is given by

    where k is the SC index, l is the OFDM symbol index, Ts is the symbol time and Tu isthe usful time. Hence the rotation largest for the outermost SC and also increases with the

    OFDM symbols.

    We use OFDM symbols to estimate the sampling frequency offset. If the symbol containsthree frequencies f1, f2 and f3, we remove GI, take the FFT and then compute the

    following parameters.

    th1 = arg (pilot2(f1) * pilot1(f1))

    th2 = arg (pilot2(f2) * pilot1(f2))

    th3 = arg (pilot2(f3) * pilot1(f3))

    and we have

    = Tu ( th3 th1 + th2 th1 )4*Ts f3-f1 f2-f1

    where th is the angle at the frequency f.

    4.8-2 Correction:

    To correct the sampling frequency offset, we need to resample the input signal. The ratio

    of new sampling frequency to the sampling frequency should be such that

    fnew/fs = (fs + *fs)/fsI.e. the new sampling frequency should be

    fnew = fs + *fs

    4.10 Frequency and Phase Synchronization:If we consider the drawbacks of an OFDM system, the main drawback is its sensitivity to

    the carrier frequency offset. The degradation is caused either by the carrier amplitude

    change or by the ICI of the neighboring SCs.

    If the desired carrier is no longer sampled at the peak of the sinc function of DFT, thechange in amplitude of the SC occurs.

    Adjacent carriers cause the interference because they may not be sampled at the zero

    crossings of the sinc function of the under discussion SC.There is always some residual error in the frequency estimation process. The main

    problem with frequency error is the carrier rotation on the constellation plot. The

    constellation points might rotate over the decision boundaries and it will becomeimpossible to correctly demodulate the incoming data.

    NWFP UET, Final Year Project Report, 2007 Page 55

  • 7/27/2019 Real Time Voice OFDM

    56/131

    Like the frequency error estimation, there are also data aided and non data aided

    techniques for carrier phase tracking. The data aided techniques utilize the pilot symbolssend with the data.

    Fig 4.10, The Carrier Frequency Offset

    Various approaches have arisen for the correction of the frequency synchronization.

    4.10-1 Estimation:

    The Estimation of the frequency and phase offset can be done using GI correlation. An

    OFDM data symbol has GI at the start, and this GI is correlated with the end data of thesymbol. Max value obtained by the correlation is saved and since this value is complex,

    the angle from it is deduced. Say it is . This is the phase offset. The frequency offset f

    can be calculated by the following formula.

    f = /(2)

    4.10-2 Correction:

    For correction purposes, two phasors are made, called the phase_phasor and the

    freq_phasor.For every input complex value at index n, of the OFDM data symbol of N total indices,

    phase_phasor[n] = exp(-j*2**n/N)freq_phasor[n] = exp(-j*2*f*n/N)

    The corrected data is obtained by the following execution

    Data_corrected[n] = (ifft(fft(data[n])*phase_phasor))*freq_phasor

    NWFP UET, Final Year Project Report, 2007 Page 56

  • 7/27/2019 Real Time Voice OFDM

    57/131

    Part3

    Chapter

    The OFDM transmitter in C++This chapter will describe in detail the working principles behind the transmitter of an

    OFDM system being implemented in C++. The theory is already presented in the

    preceding chapters, and hence, in the context of C++, this theory will be incorporated.

    NWFP UET, Final Year Project Report, 2007 Page 57

  • 7/27/2019 Real Time Voice OFDM

    58/131

    5.1 Block Diagram of the Transmitter System:This block diagram resembles to that of an OFDM transmitter system as shownpreviously. But with little changes, it is redrawn according to the steps involved in the

    implementation of this transmitter in our project.

    Fig 5.1, The Implementation of Transmitter in C++

    An acute comparison of this system with the actual OFDM transmitter is beneficial.The 1st sound card of the PC is replacing the data source. This sound card is responsible

    for taking in the analog data and converting it into the digital waveform using PCM. Theoutput of the sound card is a serial stream of data that is buffered and then forwarded.

    Although not shown previously in the OFDM transmitter system, compressor is the

    integral part of our project, which functions to compress the incoming audio stream to areasonable/tolerable limit.

    The compressed data is mapped to the constellation diagram. Here, we can use of the

    constellations like QPSK, QAM, etc.

    The pilot data block inserts known symbols in the IFFT block so that they can betransmitted and can be used by the receiver for correction and detection purposes.

    Once the complex data from the constellation diagram is available, the IDFT of the data

    is taken using IFFT. The output of the IFFT is in time domain and is a serial stream ofdata.

    Cyclic Prefixing is introduced in the Guard Interval Insertion block.

    The 2nd

    sound card of the PC converts the digital signal from the GI Insertion block intoand analog signal. Hence, it replaces the D/A in the previous scheme.

    5.2 The 1st Sound Card:This sound card is necessary to obtain the audio data from the user. It takes the audiodata, converts it into digital, and then buffers the output data in digital form.

    5.2-1 Technical Data:The sound card will receive the input at the rate of 8000 samples per second. This data

    will then be pulse coded and each sample will be represented by 2 bytes, i.e. 16 bits.As the system is implemented in real time, we need to forward some data from the sound

    card after a specific time, say 20msec. We cannot just capture the speech for 10 sec and

    then forward it. In other words, the sound card will capture speech for 20msec, and willforward it to the compressor, which will further process the speech. Again it will start

    NWFP UET, Final Year Project Report, 2007 Page 58

  • 7/27/2019 Real Time Voice OFDM

    59/131

    capturing speech and the cycle will carry on. The missing due to the delay of sending the

    sound data and processing it after every 20msec is tolerable and insensitive to human ear.

    Now if we are sampling at 8000 samples per second with 2 bytes representing each

    sample, then total number of bytes recorded after 20msec will be:

    8000 samples/sec * 2 bytes/sample * 20msec

    = 320 bytes

    This suggests a buffer size of 320 bytes for the 20msec spurts of sound data.

    5.2-2 Programming Notes:To open the sound card for recording, we need the following structures to be filled with

    appropriate data.

    WAVEFORMATEX: This structure contains the information about the format of theoutput of the sound card, i.e. it should be filled accordingly to give us the amount of

    output data, the number of output channels etc. The format tag of the output isWAVE_FORMAT_PCM, which indicates that the output is obtained via PCM. The

    sampling frequency, given by the nSamplesPerSec variable is chosen to be 8000. ThenBitsPerSample is taken as 16, i.e. we have taken 2 bytes per sample of the PCM data. So

    the average number of bytes per second now becomes

    8000 samples/sec * 2 bytes/sample = 16000 bytes/sec

    HWAVEIN: This handle contains the information about the device (sound card) itself.Using this handle, we can play with the sound card as we wish.WAVEHDR: This structure defines the header used to identify a waveform audio buffer.It contains all the information needed by the program to know the whereabouts of the

    buffer, its length and some other information like differentflags. Its member lpData is a

    long pointer to the data buffer where the pulse coded data will be stored. ThedwBufferLength denotes the length of that buffer, and the dwBytesRecorded gives us the

    number of bytes recorded at a given time when the audio input device had started

    receiving the input data. The various flags supply the information about the buffer.WAVEINCAPS: This structure stores the information about the sound device that is beinginstalled in the computer, for example the device name.

    Once all these structures are filled with appropriate data, we need to open the device forrecording. To open the device, we use the function waveInOpen( ).

    waveInOpen(): This function opens the device for recording. Its first parameter is the

    pointer to the handle of the device given byHWAVEIN. The second parameter is the IDof the device. There may be more than one sound cards installed on the PC. So the

    DeviceID is used to select the intended device. The third parameter is the pointer to the

    structure that identifies the desired format for recording waveform-audio data. A pointerto WAVEFORMATEX structure gives this. The forth argument is the pointer to a

    CALLBACK function, or an event handler, or a window, or a thread identifier. We will

    use the CALLBACK function in our project. The fifth argument is the User-instance data

    NWFP UET, Final Year Project Report, 2007 Page 59

  • 7/27/2019 Real Time Voice OFDM

    60/131

    passed to the callback mechanism. The sixth and final argument is the flag for opening

    the device. We used the flag CALLBACK_FUNCTION to indicate that the forthparameter is a CALLBACK procedure address. The return value of the function is

    MMSYSERR_NOERROR if the device is successfully opened or an error otherwise.

    Result = waveInOpen(&InHandle,InDeviceID,&InWaveFormat,(DWORD) waveInProc , (DWORD)this,CALLBACK_FUNCTION);

    if( Result = = MMSYSERR_NOERROR)// device opened, can start recording

    else// add some error handling code here

    After the device is opened, we can start recording. To start the recording, we call thewaveInStart( ) function.

    waveInStart( ):This function starts input on a given audio input device. It has a singleparameter, the handle to the waveform-audio device, given by theHWAVEINstrurcture.It returns MMSYSERR_NOERROR if successful.

    Result = waveInStart(InHandle);if( Result = = MMSYSERR_NOERROR)

    // do further processingelse

    // add some error handling code in here

    waveInStop( ): Once all the recording is done, one can stop reading data from sound card

    using the waveInStop( ) function.

    Result=waveInStop(InHandle);if( Result ! = MMSYSERR_NOERROR)

    // add some error handling code in here

    waveInClose( ): The device is closed using this function. The syntax is as fallows.

    Result=waveInClose(InHandle);if( Result ! = MMSYSERR_NOERROR)

    // add some error handling code in here

    5.2-3 Working:

    The WAVEINHDR structure tells that the buffers are of the size 320 bytes. Once a buffer

    is filled, the CALLBACK function, waveInProc( ) is called. In this function, furtherprocessing of this data of size 320 bytes is done, as shown in figure 5.1. This data is

    compressed and mapped, and then IFFT of the mapped data is carried out. Afterwards we

    add the Guard Interval. And in the last, it is played on the second sound card.

    NWFP UET, Final Year Project Report, 2007 Page 60

  • 7/27/2019 Real Time Voice OFDM

    61/131

    5.3 Compressor:The compressor that has been utilized in the project is the open source SPEEX codec.(For the details of SPEEX codec, please refer to the indexes). Its basis purpose is to

    compress the incoming stream of 320 bytes. The data is compressed using this codec,

    every time a buffer is filled by the sound data and returned to the application.

    We cannot map the whole 320 bytes of data because it defeats the purpose of real timecommunication in our project, the reasons will be visible later.

    5.3-1 Technical Data:SPEEX codec can compress data to variable limits, the limits being initialized by the

    programmer. The mapping of compressed data is to be carried out afterwards. Keeping inmind the constellation diagram, we need to set the quality of the compressed data to such

    an extent that the compressed data is fully mapped on the constellation diagram.

    Compression of 320 bytes to 15 bytes is optimal. These 15 bytes can be fully mappedonto the constellation, the method and theory being presented in the next topic.

    5.3-2 Programming Notes:To use SPEEX, first we need to create a new state of SPEEX in narrowband mode.

    void *state;state = speex_encoder_init(&speex_nb_mode);

    After the creation of the state, that holds the relative information about the compression,

    we need to tell SPEEX how much to compress data. For compression of 320 bytes of data(this constitutes one frame) to 15 bytes, the variable tmp is set to 2 and utilized as shown.

    int tmp=2;

    speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp);

    There is a structure SpeexBits that holds the bits that are written to (and read from) the

    SPEEX routines. It is initialized as fallows.

    SpeexBits bits;speex_bits_init(&bits);

    When every thing is ready, we come to the compression of the incoming data. This

    incoming data from the sound card is of size 320 bytes, and this must be converted tofloat for SPEEX to work on it. An ordinary for loop is utilized for this purpose.

    for (int i=0;i

  • 7/27/2019 Real Time Voice OFDM

    62/131

    speex_bits_reset(&bits);

    Next, we encode the new frame.

    speex_encode(state, input, &bits);

    The structure bits now contains the compressed data when control is returned to the

    program. These bits are copied to a chararray that can be processed further.

    nbBytes = speex_bits_write(&bits, cbits, 200);

    nbBytes is an integer that gives the size of the char written by SPEEX on the char array

    cbits, using the structure bits. The size ofcbits is 200. Only the first nbBytes locations of

    cbits array carry the compressed data.

    5.3-3 Working:

    Incoming data from the sound card is compressed using the SPEEX encoder. The encodercompresses 320 bytes of data to 15 bytes and then writes it onto an array of char calledcbits. The IFFT of the compressed data in this array is taken when this data is mapped

    accordingly on the constellation plot.

    5.4 Signal Mapping:Signal mapping is carried out next. Here the incoming data is mapped to the constellation

    plot where the programmer selects the constellation. It can be QPSK or anything higher.The output of mapped signal is then filled in an array, or buffer, which will be then

    utilized by the IFFT block to take the Inverse Discrete Fourier Transform. We discuss

    some of the features of mapping the data.

    5.4-1 Technical Data:

    It takes 2 bits of the data to map to a single point on the constellation of