102
Design a Digital Communication System EE 5368 WIRELESS COMMUNICATIONS Fall 2010 INSTRUCTOR: Tracy Jing Liang SUBMITTED BY:

System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Embed Size (px)

Citation preview

Page 1: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Design a Digital Communication System

EE 5368WIRELESS COMMUNICATIONS

Fall 2010

INSTRUCTOR:Tracy Jing Liang

SUBMITTED BY:

CHIRAG PANDYA: 1000722427 SAURABH GHORPADE:

VAIBHAV PATANKAR:

Page 2: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Contents

1. Introduction 3

2. Project Assigned 4

3. Rician Channel 6

4. Rician Channel with MRC 10

5. Rician Channel with viterbi Encoder and Decoder 12

6. Rician Channel with Encoding, Interleaver and Puncturing 15

7. Performance Analysis 17

8. Conclusion 29

Reference 30

Appendix 31

2

Page 3: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Introduction

Wireless communications is the fastest growing segment of the data and telecommunications industry, with the potential to provide high-speed high-quality information exchange between portable devices located anywhere in the world. Potential applications enabled by this technology include multimedia Internet-enabled cell phones, smart homes and appliances, automated highway systems, video teleconferencing and distance learning, and autonomous sensor networks, to name just a few.

Radio waves propagate from a transmitting antenna, and travel through free space undergoing reflection, refraction, diffraction, and scattering. They are greatly affected bythe ground terrain, the atmosphere, and the objects in their path, like buildings, bridges, hills, trees, etc. generally there is no direct or line of sight between transmitter and receiver, Due to which received signal reach receiver from different path with different delay creating a multipath. Various path loss models have been devised and analyzed forthe optimum performance of a wireless communication system.

These multipath waves with randomly distributed amplitudes and phases combine at the receiver, to give a resultant signal that fluctuates in time and space. This induces error in received signal. Again, several methods have been adopted to combat this issue. All theseaspects have been considered in this project and the corresponding results have been presented.

3

Page 4: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Project assigned

In this project, you (a team up to 3 graduate students) are requested to perform system level design for a mobile wireless user terminal using block phase estimation algorithm proposed in [1]. The specifications for its general packet data channel (GPDCH, a logic channel) are listed in the following:

• Modulation: QPSK with bits to symbol mapping:00 → 1, 01 → j, 11 → -1, 10 → -j.

• Burst structure:

Guard Symbols (3 symbols)

Unique Word (40 symbols)

Private Inf Symbols (Payload) (500 symbols)

Guard Symbols (3 symbols)

and transmitting such a burst needs 0.5ms.

• The channel bandwidth is 8MHz, and Rician flat fading is assumed.

• 16 samples/symbol should be used based on hardware requirements.

• The roll-off factor for square root raised cosine filter is 0.35.

Please design a simulation reference system for GPDCH subject to Rician flat fading using MATLAB or C, and design a demodulator for such a fading channel with QPSK modulation. Provide a report describe your design with the following performance plots:

1. The Rician flat fading channel K = 7dB, doppler shift (fading bandwidth) f d = 20 Hz , plot the raw bit error rate (BER) at Eb/ No =1, 2, …,7dB obtained in your simulation and compare it with the theoretical raw BER at 1, 2, …, 6,7 dB. BER = [0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];

2. The Rician flat fading channel K = 12dB, f d = 100 Hz, plot the raw bit error rate (BER) at Eb/No =1, 2, …,6, 7dB obtained in your simulation and compare itwith the theoretical raw BER at 1, 2, …, 6, 7 dB.BER = [0.06565 0.04664 0.03124 0.01958 0.011396 0.0061246, 0.00302];

3. The Rician flat fading channel K = 200dB, f Hz d = 0 , plot the raw bit error rate (BER) at Eb/ No =1, 2, …,6dB obtained in your simulation and compare it with the theoretical raw BER,Q(sqrt(2Eb/No) ).

4. If four-path diversity with maximal ratio combining (MRC) is used, repeat

4

Page 5: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

(1)(2)(3), and observe how many dB gains have achieved in each case.

5. If convolutional codes with coding rate ½ and with connections (in octal number) represented in binary [001 011 011] and [001 111 001] in the encoder and viterbi decoder are used in the design, repeat (1)(2)(3), and observe how many dB gains have achieved in each case.

6. If puncturing (b3 is punctured in every four bits b0-b3) and block interleaver (10×5) are used in the design, what’s the performance for the above three channels? How many dB losses comparing to the same channel in (5)? What’s the main advantage of this scheme?

7. In the above systematic studies, what conclusions can be drawn?

5

Page 6: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Rician Channel

Block Diagram:

Fig1 . Block diagram for the Rician channel

Description of Components

Random bits Generator and Burst Builder: This block generates the information payload along with the Guard and the unique word. The total length of the burst is 1092 bits. Payload is 1000 bits, 6 guard bits at each end and 80 bits of unique word.

6

546symbols

1000 bits1092bits

546symbols

546symbols

546 x 16 symbols

546 x 16 +96symbols

546 x 16 =8736symbols546

symbols1092bits

1000 bits

16 x 546samples

Burst Builder1092 bits

Modulation546symbols

Up sampling 16*546=8736samples

Channel(Rician Fading)

Noise

Match Filter(16x546+96 samples) + Truncation

Down sampling(546 symbols)

Demodulation(1092) bits

Phase compensation

Burst Extractor (1000 bits)

Bit Error RateCalculation

Truncation

Pulse shaping (16 x546 + 96 samples)

Block Phase estimation

Random Bits 1000 bits

+

Page 7: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Modulation: In the project we have used QPSK modulation where every symbol consists of two information bits and the modulation is being carried out using the following mapping:

00 101 j11 --110 -j

Upsampler: The up sampler introduces 15 zeros between two symbols thereby leading us to multiply the 546 symbols by 16. This is done to obtain a smooth transition between two symbols.

Pulse Filter Shaping: This filter is essentially introduced before the channel and is used to generate a continuous waveform by using convolution methods. The roll-off factor for square root raised cosine filter is 0.35.

Channel: The channel used in this project is a Rician flat fading channel. The parameters for defining this channel are given by the fading factor (k) and the Doppler frequency (fd). The simulation of the Rician channel is done by using the Jake’s model.

Matched Filter: This filter also works on the principle of convolution and is deployed just after the channel for matching purpose. The roll-off factor for square root raised cosine filter is 0.35.

Down sampler: The down sampler extracts the symbols in multiples of 16. The zeros between two symbols are dropped and the length of burst is reduced to 546 symbols

7

Page 8: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Demodulation and Block Phase Estimation: For implementing the channel compensation successfully the compensating angle has to be evaluated. This is carried out with the help of Viterbi paper. The steps in block phase estimation are as follows:

a. A window size of length N(in our case 60) is chosen with a step size of N(10 in our case)

b. The received signal (z) before demodulation and after down sampling is raised to the power four to give y.

c. The phase angle is calculated over the window size using the formula below:

d. The phase angle calculated by this method has ambiguity because theta

can have values where k varies from -4 to +4

e. The accurate phase rotation is resolved using the calculation of the unique word in the burst structure over the length L of unique word:

f. Based on angle calculated using the unique word above, the actual value of theta is calculated which is nearest to the calculated angle of unique word and is termed theta 1 which is reference to calculation of theta 2

g. After this the block window is incremented to [M, M+N-1] and similarly the phase candidate theta is obtained

h. The theta 2 is calculated from the above theta in step g by choosing one closest to theta 1

i. The above steps a-g is repeated till the whole length of the burst structure is covered.

j. Then linear interpolation is implemented to get the phase rotation for every symbol in the burst

After obtaining the phase rotation for every symbol from the above process the demodulation is carried out using hard slicing.

Channel Compensation: After the transmitted signal undergoes modulation and it passes through the channel, the signal is rotated by a phase angle. At the

8

Page 9: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

receiver end before demodulating the received signal using the hard slicer, it has to be rotated in the anticlockwise by the same amount of phase. This phenomenon is called Channel Compensation.

Hard Slicer: The hard slicer can be best described by the figure below

Fig 2 Hard Slicer

Burst Extractor: In this block we remove the unwanted guard and unique word and keep only the payload which is 1200 bits.

BER Calculator: We compare the generated payload at the transmitter and the received burst at the output of the burst extractor and calculate the BER.

9

Page 10: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Rician Channel with MRC

Block Diagram

Fig3 . Rician channel with MRC

In this case the effect of diversity is taken in to the consideration. Three different channels have been simulated with different gain. In order to improve the performance we have used maximal ratio combining technique. The rest of the blocks are same as case 1. Description of the MRC block is given below.

Maximal Ratio Combination (MRC): It is based on maximal likelihood detection principle. After a lot of derivation it can be proved that if we have L number of copies of a signal in the vector r and their corresponding gain in vector g the send signal will be the one which has the maximum real value after going the following process described in the pictorial diagram below.

10

1000bits1092bits546bits

546symbols

546symbols

546 x 16 symbols

554 x 16 +96symbols

546 x 16 =8736symbols546

symbols1092bits

1000 bits

16 x 546 samples

Burst Builder1092 bits

Modulation546 symbols

Up sampling 16*546=8736samples

Channel(Rician Fading)

MRC (4)

Match Filter(16x546+96 samples) + Truncation

Down sampling(546symbols)

Phase compensation

Burst Extractor (1000 bits)

Bit Error RateCalculation

Truncation

Pulse shaping (16 x546 + 96 samples)

Block Phase estimation

Random Bits 1000 bits

+

MRC Output

546symbols Demodulation

(1092) bits

Noise (4)

Page 11: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Fig 4 Logic diagram for Maximal Ratio Combination (MRC)

11

rt

g*

g*

g*

g*s0*= -j

s0*= j

s0*= -1

s0*= 1

X

X

X

X

X X

XX

MAX

Page 12: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Rician Channel with Viterbi encoder and decoder

Fig5 . Rician channel with Viterbi Encoder and decoder

To improve the BER performance of the system convolution codes have been used. Two new blocks are added here described below. The rest of the blocks are similar to case 1.

Convolution codes (Encoder): Convolution encoder contains memory, and the encoder outputs at any point of time don’t only depend on the present input but also on the previous inputs. A rate R=k/n convolution encoder with memory order m can be realized as k-input, n-output linear sequential circuit with input memory m; that is, inputs remain in the encoder for an additional m time units after entering. Encoders for convolution codes fall into two general categories of feed forward and feedback. Further, within each category, encoders can be either systematic or non-systematic. For an encoder with memory m, we can write the convolution operation using the following mathematical model stated below. Where signifies output lth bit of jth output, u corresponds to the input bit

sequence and corresponds to the i th bit of jth generator sequence

12

546 symbols 500bits1000bits1092 bits

546symbols

546symbols

554 x 16 symbols

546 x 16 +96symbols

5546x 16 =8736symbols546

symbols1000 bits

16 x 546 samples

Burst Builder1092 bits

Modulation546 symbols

Up sampling 16*546=8736samples

Channel(Rician Fading)

Match Filter(16x546+96 samples) + Truncation

Down sampling(546 symbols)

Phase compensation

Viterbi decoder

Bit Error RateCalculation

Truncation

Pulse shaping (16 x546 + 96 samples)

Block Phase estimation

Random Bits 500bits

+

Demodulation

546 symbols

Burst Extractor

Noise

Viterbi Encoder

1092bits

MRC Output

Page 13: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Fig 6 A rate R=1/2 binary nonsystematic feed forward convolution encoder with memory order m=3

Viterbi Decoder: Viterbi decoder is based on trellis diagram and maximal likelihood principle. A pictorial representation of Veterbi decoder is as follows:

Fig 7 Viterbi Decoder and Trellis diagramFrom the above trellis diagram the decoded bits can be determined based on minimum hamming distance which is essentially the number of bits that differ in value corresponding to the received bits. The upper branch in the trellis diagram corresponds to input bit 1 and lower branch corresponds to input bit 0.

13

V(1)

V(0)

u

+

+

Page 14: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Rician Channel with coding, encoding, interleaver and puncturing

Fig8 . Rician channel with Viterbi Encoder and decoder, puncturing and interleaving

14

666bits

546 symbols 1000bits1092 bits

546symbols

546symbols

546x 16 symbols

546 x 16 +96symbols

16 x 546 samples

Channel(Rician Fading)

Match Filter(16x546+96 samples) + Truncation

Down sampling(546 symbols)

Phase compensation

Viterbi decoder

Bit Error RateCalculation

Truncation

Block Phase estimation+

Demodulation

546 symbols

Burst Extractor

Noise

Puncturing Interleaving

Deinterleaver

Depuncturing(13342bits)

546x 16 =8736symbols

1092bits

Viterbi Encoder(1332 bits)

546symbols

1000 bitsBurst Builder1092 bits

Modulation546symbols

Up sampling 16*546=8736samples

Pulse shaping (16 x546 + 96 samples)

Random Bits 666 bits

1000 bits

Page 15: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Interleaver and de-interleaver: Interleaving is an important phenomenon by which consecutive information bits are scattered in order to avoid loss of sequence of information bits due to channel fading. Usually the generated information bit is inserted row wise in a matrix of dimension m x n and taken out column wise. In this way the two consecutive information bits before interleaving are now scattered by a distance by m bits apart after interleaving. Similarly in the de-interleaver part, the information bits at the receiver end after burst extraction are fed in the same matrix(m x n) column wise and taken out row wise to have the same sequence of information bits which was present at the transmitted end before interleaving. The entire process can be viewed as:

Let the input to the interleaver be denoted by vector x and output by vector y

x = x1 x2 x3 x4 x5 x6 …………………………………….………………x600

Let us take the matrix size of 10 x 5

Interleaver

The output of the interleaver will be x1 x6 ………x596; x2 x7…….x597; x5 x10….x600.The same process is implemented in the de-interleaver section in the reverse order.

15

x1 x2 x3 x4 x5

x6 x7 x8 x9 x10

.

.

.X596 x597 x598 x599 x600

x

Page 16: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Puncturing:

The puncturing process has the following properties:a. Some of the bits in the coded bits are not transmittedb. Receiver inserts dummy bits(or jus insert zero) to replace the punctured bits in

the receiverc. The bits that are not transmitted are defined by a puncturing patternd. Puncturing is used for implementing various information bit rate

Example of puncturing

Punctured

The code rate after puncturing was 3/4 .

16

Page 17: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Simulation Results

PROBLEM 1:

K=7dB and Fd =20Hz.

Eb/N0 1 2 3 4 5 6 7BER(Theory) 0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135BER(Practical) 0 0.0954 0.0652 0.0589 0.0319 0.0249 0.0189

17

Page 18: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 2:

K=12db and Fd =100Hz.

Eb/N0 1 2 3 4 5 6 7BER(Theory) 0.0656 0.04664 0.03124 0.01958 0.011396 0.006124600.00302BER(Practical) 0.0885 0.0678 0.0469 0.0279 0.0138 0.0090 0.0054

18

Page 19: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 3:

K=200db and Fd =0Hz

Eb/N0 1 2 3 4 5 6BER(Theory) 0.0563 0.0375 0.0229 0.0125 0.0060 0.0024BER(Practical) 0.0706 0.0385 0.0234 0.0130 0.0061 0.0025

19

Page 20: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 4:

Results for MRC

1. K=7db and fd =20Hz.

Eb/N0 1 2 3 4 5 6 7BER(MRC) 0.1030 0.0727 0.0597 0.0483 0.0265 0.0215 00.0176BER(Practical) 0.1165 0.0954 0.0652 0.0589 0.0319 0.0249 0.0189

Gain due to MRC code : 0.6dB

20

Page 21: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

2. K=12db and fd =100Hz.

Eb/N0 1 2 3 4 5 6 7BER(MRC) 0.0882 0.0582 0.0404 0.0264 0.0118 0.0087 00.0052BER(Practical) 0.0885 0.0678 0.0469 0.0279 0.0138 0.0090 0.0054

Gain due to MRC code : 0.3dB

21

Page 22: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

3. K=200db and Fd =0Hz.

Eb/N0 1 2 3 4 5 6BER(Convolution) 0.0612 0.0349 0.0213 0.0110 0.0053 0.0019BER(Practical) 0.0706 0.0385 0.0234 0.0130 0.0061 0.0025

Gain due to MRC code : 0.1dB

22

Page 23: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 5:

Results for Convolution

1. K=7db and fd =20Hz.

Eb/N0 1 2 3 4 5 6 7BER(Convolution) 0.0947 0.0670 0.0573 0.0445 0.0219 0.0119 0 0.0100BER(Practical) 0.1165 0.095 0.0652 0.0589 0.0319 0.0249 0.0189

Gain due to convolution code : 0.9dB

23

Page 24: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

2. K=12db and fd =100Hz.

Eb/N0 1 2 3 4 5 6 7BER(Convolution) 0.0541 0.0377 0.0134 0.0103 0.0063 0.0027 0 0.0015BER(Practical) 0.0885 0.0678 0.0469 0.0279 0.0138 0.0090 0.0054

Gain due to convolution code : 1.9dB

24

Page 25: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

3. K=200db and Fd =0Hz.

Eb/N0 1 2 3 4 5 6BER(Convolution) 0.0495 0.232 0.0087 0.0046 0.0026 0.0063BER(Practical) 0.0706 0.0385 0.0234 0.0130 0.0061 0.0025

Gain due to convolution code : 0.9dB

25

Page 26: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 6:

Results for Puncturing and Interleaving:

1. K=7db and Fd =20Hz.

Eb/N0 1 2 3 4 5 6 7BER(Puncturing) 0.3327 0.3333 0.3334 0.3303 0.3325 0.3335 00.3322BER(Practical) 0.1185 0.0954 0.0652 0.0589 0.0319 0.0249 0.0189

LOSS

26

Page 27: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

2. K=12db and Fd =100Hz.

Eb/N0 1 2 3 4 5 6 7BER(Puncturing) 0.3316 0.3321 0.3346 0.3345 0.3328 0.3318 00.3312BER(Practical) 0.0885 0.0678 0.0469 0.0279 0.0138 0.0090 0.0054

LOSS

27

Page 28: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

3. K=200db and Fd =0Hz.

Eb/N0 1 2 3 4 5 6BER(Puncturing) 0.3319 0.3340 0.3314 0.3333 0.3330 0.3308BER(Practical) 0.0706 0.0385 0.0234 0.0130 0.0061 0.0025

LOSS

28

Page 29: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

PROBLEM 7:

Conclusion

1. Simulations to compare the performance of the system were performed and the results were noted. It was observed that as BER reduces as EB/N0 increases for a particular value of Rician factor and Doppler shift. The Simulated values were close to theoretical values( somewhat greater).

The performance for 3rd case was better than other two cases because Doppler Shift was 0. Comparing the performance of Case 2 with Case 1 it was observed that the performance for Case 2 was better than Case 1.

2. Implementation of convolution codes improves the result i.e. BER reduces significantly and that is very much in lines with the affect of Convolution coding in BER according to theoretical calculations.

3. MRC, when incorporated in code improves the performance. It reduces BER as EB/N0 increases for a particular value of Rician factor and Doppler shift. MRC is based on Diversity and BER for Diversity is less than the basic Rician channel. In our plot we have observed that introduction of MRC reduces the BER and is less than the calculated BER of Basic Channel

4. In the final case, where we implemented puncturing and interleaving along with convolution coding and decoding, we observed that the BER degrades compared with Basic Rician Channel. This is mainly due to puncturing. Puncturing is only effective in the case of burst error caused by noisy environment.

29

Page 30: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Reference

[1].Andrew J. Viterbi, Audrey M. Viterbi, “Nonlinear Estimation of PSK-Modulated Carrier Phase with Application to Burst Digital Transmission”, IEEE Transaction on Information Theory, vol. IT – 29, No. 4, pp 543-551, July 1983.

[2].Class notes on Wireless Communication Systems (EE 5368) by Dr. Qilian Liang[3].Matlab help.

[4]. John Proakis, Digital Communications, Fourth Edition 2000.

30

Page 31: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Appendix

Code for Q. 1

clc;clear all;for snr=1:7for count=1:1000

% Inforamation symbols

no_of_infosymbol=1000; Infosymbol=randint (1,no_of_infosymbol); Kn=[5.1918e+007 2.5959e+007 1.7306e+007 1.2980e+007 1.0384e+007 0.8653e+007 0.7417e+007]; % got from calibration

% uniqueword uw=[0 0 1 0 1 1 1 0]; uniqueword=cat(2,uw,uw,uw,uw,uw,uw,uw,uw,uw,uw);

% guard guard (1:6) =0;

%burst structure burst=cat(2,guard,uniqueword,Infosymbol,guard); burst_len= length (burst); % 1092

% QPSK Modulation for(t=1:2:burst_len) if((burst(t)==0) && (burst(t+1)==0)) burst_mod((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_mod((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_mod((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_mod((t+1)/2)=-1; end end burst_length= length(burst_mod); % 546

% Upsampling m=1;for j=1:burst_length up(m)= burst_mod(j); for k=1:16 m=m+1; up(m)=0;

31

Page 32: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

endendupsample_length = length( up)-1; % length is 8736 ( 546*16)

for i=1:upsample_lengthupsample(i)= up(i);end

% pulse shaping

filter=rcosine(1,16,'sqrt',0.35);filter_len=length(filter); % length is M=97pulse_op=conv(filter,upsample);pulse_op_len= length (pulse_op);% length is (546*16 + 97-1)= 8832

% Discarding M-1 samples

cut1=(filter_len-1)/2;cut2= pulse_op_len-cut1;j=1;for i= cut1+1:cut2 pulseshape_output(j)=pulse_op(i); j=j+1;endpulseshape_op_len=length(pulseshape_output); % length is 546*16= 8736

% Channel fm=20;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

K=7;

32

Page 33: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

A=10^(-K/20); % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factor

for t=1:8736Rician(t)=((1 + A*Gt(t)).*B); % This is Ricianend

for i=1:pulseshape_op_len Ch_output(i)=Rician(i)*pulseshape_output(i);endCh_output_len= length(Ch_output);

% AWGNK=Kn(snr);Noise=K*((randn(1,Ch_output_len))+j*(randn(1,Ch_output_len)));

Tx_output=Ch_output + Noise;

% RECEIVER

% Matched Filter

Matched_filter= rcosine(1,16,'sqrt',0.35);len_Matched_filter= length(Matched_filter); % length 97

Matched_conv=conv(Matched_filter,Tx_output);len_Matched_conv=length(Matched_conv); % length 8832

% discard N-1;

m1= (len_Matched_filter-1)/2;m2= (len_Matched_conv)-m1;j=1;for i= m1+1 : m2 Matched_output(j) = Matched_conv(i); j=j+1;endMatched_output_length=length(Matched_output); % length 8736

% DOWNSAMPLING

j=1;for i= 1:16:Matched_output_length downsample(j)= Matched_output(i); j=j+1;end

len_downsample=length(downsample); % length is 546

% Block phase estimation Window_length=50; %The block size

33

Page 34: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

wstep=10; % The step in which the sliding window moves. uw_tx=burst_mod(4:44); % Transmitted UW is from 4 to 44 symbols( 40 )uw_rx=downsample(4:44); % Received UW is from 4 to 54 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downsample)) s=sum(downsample((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downsample)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); Blockphase=downsample.*exp(-j*theta_rx); % perform phase compensation Blockphase_len=length(Blockphase);

% Hardslicer n=1;for m=1:2:(2*Blockphase_len)-1 angl = angle(Blockphase(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

BER=0;for i= 1:1092 if(burst_rx(i)~= burst(i))

34

Page 35: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

BER=BER+1; endend BER=BER/1092;ber(count)=BER;endbit_err=sum(ber)/1000;

BIT_ERR(snr)=bit_err;endSNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off

2. Code for Q.2

clc;clear all;for snr=1:7for count=1:1000

% Inforamation symbols

no_of_infosymbol=1000; Infosymbol=randint (1,no_of_infosymbol); Kn=[5.1918e+007 2.5959e+007 1.7306e+007 1.2980e+007 1.0384e+007 0.8653e+007 0.7417e+007]; % got from calibration

% uniqueword uw=[0 0 1 0 1 1 1 0]; uniqueword=cat(2,uw,uw,uw,uw,uw,uw,uw,uw,uw,uw);

% guard guard (1:6) =0;

%burst structure burst=cat(2,guard,uniqueword,Infosymbol,guard);

35

Page 36: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

burst_len= length (burst); % 1092

% QPSK Modulation for(t=1:2:burst_len) if((burst(t)==0) && (burst(t+1)==0)) burst_mod((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_mod((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_mod((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_mod((t+1)/2)=-1; end end burst_length= length(burst_mod); % 546

% Upsampling m=1;for j=1:burst_length up(m)= burst_mod(j); for k=1:16 m=m+1; up(m)=0; endendupsample_length = length( up)-1; % length is 8736 ( 546*16)

for i=1:upsample_lengthupsample(i)= up(i);end

% pulse shaping

filter=rcosine(1,16,'sqrt',0.35);filter_len=length(filter); % length is M=97pulse_op=conv(filter,upsample);pulse_op_len= length (pulse_op);% length is (546*16 + 97-1)= 8832

% Discarding M-1 samples

cut1=(filter_len-1)/2;cut2= pulse_op_len-cut1;j=1;for i= cut1+1:cut2 pulseshape_output(j)=pulse_op(i); j=j+1;endpulseshape_op_len=length(pulseshape_output); % length is 546*16= 8736

% Channel fm=100;N=66; wm=2*pi*fm;

36

Page 37: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

K=12; A=10^(-K/20); % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factor

for t=1:8736Rician(t)=((1 + A*Gt(t)).*B); % This is Ricianend

for i=1:pulseshape_op_len Ch_output(i)=Rician(i)*pulseshape_output(i);endCh_output_len= length(Ch_output);

% AWGNK=Kn(snr);Noise=K*((randn(1,Ch_output_len))+j*(randn(1,Ch_output_len)));

Tx_output=Ch_output + Noise;

% RECEIVER

% Matched Filter

Matched_filter= rcosine(1,16,'sqrt',0.35);len_Matched_filter= length(Matched_filter); % length 97

Matched_conv=conv(Matched_filter,Tx_output);len_Matched_conv=length(Matched_conv); % length 8832

37

Page 38: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% discard N-1;

m1= (len_Matched_filter-1)/2;m2= (len_Matched_conv)-m1;j=1;for i= m1+1 : m2 Matched_output(j) = Matched_conv(i); j=j+1;endMatched_output_length=length(Matched_output); % length 8736

% DOWNSAMPLING

j=1;for i= 1:16:Matched_output_length downsample(j)= Matched_output(i); j=j+1;end

len_downsample=length(downsample); % length is 546

% Block phase estimation Window_length=50; %The block size wstep=10; % The step in which the sliding window moves. uw_tx=burst_mod(4:44); % Transmitted UW is from 4 to 44 symbols( 40 )uw_rx=downsample(4:44); % Received UW is from 4 to 54 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downsample)) s=sum(downsample((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downsample)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end);

38

Page 39: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Blockphase=downsample.*exp(-j*theta_rx); % perform phase compensation Blockphase_len=length(Blockphase);

% Hardslicer n=1;for m=1:2:(2*Blockphase_len)-1 angl = angle(Blockphase(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

BER=0;for i= 1:1092 if(burst_rx(i)~= burst(i)) BER=BER+1; endend BER=BER/1092;ber(count)=BER;endbit_err=sum(ber)/1000;

BIT_ERR(snr)=bit_err;endSNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off

39

Page 40: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

3. Code for Q. 3

clc;clear all;for snr=1:7for count=1:1000

% Inforamation symbols

no_of_infosymbol=1000; Infosymbol=randint (1,no_of_infosymbol); Kn=[5.1918e+007 2.5959e+007 1.7306e+007 1.2980e+007 1.0384e+007 0.8653e+007 0.7417e+007]; % got from calibration

% uniqueword uw=[0 0 1 0 1 1 1 0]; uniqueword=cat(2,uw,uw,uw,uw,uw,uw,uw,uw,uw,uw);

% guard guard (1:6) =0;

%burst structure burst=cat(2,guard,uniqueword,Infosymbol,guard); burst_len= length (burst); % 1092

% QPSK Modulation for(t=1:2:burst_len) if((burst(t)==0) && (burst(t+1)==0)) burst_mod((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_mod((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_mod((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_mod((t+1)/2)=-1; end end burst_length= length(burst_mod); % 546

% Upsampling m=1;for j=1:burst_length up(m)= burst_mod(j); for k=1:16 m=m+1; up(m)=0; endendupsample_length = length( up)-1; % length is 8736 ( 546*16)

for i=1:upsample_lengthupsample(i)= up(i);

40

Page 41: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

end

% pulse shaping

filter=rcosine(1,16,'sqrt',0.35);filter_len=length(filter); % length is M=97pulse_op=conv(filter,upsample);pulse_op_len= length (pulse_op);% length is (546*16 + 97-1)= 8832

% Discarding M-1 samples

cut1=(filter_len-1)/2;cut2= pulse_op_len-cut1;j=1;for i= cut1+1:cut2 pulseshape_output(j)=pulse_op(i); j=j+1;endpulseshape_op_len=length(pulseshape_output); % length is 546*16= 8736

% Channel fm=0;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

K=200; A=10^(-K/20); % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factor

for t=1:8736Rician(t)=((1 + A*Gt(t)).*B); % This is Ricianend

41

Page 42: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

for i=1:pulseshape_op_len Ch_output(i)=Rician(i)*pulseshape_output(i);endCh_output_len= length(Ch_output);

% AWGNK=Kn(snr);Noise=K*((randn(1,Ch_output_len))+j*(randn(1,Ch_output_len)));

Tx_output=Ch_output + Noise;

% RECEIVER

% Matched Filter

Matched_filter= rcosine(1,16,'sqrt',0.35);len_Matched_filter= length(Matched_filter); % length 97

Matched_conv=conv(Matched_filter,Tx_output);len_Matched_conv=length(Matched_conv); % length 8832

% discard N-1;

m1= (len_Matched_filter-1)/2;m2= (len_Matched_conv)-m1;j=1;for i= m1+1 : m2 Matched_output(j) = Matched_conv(i); j=j+1;endMatched_output_length=length(Matched_output); % length 8736

% DOWNSAMPLING

j=1;for i= 1:16:Matched_output_length downsample(j)= Matched_output(i); j=j+1;end

len_downsample=length(downsample); % length is 546

% Block phase estimation Window_length=50; %The block size wstep=10; % The step in which the sliding window moves. uw_tx=burst_mod(4:44); % Transmitted UW is from 4 to 44 symbols( 40 )

42

Page 43: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

uw_rx=downsample(4:44); % Received UW is from 4 to 54 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downsample)) s=sum(downsample((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downsample)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); Blockphase=downsample.*exp(-j*theta_rx); % perform phase compensation Blockphase_len=length(Blockphase);

% Hardslicer n=1;for m=1:2:(2*Blockphase_len)-1 angl = angle(Blockphase(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

BER=0;for i= 1:1092 if(burst_rx(i)~= burst(i)) BER=BER+1; endend BER=BER/1092;

43

Page 44: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

ber(count)=BER;endbit_err=sum(ber)/1000;

BIT_ERR(snr)=bit_err;endSNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off

4. [1] Code for Q. 4 Part 1 clear all;

close all;clc; clear memory;for SNR=1:7 for burstcount=1:100 Burst1=Burstbuilder(); Modulatedout1= QPSK(Burst1); Upsampleburst1 = Upsample(Modulatedout1); Shapedburst1= Pulseshaping(Upsampleburst1); K=7;fm=20; % CHANNEL 1 Creat_channe_l1=Rician(K,fm,Shapedburst1); Creat_channe_l11=mulchan_pulse(Creat_channe_l1,Shapedburst1); Txsignal1 =awgnoise(Creat_channe_l11, SNR); match1= Matchfilter(Txsignal1);

44

Page 45: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Downburst1= Downsample(match1); Blockphase1=Blockestimate(Downburst1,Modulatedout1); % CHANNEL 2 Creat_channe_l2=Rician(K,fm,Shapedburst1); Creat_channe_l22=mulchandpulse(Creat_channel_2,Shapedburst1); Txsignal2 =awgnoise(Creat_channe_l22, SNR); match2= Matchfilter(Txsignal2); Downburst2= Downsample(match2); Blockphase2=Blockestimate(Downburst2,Modulatedout1); % CHANNEL 3 Creat_channe_l3=Rician(K,fm,Shapedburst1); Creat_channe_l33=mulchanpulse(Creat_channe_l3,Shapedburst1); Txsignal3 =awgnoise(Creat_channe_l33, SNR); match3= Matchfilter(Txsignal3); Downburst3= Downsample(match3); Blockphase3=Blockestimate(Downburst3,Modulatedout1); % CHANNEL 4 Creat_channe_l4=Rician(K,fm,Shapedburst1); Creat_channe_l44=mulchanpulse(Creat_channe_l4,Shapedburst1); Txsignal4 =awgnoise(Creat_channe_l44, SNR); match4= Matchfilter(Txsignal4); Downburst4= Downsample(match4); Blockphase4=Blockestimate(Downburst4,Modulatedout1); rxburst_1=Creat_channel1(1:16:end); rxburst_2=Creat_channel2(1:16:end); rxburst_3=Creat_channel3(1:16:end); rxburst_4=Creat_channel4(1:16:end); mu=zeros(1,4); s=[ 1 j -1 -j ];

45

Page 46: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

for a = 1:length(Blockphase1) rsum(a)= conj(rxburst_1)*Blockphase1(a) + conj(rxburst_2)*Blockphase2(a) + ... conj(rxburst_3)*Blockphase3(a) + conj(rxburst_4)*Blockhpahse4(a); mu(1)=rsum(a)*conj(s(1)); mu(2)=rsum(a)*conj(s(2)); mu(3)=rsum(a)*conj(s(3)); mu(4)=rsum(a)*conj(s(4)); [Y,I]=max(real(mu)); blockphaseout(a)=s(I); end Blockphase=hardslice(blockphaseout); [number,ratio(burstcount)] = biterr(Blockphase(103:1102),Burst1(103:1102)); end Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

46

Page 47: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

4. [2] Code for Q. 4 Part 2

clear all;

close all;clc; clear memory;for SNR=1:7 for burstcount=1:100 Burst1=Burstbuilder(); Modulatedout1= QPSK(Burst1); Upsampleburst1 = Upsample(Modulatedout1); Shapedburst1= Pulseshaping(Upsampleburst1); K=12;fm=100; % CHANNEL 1 Creat_channe_l1=Rician(K,fm,Shapedburst1); Creat_channe_l11=mulchan_pulse(Creat_channe_l1,Shapedburst1); Txsignal1 =awgnoise(Creat_channe_l11, SNR); match1= Matchfilter(Txsignal1); Downburst1= Downsample(match1); Blockphase1=Blockestimate(Downburst1,Modulatedout1); % CHANNEL 2 Creat_channe_l2=Rician(K,fm,Shapedburst1); Creat_channe_l22=mulchandpulse(Creat_channel_2,Shapedburst1); Txsignal2 =awgnoise(Creat_channe_l22, SNR); match2= Matchfilter(Txsignal2); Downburst2= Downsample(match2); Blockphase2=Blockestimate(Downburst2,Modulatedout1); % CHANNEL 3 Creat_channe_l3=Rician(K,fm,Shapedburst1); Creat_channe_l33=mulchanpulse(Creat_channe_l3,Shapedburst1);

47

Page 48: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Txsignal3 =awgnoise(Creat_channe_l33, SNR); match3= Matchfilter(Txsignal3); Downburst3= Downsample(match3); Blockphase3=Blockestimate(Downburst3,Modulatedout1); % CHANNEL 4 Creat_channe_l4=Rician(K,fm,Shapedburst1); Creat_channe_l44=mulchanpulse(Creat_channe_l4,Shapedburst1); Txsignal4 =awgnoise(Creat_channe_l44, SNR); match4= Matchfilter(Txsignal4); Downburst4= Downsample(match4); Blockphase4=Blockestimate(Downburst4,Modulatedout1); rxburst_1=Creat_channel1(1:16:end); rxburst_2=Creat_channel2(1:16:end); rxburst_3=Creat_channel3(1:16:end); rxburst_4=Creat_channel4(1:16:end); mu=zeros(1,4); s=[ 1 j -1 -j ]; for a = 1:length(Blockphase1) rsum(a)= conj(rxburst_1)*Blockphase1(a) + conj(rxburst_2)*Blockphase2(a) + ... conj(rxburst_3)*Blockphase3(a) + conj(rxburst_4)*Blockhpahse4(a); mu(1)=rsum(a)*conj(s(1)); mu(2)=rsum(a)*conj(s(2)); mu(3)=rsum(a)*conj(s(3)); mu(4)=rsum(a)*conj(s(4)); [Y,I]=max(real(mu)); blockphaseout(a)=s(I); end Blockphase=hardslice(blockphaseout); [number,ratio(burstcount)] = biterr(Blockphase(103:1102),Burst1(103:1102)); end Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.06565 0.04664 0.03124 0.01958 0.011396 0.0061246 0.00302];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;

48

Page 49: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

4. [3] Code for Q. 4 Part 3

clear all;

close all;clc; clear memory;for SNR=1:7 for burstcount=1:100 Burst1=Burstbuilder(); Modulatedout1= QPSK(Burst1); Upsampleburst1 = Upsample(Modulatedout1); Shapedburst1= Pulseshaping(Upsampleburst1); K=12;fm=100; % CHANNEL 1 Creat_channe_l1=Rician(K,fm,Shapedburst1); Creat_channe_l11=mulchan_pulse(Creat_channe_l1,Shapedburst1); Txsignal1 =awgnoise(Creat_channe_l11, SNR); match1= Matchfilter(Txsignal1); Downburst1= Downsample(match1); Blockphase1=Blockestimate(Downburst1,Modulatedout1); % CHANNEL 2 Creat_channe_l2=Rician(K,fm,Shapedburst1); Creat_channe_l22=mulchandpulse(Creat_channel_2,Shapedburst1); Txsignal2 =awgnoise(Creat_channe_l22, SNR); match2= Matchfilter(Txsignal2);

49

Page 50: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Downburst2= Downsample(match2); Blockphase2=Blockestimate(Downburst2,Modulatedout1); % CHANNEL 3 Creat_channe_l3=Rician(K,fm,Shapedburst1); Creat_channe_l33=mulchanpulse(Creat_channe_l3,Shapedburst1); Txsignal3 =awgnoise(Creat_channe_l33, SNR); match3= Matchfilter(Txsignal3); Downburst3= Downsample(match3); Blockphase3=Blockestimate(Downburst3,Modulatedout1); % CHANNEL 4 Creat_channe_l4=Rician(K,fm,Shapedburst1); Creat_channe_l44=mulchanpulse(Creat_channe_l4,Shapedburst1); Txsignal4 =awgnoise(Creat_channe_l44, SNR); match4= Matchfilter(Txsignal4); Downburst4= Downsample(match4); Blockphase4=Blockestimate(Downburst4,Modulatedout1); rxburst_1=Creat_channel1(1:16:end); rxburst_2=Creat_channel2(1:16:end); rxburst_3=Creat_channel3(1:16:end); rxburst_4=Creat_channel4(1:16:end); mu=zeros(1,4); s=[ 1 j -1 -j ]; for a = 1:length(Blockphase1) rsum(a)= conj(rxburst_1)*Blockphase1(a) + conj(rxburst_2)*Blockphase2(a) + ... conj(rxburst_3)*Blockphase3(a) + conj(rxburst_4)*Blockhpahse4(a); mu(1)=rsum(a)*conj(s(1)); mu(2)=rsum(a)*conj(s(2)); mu(3)=rsum(a)*conj(s(3)); mu(4)=rsum(a)*conj(s(4)); [Y,I]=max(real(mu)); blockphaseout(a)=s(I); end Blockphase=hardslice(blockphaseout);

50

Page 51: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

[number,ratio(burstcount)] = biterr(Blockphase(103:1102),Burst1(103:1102)); end Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.06565 0.04664 0.03124 0.01958 0.011396 0.0061246 0.00302];figure(1);semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER,'bo-');grid on;title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

51

Page 52: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Functions Used in Questions 4(1),4(2) and 4(3)

1. Burstbuilder

function [Burst]=Burstbuilder();

y=randint(1,1000); guard=ones(1,6);

% GENERATION OF UNIQUE WORDuw1=zeros(1,24);

uw2=ones(1,24);

uw=[uw1 uw2 uw1 uw2];

burst=[guard uw payload guard];t=length(burst);[Burst]=burst;

2. QPSK

function [Modulatedout]= QPSK(burst); for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end

[Modulatedout]=burst_tx;

52

Page 53: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

3. Upsample

function Upsampleburst = Upsample(burst_tx);samout=zeros(1,16*length(burst_tx)); samout(1:16:end)=burst_tx; Upsampleburst=samout;

4. Pulseshaping

function Shapedburst= Pulseshaping(samout);

[num,den]=rcosine(1,16,'sqrt',0.3);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 ); Shapedburst=pulseout;

5. Rician

function [channelout]=Rician(K,fm,pulseout); shapedburst=pulseout; fm=0;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

53

Page 54: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

K=12; %K=input('Enter the value K (path loss factor in dB'); cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B);

[channelout] =channel.*shapedburst;

6. mulchanpulse

function Creat_channel=mulchanpulse(Creat_channel,Shapedburst1);Creat_channel=Creat_channel.*Shapedburst1;

7. awgnoise

function Txsignal=awgnoise(channelout, SNR);

wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) ); Txsignal= channelout+wgnoise;

8. Matchfilter

function match=Matchfilter(Txsignal);[num,den]=rcosine(1,16,'sqrt',0.3);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 );match=matchout;

9. Downsample

function [Downburst]=Downsample(matchout);

54

Page 55: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);Downburst=downout;

10. Blockestimate

function Blockphase=Blockestimate(downout,burst_tx) Window_length=50;%The block size wstep=10;% The step in which the sliding window moves. uw_tx=burst_tx(4:51);% Transmitted UW is from 4 to 51 symbols( 48 )uw_rx=downout(4:51);% Received UW is from 4 to 51 symbols( 48 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); Blockphase=downout.*exp(-j*theta_rx); % perform phase compensation

11. hardslice

function [Blockphase]=hardslice(blokphaseout); % Hard slicingn=1;for m=1:2:(2*length(blockphaseout)-1) angl = angle(blockphaseout(n));

55

Page 56: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

Blockphase= burst_rx;

56

Page 57: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

5. [1] Code for Q. 5 Part 1

% GENERATION OF PAYLOAD

clear all;close all;clc;clear memory; for SNR=1:7for burstcount=1:1:100 y= randint(1,500); trellis=poly2trellis(7,[133 171]); % generate trellis structure payload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

% Puncturing process 3/4payload_punc=(payload_trellis);

% GENERATION OF GUARD BITS

guard=ones(1,6);

% GENERATION OF UNIQUE WORD

uw1=zeros(1,20);uw2=ones(1,20);uw=[uw1 uw2 uw1 uw2];burst=[guard uw payload_punc guard];t=length(burst);

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j;

57

Page 58: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end

samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsamplingsamout(1:16:end)=burst_tx; % do upsampling by 16

% Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

% Creation of Rician Channelfm=20;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

%Rician Factor

K=7 % K from (Q1)

58

Page 59: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise %%%%%% output of Channel block % Calculation of Out put of channel channelout =channel.*pulseout; % Creation of Noise % Eb_No=1;wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

%Out put of Channel after addition of noise Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 ); % Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation Window_length=50;%The block size wstep=10;% The step in which the sliding window moves. uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW.

59

Page 60: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blockphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise) % Hard slicingn=1;for m=1:2:(2*length(blockphaseout)-1) angl = angle(blockphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

% Hard Slicing ( Demodulator)trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+40)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(burst_rx,trellis,tblen,'trunc','hard'); % 1500 --> 750

reciever_burst= length(Demod_viterbi)

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(52:551),y(1:500));% x=burst_rx(103:1101);% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;

60

Page 61: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

SNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

5. [2] Code for Q. 5 Part 2

% GENERATION OF PAYLOAD

clear all;close all;clc;clear memory; for SNR=1:7for burstcount=1:1:100 y= randint(1,500); trellis=poly2trellis(7,[133 171]); % generate trellis structure payload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

% Puncturing process 3/4payload_punc=(payload_trellis);

% GENERATION OF GUARD BITS

guard=ones(1,6);

% GENERATION OF UNIQUE WORD

uw1=zeros(1,20);uw2=ones(1,20);uw=[uw1 uw2 uw1 uw2];burst=[guard uw payload_punc guard];t=length(burst);

61

Page 62: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end

samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsamplingsamout(1:16:end)=burst_tx; % do upsampling by 16

% Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

%Rician Channelfm=100;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh

62

Page 63: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

end

%Rician Factor

K=12 % K from (Q2)cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise %%%%%% output of Channel block % Calculation of Out put of channel channelout =channel.*pulseout; % End of the Out put of channel % end

% Creation of Noise % Eb_No=1;wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

%Out put of Channel after addition of noise Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 ); % Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation Window_length=50;%The block size wstep=10;% The step in which the sliding window moves. uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx)));

63

Page 64: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blkphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise) % Hard slicingn=1;for m=1:2:(2*length(blockphaseout)-1) angl = angle(blockphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

% Hard Slicing ( Demodulator)trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+40)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(burst_rx,trellis,tblen,'trunc','hard'); % 1500 --> 750

reciever_burst= length(Demod_viterbi)

64

Page 65: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(52:551),y(1:500));% x=burst_rx(103:1101);% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

5. [3] Code for Q. 5 Part 3

% GENERATION OF PAYLOAD

clear all;close all;clc;clear memory; for SNR=1:7for burstcount=1:1:100 y= randint(1,500); trellis=poly2trellis(7,[133 171]); % generate trellis structure payload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

% Puncturing process 3/4payload_punc=(payload_trellis);

% GENERATION OF GUARD BITS

guard=ones(1,6);

% GENERATION OF UNIQUE WORD

65

Page 66: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

uw1=zeros(1,20);uw2=ones(1,20);uw=[uw1 uw2 uw1 uw2];burst=[guard uw payload_punc guard];t=length(burst);

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end

samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsamplingsamout(1:16:end)=burst_tx; % do upsampling by 16

% Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

% Rician Channelfm=0;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736

66

Page 67: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end

%Rician Factor

K=200 % K from (Q3)cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise %%%%%% output of Channel block % Calculation of Out put of channel channelout =channel.*pulseout; % Creation of Noise % Eb_No=1;wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

%Out put of Channel after addition of noise Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 ); % Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation Window_length=50;%The block size wstep=10;% The step in which the sliding window moves.

67

Page 68: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blkphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise) % Hard slicingn=1;for m=1:2:(2*length(blockphaseout)-1) angl = angle(blockphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end

% Hard Slicing ( Demodulator)trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+40)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(burst_rx,trellis,tblen,'trunc','hard'); % 1500 --> 750

68

Page 69: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

reciever_burst= length(Demod_viterbi)

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(52:551),y(1:500));% x=burst_rx(103:1101);% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

6. [1] Code for Q. 6 Part 1

% GENERATION OF PAYLOADclear all;close all;

69

Page 70: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

clc;clear memory; for SNR=1:7for burstcount=1:1:100 y= randint(1,666); trellis=poly2trellis(7,[133 171]); % generate trellis structure rate=1/2 feed forwardpayload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

payload_punc=(payload_trellis);% check a=[1:24]; b=a; b(payload_punc(3:4:end)=[]; % pick block 6; delete 2; payload_punc=payload_punc(1:end-1);%%%%% interleaving %%%%for i_=1:50 % row 50 x col 20 ; cut vector 20 each; total 50 block payload_inter(i_,:)=payload_punc(20*(i_-1)+1:20*i_);endpayload=payload_inter(:)'; % GENERATION OF GUARD BITSguard=ones(1,6);

% GENERATION OF UNIQUE WORDuw1=zeros(1,20);

uw2=ones(1,20);

uw=[uw1 uw2 uw1 uw2];

burst=[guard uw payload guard];% grid ont=length(burst);

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end% function Upsampleburst = Upsample(burst_tx);

% up sampling samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsampling

70

Page 71: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

samout(1:16:end)=burst_tx; % do upsampling by 16

% function Shapedburst= Pulseshaping(samout); %Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

% function Creat_channel=Rician(K,fm,pulseout); % Rician Channelfm=20;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end%Rician Factor K=7; %K=input('Enter the value K (path loss factor in dB'); % K from (Q1)cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise

%Calculation of Output of channel channelout =channel.*pulseout;

% Eb_No=1;

71

Page 72: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 );

%Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation % Window_length=50;%The block size wstep=10;% The step in which the sliding window moves. uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blkphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise)

72

Page 73: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% Hard slicingn=1;for m=1:2:(2*length(blkphaseout)-1) angl = angle(blkphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end% burstDemod=Demod; % Hard Slicing %%% De-interleaving %%%%%%for j_=1:20 % take 50 rows each; put 20 column vectors Demod_inter_(:,j_)=burst_rx(50*(j_-1)+1:50*j_); % | --> |||endDemod_inter_1=Demod_inter_'; % ||| --> =Demod_inter=Demod_inter_1(:)'; % | --> - % De-puncturing Demod_punc=ones(1,1332); Demod_punc(1:4:end)=Demod_inter(1:3:end); Demod_punc(2:4:end)=Demod_inter(2:3:end); Demod_punc(4:4:end)=Demod_inter(3:3:end); Demod_pun=[Demod_punc 0];%%%% Viterbi decoder %%%%%%%%%trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+48)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(Demod_pun,trellis,tblen,'trunc','hard'); % 1500 --> 750

reciever_burst= length(Demod_viterbi)

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(1:667),y(1:667));% x=burst_rx(103:1101);

73

Page 74: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.09 0.0699 0.0527 0.0387 0.0277 0.0193 0.0135];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',... 'Theoretical BER','Location','SouthWest');hold off;

6. [2] Code for Q. 6 Part 2

% GENERATION OF PAYLOADclear all;close all;clc;clear memory; for SNR=1:7for burstcount=1:1:100 y= randint(1,666); trellis=poly2trellis(7,[133 171]); % generate trellis structure rate=1/2 feed forwardpayload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

payload_punc=(payload_trellis);% check a=[1:24]; b=a; b(payload_punc(3:4:end)=[]; % pick block 6; delete 2; payload_punc=payload_punc(1:end-1);%%%%% interleaving %%%%for i_=1:50 % row 50 x col 20 ; cut vector 20 each; total 50 block payload_inter(i_,:)=payload_punc(20*(i_-1)+1:20*i_);endpayload=payload_inter(:)'; % GENERATION OF GUARD BITSguard=ones(1,6);

% GENERATION OF UNIQUE WORDuw1=zeros(1,20);

uw2=ones(1,20);

74

Page 75: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

uw=[uw1 uw2 uw1 uw2];

burst=[guard uw payload guard];% grid ont=length(burst);

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end% function Upsampleburst = Upsample(burst_tx);

% up sampling samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsamplingsamout(1:16:end)=burst_tx; % do upsampling by 16

% function Shapedburst= Pulseshaping(samout); %Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

% function Creat_channel=Rician(K,fm,pulseout); % Rician Channelfm=100;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));

75

Page 76: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end%Rician Factor K=12; %K=input('Enter the value K (path loss factor in dB'); % K from (Q2)cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise

%Calculation of Output of channel channelout =channel.*pulseout;

% Eb_No=1;wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 );

%Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation % Window_length=50;%The block size wstep=10;% The step in which the sliding window moves.

76

Page 77: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blkphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise)

% Hard slicingn=1;for m=1:2:(2*length(blkphaseout)-1) angl = angle(blkphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end% burstDemod=Demod; % Hard Slicing %%% De-interleaving %%%%%%for j_=1:20 % take 50 rows each; put 20 column vectors Demod_inter_(:,j_)=burst_rx(50*(j_-1)+1:50*j_); % | --> |||endDemod_inter_1=Demod_inter_'; % ||| --> =Demod_inter=Demod_inter_1(:)'; % | --> -

77

Page 78: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% De-puncturing Demod_punc=ones(1,1332); Demod_punc(1:4:end)=Demod_inter(1:3:end); Demod_punc(2:4:end)=Demod_inter(2:3:end); Demod_punc(4:4:end)=Demod_inter(3:3:end); Demod_pun=[Demod_punc 0];%%%% Viterbi decoder %%%%%%%%%trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+48)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(Demod_pun,trellis,tblen,'trunc','hard'); % 1500 --> 750

reciever_burst= length(Demod_viterbi)

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(1:667),y(1:667));% x=burst_rx(103:1101);% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[0.06565 0.04664 0.03124 0.01958 0.011396 0.0061246 0.00302];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',..'Theoretical BER','Location','SouthWest');hold off;

6. [3] Code for Q. 6 Part 3

% GENERATION OF PAYLOADclear all;close all;clc;clear memory;

78

Page 79: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

for SNR=1:7for burstcount=1:1:100 y= randint(1,666); trellis=poly2trellis(7,[133 171]); % generate trellis structure rate=1/2 feed forwardpayload_trellis=convenc(y,trellis); % encode payload (half) with trellis code

payload_punc=(payload_trellis);% check a=[1:24]; b=a; b(payload_punc(3:4:end)=[]; % pick block 6; delete 2; payload_punc=payload_punc(1:end-1);%%%%% interleaving %%%%for i_=1:50 % row 50 x col 20 ; cut vector 20 each; total 50 block payload_inter(i_,:)=payload_punc(20*(i_-1)+1:20*i_);endpayload=payload_inter(:)'; % GENERATION OF GUARD BITSguard=ones(1,6);

% GENERATION OF UNIQUE WORDuw1=zeros(1,20);

uw2=ones(1,20);

uw=[uw1 uw2 uw1 uw2];

burst=[guard uw payload guard];% grid ont=length(burst);

% QPSK MODULATION for(t=1:2:length(burst)) if((burst(t)==0) && (burst(t+1)==0)) burst_tx((t+1)/2)=1; elseif(burst(t)==0&&burst(t+1)==1) burst_tx((t+1)/2)=j; elseif(burst(t)==1 && burst(t+1)==0) burst_tx((t+1)/2)=-j; elseif(burst(t)==1 && burst(t+1)==1) burst_tx((t+1)/2)=-1; end end% function Upsampleburst = Upsample(burst_tx);

% up sampling samout=zeros(1,16*length(burst_tx)); % prepare zero vector for upsamplingsamout(1:16:end)=burst_tx; % do upsampling by 16

79

Page 80: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% function Shapedburst= Pulseshaping(samout); %Pulse Shaping filter [num,den]=rcosine(1,16,'sqrt',0.35);pulseout=conv(samout,num); pulseout=pulseout( (length(num)+1)/2:end-(length(num)-1)/2 );

% function Creat_channel=Rician(K,fm,pulseout); % Rician Channelfm=0;N=66; wm=2*pi*fm; M=(1/2*(N/2 -1));n=1:1:M; % row vectorwn=wm*cos(2*pi*n/N); % row vectorbeta=pi*n/M; % row vectoralpha=0; T_sample=0.5*10^(-3)/(554*16);

for t=1:8736Git_1=2*(cos(beta).*cos(wn*T_sample*t)); Git(t)= sum( Git_1) + sqrt(2)*cos(wm*T_sample*t)*cos(alpha); Git(t)= sqrt(2)*(Git(t));end

for t=1:8736Gqt_1=2*( sin(beta).*cos(wn*T_sample*t)); Gqt(t)= sum( Gqt_1) + sqrt(2)*cos(wm*T_sample*t)*sin(alpha);Gqt(t)=sqrt(2)*(Gqt(t));end

for t=1:8736 Git_Norm(t)=Git(t)/sqrt(2*(M+1)); Gqt_Norm(t)=Gqt(t)/sqrt(2*M); Gt(t)=Git_Norm(t)+j*Gqt_Norm(t); % This is raleigh end%Rician Factor K=200; %K=input('Enter the value K (path loss factor in dB'); % K from (Q3)cons=10^(-K/20); % scatter path % K_ in non-dBB=1/sqrt(1 + 10^(-K/10)); % normalization factorchannel=((1 + cons*Gt).*B); % before adding noise

%Calculation of Output of channel channelout =channel.*pulseout;

% Eb_No=1;wgnoise=10^(-SNR/10)*(randn(size(channelout))+j*randn(size(channelout)) );

80

Page 81: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

Txsignal= channelout+wgnoise;

% Match filter [num,den]=rcosine(1,16,'sqrt',0.35);matchout=conv(Txsignal,num); matchout=matchout( (length(num)+1)/2:end-(length(num)-1)/2 );

%Down sampling downout=zeros(1,length(matchout)/16); downout=matchout(1:16:end);

% Block phase estimation % Window_length=50;%The block size wstep=10;% The step in which the sliding window moves. uw_tx=burst_tx(4:43);% Transmitted UW is from 4 to 43 symbols( 40 )uw_rx=downout(4:43);% Received UW is from 4 to 43 symbols( 40 ) theta_ref=1/40*sum(angle(uw_rx.*conj(uw_tx))); k=1; %set up the counter consider the intial theta value from the theta_UWt_=[];while((Window_length + wstep*(k-1))<=length(downout)) s=sum(downout((1+wstep*(k-1)):(Window_length+wstep*(k-1))).^4); theta_sig=1/4*atan2(imag(s),real(s)) + [0 pi/4 -pi/4 pi/2 -pi/2 3*pi/4 -3*pi/4 pi]; % 8 possible angles a=abs(theta_ref-theta_sig); theta_min(k)=theta_sig( a==min(a) ); %Remove the ambiguity in angle calculation by comparing with the UW. t_=[t_ 0.5*(Window_length+wstep*2*(k-1))]; theta_ref=theta_min(k); k=k+1;end theta_rx=interp1(t_,theta_min,[1:length(downout)],'linear'); % Perform Linear Interpolation to get the entire range of anglestheta_rx(1:29)=theta_min(1);theta_rx((t_(end)+1:end))=theta_min(end); blkphaseout=downout.*exp(-j*theta_rx); % perform phase compensation (rotate counter-clock wise)

81

Page 82: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% Hard slicingn=1;for m=1:2:(2*length(blkphaseout)-1) angl = angle(blkphaseout(n)); if ((angl> -pi/4) & (angl<=0)) | ((angl>=0) & (angl<=pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 0; elseif ((angl< 3*pi/4) & (angl>= pi/4)) burst_rx(m) = 0; burst_rx(m+1) = 1; elseif ((angl>= 3*pi/4) & (angl<= pi)) | ((angl<= -3*pi/4) & (angl>= -pi)) burst_rx(m) = 1; burst_rx(m+1) = 1; elseif ((angl<= -pi/4) & (angl> -3*pi/4 )) burst_rx(m) = 1; burst_rx(m+1) = 0; end n = n+1;end% burstDemod=Demod; % Hard Slicing %%% De-interleaving %%%%%%for j_=1:20 % take 50 rows each; put 20 column vectors Demod_inter_(:,j_)=burst_rx(50*(j_-1)+1:50*j_); % | --> |||endDemod_inter_1=Demod_inter_'; % ||| --> =Demod_inter=Demod_inter_1(:)'; % | --> - % De-puncturing Demod_punc=ones(1,1332); Demod_punc(1:4:end)=Demod_inter(1:3:end); Demod_punc(2:4:end)=Demod_inter(2:3:end); Demod_punc(4:4:end)=Demod_inter(3:3:end); Demod_pun=[Demod_punc 0];%%%% Viterbi decoder %%%%%%%%%trellis=poly2trellis(7,[133 171]); % generate trellis structure at the receivertblen=3;% Demod_viterbi=vitdec(burstDemod(2*(3+48)+1:end-6),trellis,tblen,'trunc','hard'); % viterbi decoder on PayloadDemod_viterbi=vitdec(Demod_pun,trellis,tblen,'trunc','hard'); % 1500 --> 750

reciever_burst= length(Demod_viterbi)

% BER CALCULATION

[number,ratio(burstcount)] = biterr(Demod_viterbi(1:667),y(1:667));% x=burst_rx(103:1101);

82

Page 83: System-Level Design for a Mobile - EEWeb Communitys.eeweb.com/members/joe_wolin/projects/2011/05/23/Wi... · Web viewRician Channel with viterbi Encoder and Decoder 12 6. Rician Channel

% [number,ratio] = biterr(abs(x),abs(y)); end;% SNR=1:7;Ratio(SNR)=sum(ratio)/burstcount;disp(Ratio(SNR));end;SNR=1:7;TheBER=[TheBER(SNR) TheBER(SNR) TheBER(SNR) TheBER(SNR) TheBER(SNR) TheBER(SNR)];figure;semilogy(SNR,Ratio(SNR),'r*-');hold on;semilogy(SNR,TheBER(SNR),'bo-');grid on;xlabel('Eb/No in dB');ylabel('BER');title(' Practical BER Compared with Theoretical ');legend('Practical BER',..'Theoretical BER','Location','SouthWest');hold off;

83