Digital comm. systems Project: Simplified digital have...

8
Project: Simplified digital communica5on systems Watcharapan Suwansan5suk EIE/ENE 324 King Mongkut’s University of Technology Thonburi Digital comm. systems have these major components Sampler message (input waveform) Quan5zer Source encoder Channel encoder Modulator Interpolator Table lookup Source decoder Channel decoder message (output waveform) Channel transmiRer receiver Demodulator 2 A focus of this project The project covers the simplest case: the case of no channel encoding is a guess of 3 Channel encoder Modulator Channel decoder Gaussian Channel transmiRer receiver Demodulator X 1 ,X 2 ,X 3 ,... ˆ X 1 , ˆ X 2 , ˆ X 3 ,... X i 2 {-1, 1} where independent and iden5cally distributed (iid) ˆ X i X i This block can be simplified (see next slide) By using orthornormal signals to modulate, we can simplify the diagram Random variables appear at the input/output of each block Given independence, the decoder decoders each separately 4 Channel encoder Channel decoder transmiRer receiver X 1 ,X 2 ,X 3 ,... ˆ X 1 , ˆ X 2 , ˆ X 3 ,... X i 2 {-1, 1} where iid + X 1 ,X 2 ,X 3 ,... iid Gaussian N (0, σ 2 ) Z 1 ,Z 2 ,Z 3 ,... Y 1 ,Y 2 ,Y 3 ,... Y i = X i + Z i where (given) (given) (consequence: Y i ’s are iid) Y i

Transcript of Digital comm. systems Project: Simplified digital have...

Page 1: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

Project:Simplifieddigitalcommunica5onsystems

WatcharapanSuwansan5suk

EIE/ENE324KingMongkut’sUniversityofTechnologyThonburi

Digitalcomm.systemshavethesemajorcomponents

Sampler

message(inputwaveform)

Quan5zer Sourceencoder

Channelencoder Modulator

Interpolator Tablelookup

Sourcedecoder

Channeldecoder

message(outputwaveform)

Channel

transmiRer

receiver

Demodulator

2

Afocusofthisproject

Theprojectcoversthesimplestcase:thecaseofnochannelencoding

•  isaguessof

3

Channelencoder Modulator

Channeldecoder

GaussianChannel

transmiRer

receiver

Demodulator

X1, X2, X3, . . .

X̂1, X̂2, X̂3, . . .

Xi 2 {�1, 1}where

independentandiden5callydistributed(iid)

X̂i Xi

Thisblockcanbesimplified(seenextslide)

Byusingorthornormalsignalstomodulate,wecansimplifythediagram

•  Randomvariablesappearattheinput/outputofeachblock•  Givenindependence,thedecoderdecoderseachseparately

4

Channelencoder

Channeldecoder

transmiRer

receiver

X1, X2, X3, . . .

X̂1, X̂2, X̂3, . . .

Xi 2 {�1, 1}whereiid

+

X1, X2, X3, . . .

iidGaussianN (0,�2)

Z1, Z2, Z3, . . .

Y1, Y2, Y3, . . .

Yi = Xi + Ziwhere

(given)

(given)

(consequence:Yi’sareiid)

Yi

Page 2: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

Youwillsimulatethesimplestformofadigitalcommunica5onsystem

noise

+

transmiRedbit receivedsymbol

X 2 {�1, 1}

XY

Z

Discreterandomvariable(rv)(Bernoullirvwith)

Con5nuousrv,independentofX(Gaussianornormaldistribu5on)Mean=0,variance=

Y = X + Z

�2

Con5nuousrv

Decoder

receivedbitX̂

Discreterv

X̂ 2 {�1, 1}P {X = 1} = p

5

A^erthisproject,youwillbeableto•  Understand the simplest structure of the digitalcommunica5onsystem

•  Generate realiza5ons (random samples) of discrete andcon5nuousrandomvariablesusingMatlab

•  Compare thehistogramof the realiza5ons to theprobabilitydistribu5onoftherandomvariable

•  Designadecisionruleatareceiver•  Simulatethebiterrorrateasafunc5onofthesignal-to-noisera5o

6

Thisexampleshowsrealiza5onsofrvs

•  Supposethedecisionrule(thedecoder)isalwaysoutput

noise

+

transmiRedbit receivedsymbol

Y = X + ZDecoder

decodedbit

X = 1

Z = �0.1

= 0.9

X̂ = 1

X̂ = 1

7

Thisprojectconsistsof4parts

noise

+

transmiRedbit receivedsymbol

XY

Z

Decoder

decodedbitX̂

Part1:TransmiRer

Part2:Channel

Part3:Receivedsymbol Part4:Decodedbit

8

Page 3: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

YouwillmodifysixMatlabfilesthatareprovidedtoyouinthecoursewebsite

•  Someofthefilesareusedinmul5plepaths

getBernoulli.m commsys_1_transmit.m

commsys_2_channel.mgetNormal.m

commsys_3_rec_symb.m

commsys_4_detect.m

isusedinPart1

Part2

Part3

Part4

9

PART1:THETRANSMITTER

10

Youwillgeneraterealiza5ons(observedvalues)ofa{-1,+1}-Bernoullirv

•  ThepmfofXis

•  Arealiza5on(observedvalue)ofXhasthevalueofeither+1or-1

•  Inalongrunifyougenerateonerealiza5ona^eranother,thepropor5onof+1thatyouobserveisp

P {X = +1} = p

P {X = �1} = 1� p

11

Usethesevaluesofpinyourexperiment

Group p

5 0.55

6 0.60

7 0.65

8 0.70

12

•  Thevalueofpwillbeassignedtoyouinclass

Group p

1 0.30

2 0.35

3 0.40

4 0.45

Page 4: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

Yourtaskisthefollowing1.  FillinthecodeoffilegetBernoulli.m2.  Fill in the code of func5on getRela5veFreq of file

commsys_1_transmit.m3.  Modify the value of p in the first line of func5on

plotBernoulliHistoffilecommsys_1_transmit.m4.  Runcommsys_1_transmit.m,andmakesurethehistogram

and the pmf matches (otherwise your code in 1-3 arewrong)

5.  S u b m i t M a t l a b c o d e g e t B e r n o u l l i . m a n dcommsys_1_transmit.m(so^copy/email)

6.  Submitthehistogram(so^copy/email)

13

Matlabexample:generaterealiza5onsfromauniformdiscreterv

•  Suppose randomvariableW is equally likely to take a valuefromtheset{1,2,3,...,10}

•  Thatis,thepmfofWis

•  Matlabfunc5onunidrnd(10)givesyourealiza5onsofW>>unidrnd(10,1,3)%1-by-3matrixans=9102

P {W = k} =

(110 , k = 1, 2, . . . , 10

0, otherwise

14

TheseareMatlabfunc5onsthatgeneraterealiza5onofcommondiscretervs

Distribu<on Matlabfunc<on

Binomial binornd

Geometric geornd

Poisson poissrnd

Uniform unidrnd

15

Rela5vefrequencyisapropor5onthatasymboloccursinagivensequence

•  Supposethe5realiza5onsofXare+1,-1,-1,+1,-1

•  Therela5vefrequencyof+1is

•  Therela5vefrequencyof-1is

16

# of times that 1 occurs

5

=

2

5

# of times that �1 occurs

5

=

3

5

Page 5: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

PART2:THECHANNEL

17

Youwillgeneraterealiza5onsofazero-meanGaussian(normal)rv

•  GaussianrvZhasameanofzeroandthevarianceof•  ThepdfofZis

•  Arealiza5onofZisarealnumber•  Inalongrunifyougenerateonerealiza5ona^eranother,thehistogramoftheserealiza5onslookslikethepdfofY

�2

fZ(z) =1p2⇡�2

e�z2/2, �1 < z < 1

18

Yourtaskisthefollowing1.  Fill in the code of func5on getNormalPDF in the file

commsys_2_channel.m2.  Fillinthecodeoftheonlyfunc5oninfilegetNormal.m3.  Changethevalueofsiginline11ofcommsys_2_channel.m

tobeanyvalueofyourchoice(sig= =standarddevia5onofnoiseZ)

4.  Run commsys_2_channel.m, and make sure that thehistogramand thepdfmatch (otherwise, your code in1-3arewrong)

5.  S u bm i t M a t l a b c o d e g e t N o rm a l P D F .m a n dcommsys_2_channel.m(hardcopy)

6.  Submitthehistogram(hardcopy)

19

Matlabexample:generaterealiza5onsfromauniformcon5nuousrv

•  SupposerandomvariableUisuniformontheinterval(0,1)•  Thatis,thepdfofUis

•  Matlabfunc5onrandgivesyourealiza5onsofU>>rand(1,5)%1-by-5matrixans=0.39220.65550.17120.70600.0318

fU (u) =

(1, 0 < u < 1

0, otherwise

20

Page 6: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

TheseareMatlabfunc5onsthatgeneraterealiza5onofcommoncon5nuousrvs

Distribu<on Matlabfunc<on

Exponen5al exprnd

NormalorGaussian normrnd

Uniform rand

21

PART3:THERECEIVER(RECEIVEDSYMBOL)

22

YouwillderivethepdfofY•  Therela5onshipiswhereisa{-1,1}-Bernoullirvandisanormalrv,independentof

•  Arealiza5onofYisgeneratedforyouinthetemplate,callingyourfunc5onsgetBernoulli.mandgetNormal.m

•  Realiza5onofY=realiza5onofX+realiza5onofZ

Y = X + Z

X Z N (0,�2)

X

23

Yourtaskisthefollowing1.  Fillinthevalueofsiginline10ofcommsys_3_rec_symb.m,

usingthesamevalueofsiginpart22.  DerivethepdfofYasa func5onofsig.Usethevalueofp

thatwasassignedtoyourgroupforthederiva5on3.  Fillinfunc5ongetPdfYoffilecommsys_3_rec_symb.m4.  Runcommsys_3_rec_symb.m,andmakesurethehistogram

andthepdfmatches(otherwise,yoursteps1-3arewrong)5.  Submitthederiva5onofthepdfinstep2(hardcopy)6.  Submit theMatlab code commsys_3_rec_symb.m and the

histogram(hardcopy)

24

Page 7: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

Hereisaderiva5onforthecase.

•  ThecdfofYis

p = 1/2

P {Y y} = P {Y y and X = 1}+ P {Y y and X = �1}

= P {Y y | X = 1}P {X = 1}+ P {Y y | X = �1}P {X = �1}

=1/2 =1/2Y=X+Z

=1

2P {X + Z y | X = 1}+ 1

2P {X + Z y | X = �1}

=1

2P {1 + Z y | X = 1}+ 1

2P {�1 + Z y | X = �1}

independence independence

25

(con5nued)deriva5onofthepdfofY

•  Differen5atethecdfwithrespecttoyandgetthepdf:

P {Y y} =1

2P {1 + Z y}+ 1

2P {�1 + Z y}

=1

2P {Z y � 1}+ 1

2P {Z y + 1}

fY (y) =1

2fZ(y � 1) · d(y � 1)

dy+

1

2fZ(y + 1) · d(y + 1)

dy

fY (y) =1

2fZ(y � 1) +

1

2fZ(y + 1)

=1 =1

26

PART4:THERECEIVER(DECODEDBIT)

27

YouwilldesignadecisionruleandsimulatethecorrespondingBER

•  The decoder “guesses” whether the transmiRed bit is -1 or+1,usingtheinputvalueY

•  isthevalueoftheguess•  Bit error rate (BER) or the bit error probability (BEP) is theprobabilityofmakinganerrorinthedecision:

receivedsymbol(realnumber)

YDecoder

receivedbit

X̂ 2 {�1, 1}

BER = Pn

X 6= X̂o

28

Page 8: Digital comm. systems Project: Simplified digital have ...webstaff.kmutt.ac.th/~watcharapan.suw/class/324/doc/commsys.pdf · encoder Channel encoder Modulator Interpolator Table

Yourtaskisthefollowing1.  Set p in line 10 of commsys_4_detect.m to be the value

assignedtoyourgroup2.  Fill-infunc5onfromSNRdB,whichconvertsfromtheSNRin

dBtothestandarddevia5onsigofnoise.Therela5onshipis

3.  Designyourowndecisionruleandfill-inthefunc5ondecide4.  Run commsys_4_detect.m to simulate the BER using the

decisionruleyoudesignedinstep35.  ModifythedecisionrulesothatthesimulatedBERisclose

tothebaseline(themaximumlikelihoodes5mateorMLE)6.  SubmitMatlab code commsys_4_detect.m and the plot of

BER(hardcopies)

SNR (dB) = 10 log10

E�X2

2E {Z2} = 10 log10p

�2

29

Anexampleofanaivedecisionruleistoalwaysguess.

•  ThentheMatlabcodeforfunc5ondecidewillbe% Decode the received symbols% Input:% y - a vector of received symbols (real numbers)% p - the probability that a bit +1 is sent at the % transmitter% sig - the standard deviation of Gaussian noise% Output:% xhat - a vector of +1's and -1's, of the same % size of 'y’. xhat(i) is the decoded bit for % the received symbol y(i)function xhat = decide( y, p, sig ) xhat = ones( size(y) ); end

X̂ = 1

30

ThentheBERwillbeatthedots

31

−10 −5 0 510−4

10−3

10−2

10−1

100

SNR (dB)

BER

Part 4: Bit error rate (BER) at different signal to noise ratios (SNRs)

Simulation (my decision rule)Baseline