exercise.1 8 pam – ber/ser monte carlo simulationsignals – matlab exercise 0 y1 y2 signal...

29
Exercise.1 8 PAM – BER/SER Monte Carlo Simulation - Simulate a 8 level PAM communication system and calculate bit and symbol error ratios (BER/SER). - Plot the calculated and simulated SER and BER curves. - Plot the theoretical SER and BER curves. - Calculate the average energy. - Plot the constellation and histogram of samples.

Upload: others

Post on 09-Feb-2020

8 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise.1 8 PAM – BER/SER Monte Carlo Simulation

- Simulate a 8 level PAM communication system and calculate bit and symbol error ratios (BER/SER).- Plot the calculated and simulated SER and BER curves. - Plot the theoretical SER and BER curves. - Calculate the average energy.- Plot the constellation and histogram of samples.

Page 2: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Uniform random number generator

Gray-encodesymbols

Detector+

GaussianNoise

Compare symbols(I = I_hat) ?

Compare bits

Symbol Error Ratio

Bit Error Ratio

X Y

S_hat

Block Diagram

Exercise.1 8 PAM – BER/SER Monte Carlo Simulation

S

Modulator

I

Gray-decoderI_hat

Page 3: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Gray encoding

0 1 3 2 6 7 5 4

000 001 011 010 110 111 101 100

8 PAM System – Signal constellation

-7d -5d -3d -1d 0 1d 3d 5d 7d

Symbols

Bits in symbol

Amplitude

d : scaling

Gray encoding: Slide 65 (Lecture_3_2007_HypothesisTesting_SignalSpace.pdf)

Page 4: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Average transmitted signal energy

∑ ∫=

=

M

k

T

kav dtttsM

E1

2

0

)()(1 φ

S0(t) S1(t) S2(t) S3(t)

S4(t) S5(t) S6(t) S7(t)

T

E7− T

E5− T

E3−T

E−

T

ET

E3 T

E5T

E7

8 PAM System – Derivation of standard deviation

T

T

t

t

( ) 222228

1

2

0

2121135728

1)()(

8

1dEEdtttsE

k

T

kav ==+++=

= ∑ ∫

=

φ

T

1

)(functionBasis tφ

Tt

T T T

Page 5: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

3log2_

avavbitav

E

M

EE ==

2

2

2

2

00

_

2

7

23

21

3 σσdd

N

E

N

ESNR avbitav

bit =⋅

===

bitSNR

d

2

7 2

Average bit SNR

Transmitted average energy per bit

Standard deviation used in the simulation

8 PAM System – Derivation of standard deviation

EbNoNo

bE

N

bE

N

bitavE

bitSNR ====

00

_

Note that some books use different notation

Page 6: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

8 PAM System – Theoretical symbol error probability

SEP = (2*(M-1)/M)*qfunc(sqrt((6*log2(M)/(M^2-1))*SNR_bit_abs));

M = 8

SEP: Slide 63 (Lecture_3_2007_HypothesisTesting_SignalSpace.pdf)

0 2 4 6 8 10 12 14 1610

-4

10-3

10-2

10-1

100

Symbol error probabilities. 8 PAM

Eb/No

Sym

bol E

rror

Pro

babi

lity

theoretical

simulation

[db]

Page 7: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

BEP = (1/log2M) SEPapproximation for low BEP :

8 PAM System – Theoretical bit error probability

BEP: Slide 68 (Lecture_3_2007_HypothesisTesting_SignalSpace.pdf)

0 2 4 6 8 10 12 14 1610

-4

10-3

10-2

10-1

100

Bit error probabilities. 8 PAM

Eb/No

Bit

Err

or P

roba

bilit

ytheoretical

simulation

[db]

Page 8: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Histogram of symbols

-4 -2 0 2 4 6 8 10 12 140

200

400

600

800

1000

1200

1400

-Download the file from the course web page and open with an editor

STEP 1 : transform SNR [dB] to SNR [abs]

STEP 2: complete standard deviation for 8 PAM

STEP 3: generate N integer random numbers in the interval [0,7]and verify the distribution with a histogram

8 PAM System – Matlab exercise

Page 9: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

STEP 4 : Add noise to symbols, use randn()

STEP 5: Calculate the symbol error ratio

STEP 6: Calculate the bit error ratio

STEP 7: Repeat the simulation for different SNR

STEP 8: Plot using the code in the file. Observe:- symbol error probabilities and compare to theoretical results- bit error probabilities and compare to theoretical results- constellation- histogram of the samples

STEP 9: Observe the average energy

STEP 10:Optional. Modulate using pammod() from the Communications Toolbox

8 PAM System – Matlab

Page 10: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 2 BPSK / QPSK – BER/SER Simulation

-Simulate a communication system using BPSK/QPSK modulation and calculate bit and symbol error ratios.

- Set BPSK modulation.- Plot the calculated and simulated SER and BER curves. - Plot the theoretical SER and BER curves. - Change modulation to QPSK- Plot the calculated and simulated SER and BER curves. - Plot the theoretical SER and BER curves. - Introduce a rotation in the channel and equalize the channel.

Page 11: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 2 BPSK / QPSK – BER/SER Simulation

Uniform random number generator

Gray-encodesymbols

Detector+

GaussianNoise

Compare symbols(I = I_hat) ?

Compare bits

Symbol Error Probability

Bit Error Probability

X YS_hatS

Modulator

I

Gray-decoderI_hat

Block Diagram

Page 12: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

savbitav EE __ =

220

_

0

_

22 σσEE

N

E

N

E

No

EbSNR savbitav

bit =====

Transmitted average energy per bit

SNR bit

bitSNR

E

2=→ σ

Symbol Error Probability = Bit Error Probability in BPSK (1bit=1symbol)

( )bitb SNRQP 2=

Theoretical Bit Error Probability for BPSK

BPSK

( )bits SNRQP 2=

Page 13: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

2log_

2

__

savsavbitav

E

M

EE ==

220

_

0

_

4222 σσEE

N

E

N

E

No

EbSNR savbitav

bit =⋅

====

Transmitted average energy per bit

SNR bit

bitSNR

E

4=→ σ

Approximation of Theoretical Symbol Error Probability for M >= 4

⋅⋅=M

SNRQP bits

πsin22

( )bitb SNRQP 2=

Theoretical Bit Error Probability for BPSK = QPSK

QPSK

4=M

Page 14: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

-Download the file from the course web page and open with an editor

STEP 1 : Set modulation to BPSK

STEP 2: Gray-encode symbols, use bin2gray()

STEP 3: Demodulate PSK by using pskdemod()

STEP 4: Plot using the code in the file. Observe:- symbol error probabilities and compare to theoretical results- bit error probabilities and compare to theoretical results

STEP 5: Change modulation to QPSK

STEP 6: Introduce a rotation in the channel

STEP 7: Equalize the channel

BPSK/QPSK – Matlab exercise

Page 15: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

STEP 8 : Plot using the code in the file. Observe:- The symbols rotated- The symbols rotated + noise- The symbols after the equalizer

BPSK/QPSK – Matlab exercise

Page 16: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

0 1 2 3 4 5 6 7 8 9 1010

-6

10-5

10-4

10-3

10-2

10-1

100

Symbol/Bit error probabilities. BPSK

Eb/No

Bit

Err

or P

roba

bilit

y

SER theoretical

SER simulationBER theoretical

BER simulation

-1.5 -1 -0.5 0 0.5 1 1.5-1.5

-1

-0.5

0

0.5

1

1.5Rotated Signal Constellation with Noise

real

imag

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2-2

-1.5

-1

-0.5

0

0.5

1

1.5Signal Constellation after Equalization

real

imag

0 1 2 3 4 5 6 7 8 9 1010

-6

10-5

10-4

10-3

10-2

10-1

100

Eb/No

Bit

Err

or P

roba

bilit

y

Symbol/Bit error probabilities. QPSK

SER theoretical

SER simulationBER theoretical

BER simulation

BPSK QPSK

QPSK QPSK

[db][db]

Page 17: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 3 System using Biorthogonal Signals

-Simulate a communication system using biorthogonal waveforms and calculate bit and symbol error ratios.

-Plot the calculated and simulated SER and BER curves. -Modify the simulator to use orthogonal waveforms.-Plot the calculated and simulated SER and BER curves.

Page 18: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 3 System using Biorthogonal Signals

T/2

S0(t)

T

E2

T

E2−

t T/2

S1(t)

T

E2

T

E2−

T t

T/2

S2(t)

T

E2

T

E2−

t

T/2

S3(t)

T

E2

T

E2−

T

t

101

000

311

210

S0(t)

S1(t)

S2(t)

S3(t)

[ 1 0]

[ 0 1]

[-1 0]

[ 0 -1]

0

1

3

2

Symbols

Signal constellation

Page 19: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

System using Biorthogonal Signals

220

_

0

_

4222 σσEE

N

E

N

E

No

EbSNR savbitav

bit =⋅

====

� Transmitted average energy per bit

� Average transmitted signal energy

EE sav =_

� SNR bit

NoEb

E

/4=→ σ

2log_

2

__

savsavbitav

E

M

EE ==

Page 20: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Y10

1

3

2

Y2

System using Biorthogonal Signals - Detector

Possible approach to make decisions

if (y1 > abs(y2), S = 0;elseif (y2 > abs(y1), S = 1;elseif (y1 <-abs(y2), S = 3;else S = 2;

y1

y2 Received symbol

Decision Areas

Signal constellation

Page 21: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Biorthogonal Signals – Matlab exercise

SER / BER

0 1 2 3 4 5 6 7 8 9 1010

-5

10-4

10-3

10-2

10-1

100

Eb/No

Sym

bol/B

it E

rror

Pro

babi

lity

Symbol and bit error probabilities. Biorthogonal waveforms M = 4

SER

BER

Task : Download the file from the course web page and open with an editorThis code simulates biorthogonal signals and is ready to run.Compare the Symbol and Bit error probabilities obtained here to the results obtained in the QPSK exercise.

[db]

Page 22: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

.Orthogonal Signals – Matlab exercise

Y10

Y2

Signal constellation

Task : The code provided simulates biorthogonal signals.Modify the code to simulate the orthogonal signals shown below (M = 2).

[ 1 0]

[ 0 1]T/2

S0(t)

T

E2

T

E2−

t T/2

S1(t)

T

E2

T

E2−

T t

S0(t)

S1(t)

STEP 1: Set M = 2

STEP 2: Change standard deviation

STEP 3: Set modulation

STEP 4: Set the decision areas

Page 23: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

STEP 5: Observe symbol and bit error rates

STEP 6: Plot theoretical bit error probabilities,for orthogonal and biorthogonal cases.Observe 3dB difference.

0 2 4 6 8 10 1210

-8

10-7

10-6

10-5

10-4

10-3

10-2

10-1

100

Symbol and bit error probabilities.

Eb/No

Sym

bol/B

it E

rror

Pro

babi

lity

SER

BERBER Theoretical Orthogonal

BER Theoretical Biorthogonal

.Orthogonal Signals – Matlab exercise

[db]

Page 24: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Consider a four-phase PSK represented by the following equivalent low pass signal:

Exercise 4 Power Spectrum Density

( ) ( )n

n

u t I g t nT= −∑

where nI takes one of the four possible values: ( )1 12 j± ± with equal probability.

a. Determine and sketch the power spectrum density of( )u t when:

( ) 0

0

A t Tg t

otherwise

≤ ≤=

b. Repeat a. when

( ) sin 0

0

tA t T

g t T

otherwise

π ≤ ≤ =

c. Compare the spectra obtained in a. and b. in terms of the 3dB bandwidthand the bandwidth to the first spectral zero.

Page 25: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

( ) ( )sinj fT

ftG f AT e

ftπ

π

π−=

Exercise 4

In PAM the coefficients are real but in PSK this is not the case since the signal space isnI

not uni-dimensional.

( ) 0

0

A t Tg t

otherwise

≤ ≤=

FT

( ) ( )( ) ( ) ( )

( )2 22

2 2 22 2

sin sinuu

ft ftG f A T f A T

ft ft

π π

π π= ⇒Φ =

The power spectrum density is calculated as:

First Zeroat 1/T

-5 -4 -3 -2 -1 0 1 2 3 4 510

-6

10-5

10-4

10-3

10-2

10-1

100

Spectrum for Rectangular pulse

Normalized frequency fTb

Nor

mal

ized

Pow

er s

pect

rum

den

sity

a).

fT

fTATfG

ππ )sin(

)( =

2)(

1)( fG

Tfuu =Φ

Page 26: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 4

( ) sin 0

0

tA t T

g t T

otherwise

π ≤ ≤ =

FT ( ) ( )2 2

cos2

1 4j Tf

TfATG f e

T fπ

π

π−= ⋅

b).

The power spectrum density is calculated:

( ) ( ) ( )( )

2 22

22 2

cos1 2

1 4uu

TfAf G f T

T TT f

π Φ = =

First Zero at 1.5/T

-5 -4 -3 -2 -1 0 1 2 3 4 510

-5

10-4

10-3

10-2

10-1

100

Spectrum for Sinusoid pulse

Normalized frequency fTb

Nor

mal

ized

Pow

er s

pect

rum

den

sity

Page 27: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 4

c).

The power spectrum for the rectangular pulse has narrower mainlobe but higher sidelobes

-5 -4 -3 -2 -1 0 1 2 3 4 5

10-4

10-3

10-2

10-1

100

Spectrum for Rectangular and sinusoid pulse

Normalized frequency fTb

Nor

mal

ized

Pow

er s

pect

rum

den

sity

RectangularSinusoid The sinusoid pulse demands 50% more bandwidth

compared to the rectangular pulse

( )( )

( )( )

23

32

3

2

322 2

sin 1 0.44rectangular:

2

cos 1 0.59sinusoid :

21 4

db

dB

db

dB

f Tf

Tf T

T ff

TT f

π

π

π

= ⇒ =

= ⇒ =−

Page 28: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 4

• To determine the power spectrum density we used the Fourier transform of a proposed signal.• But the Fourier transform is available only for deterministic signals.• With random message signals we can not find the Fourier transform.• Nevertheless we can determine the autocorrelation function of these signals from their statistical information.• Then we find the power spectrum density from the Fourier transform of the autocorrelation function:

{ })()( τψℑ=Φ fuu

Where ψ(τ) is the autocorrelation function

dttutu )()()( *∫∞

∞−

+= ττψ

In Matlab we use xcorr(x) (crosscorrelation of vector x with itself)

Page 29: Exercise.1 8 PAM – BER/SER Monte Carlo SimulationSignals – Matlab exercise 0 Y1 Y2 Signal constellation Task : The code provided simulates biorthogonal signals. Modify the code

Exercise 4

TASK : Simulate a communication system for the given problem usingMatlab and determine the Power Spectrum Density when g(t)

is a rectangular and sinusoidal pulse.