2013_v5_bpskpiawgn

Upload: safaahah

Post on 03-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 2013_V5_BPSKpiAWGN

    1/11

    1

    Binary Phase Shift Keying with

    BandPass Channel and Additive White

    Gaussian Noise : Modulation andDemodulation

    by Laurence G. Hassebrook

    2-27-2013

    We simulate Binary Phase Shift Keying (BPSK) with amplitude modulation and mixer based

    demodulation. The modulated signal is synthesized by using an upsampled random bipolar bit

    stream, modulated by a carrier wave and then sent through a bandpass channel and corrupted byAdditive White Gaussian Noise (AWGN). Assuming no phase error, the modulated signal is

    demodulated using a mixer configuration. Because the binary signal is bipolar, the resulting

    modulation is equivalent to phase modulation by 0 or . Both input and output signals areanalyzed for bandwidth and noise distribution. The goal is to reproduce the figures and

    processing presented in this document using MATLAB. The signal length is N; number of bits isNbit; Standard Deviation is STD and carrier frequency is kc.

    cl ear al l ; N=10000; Nbi t =8; %300; Nsampl e=f l oor ( N/ Nbi t ) ; STD=0. 1; %0. 5; kc=4*Nbi t ; kcut of f =kc/ 4; Nbi n=100; n=1: Nbi n;

    Note that there are Nsample sample values for each bit. Hence the system is upsampled byNsample to simulate continuous time or what we call pseudo-continuous time. The noise level is

    controlled by STD which is effectively the standard deviation of the Gaussian noise. The carrier

    frequency is kc and kcutoff is used for both the channel bandwidth and the demodulatorlowpass filter cutoff frequency. We separate the received 1 and 0 values and estimate their

    probability density functions for two experiments:

    Case 1: Use Nbit=8 and STD=0.1.Case 2: Use Nbit=300 and STD=0.5.

    1.BinarySequenceSynthesisGenerateNbitrandom bits using a the pseudo-random generater rand() such that

  • 8/12/2019 2013_V5_BPSKpiAWGN

    2/11

    2

    % Random Bi nar y Si gnal wb=r and(1, Nbi t ) ; bi t s=bi nar i ze( wb) ;

    The vector wbis has only one sample per bit which is not a good model for continuous time so

    we upsample using a kronecker product such that.

    ub=ones( 1, Nsampl e) ; bk=kron( bi t s, ub) ;

    where bk is length Nb = NsamplexNbit which might be less than N. So to make sure we have a

    signal N long we first generate a zero vector N long and then we move bk into it whicheffectively zero pads any mismatch in length.b=zeros( 1, N) ;Nb=Nsampl e*Nbi t ; t =1: N; b( 1: Nb) =bk( 1: Nb) ; %Force si gnal t o be N sampl es l ong

    % t ur n si gnal i nt o a bi pol ar non- r et ur n t o zer o si gnal b=2*( b- 0. 5) ;

    The result along with the BPSK modulation is shown in the next section.

    2.BPSKModulationfor shift.BPSK modulation with phase shift is achieved by first generating a discrete cosine wave andthen elementwise multiplying it by the upsampled bipolar binary signal sequence bsuch that

    % modul atesc=cos( 2*pi *kc*t / N) ; % car r i er s i gnal s=b. *sc;

    To plot out both the binary signal and the modulated signal in the same plot, and store a jpegimage of this result, the matlab code is:

    f i gur e( 1) ; pl ot ( t , b, t , s) ; t i t l e( ' BPSK Modul at i on' ) ; xl abel ( ' n' ) ; yl abel ( ' s( n) and b( n) ' ) ; axi s([ 1, N, - 1. 5, 1. 5] ) ;

    l egend( ' bi nar y message' , ' BPSK' ) ; pr i nt - dj peg Fi g1_BPSKSi gnal ;

    The resulting figures for is

  • 8/12/2019 2013_V5_BPSKpiAWGN

    3/11

    3

    Figure 2.1: Case 1 binary signal and modulated signal.

    The mathematical representation of the BPSK modulated signal is

    tftbts c2cos (1)

    where tis an integer index for sequence of lengthNand carrier frequencyfc= kc/N.

    3. ChannelModelandSignalAnalysisThe channel is a lowpass model with Additive White Gaussian Noise (AWGN) on its output.

    The lowpass component forces a bandlimited baseband onto the otherwise infinite bandwidth

    BPSK signal. The model is shown in Fig. 3.1.

  • 8/12/2019 2013_V5_BPSKpiAWGN

    4/11

    4

    Figure 3.1: Bandpass AWGN channel model.

    The MATLAB code to perform the bandpass component is:

    % f or m bandpass f i l t er Nor der =10; % f i l t er or der f max=N/ 2; % r equi r ed var i abl eK=1; % f i l t er gai n% kcut of f i s t he bandwi dt h of t he bandpass f i l t er% wher e kc i s cent er f r equency% band pass f i l t er [ f Hchannel ] =bp_but t er wor t h_oN_df t ( kc, kcut of f , K, f max, N, Nor der ) ; % f i l t er si gnal t hr ough channel S=f f t ( s); R=S. *Hchannel ; r0=real ( i f f t (R) ) ;

    k=t ; f i gur e( 2) ; SUBPLOT( 2, 1, 1) ; pl ot ( k, Hchannel , k, abs( S) / ( 2*max( abs( S) ) ) ) ; t i t l e( ' BPSK and Channel Spect r a' ) ; xl abel ( ' k' ) ; yl abel ( ' H( f ) and S( f ) ' ) ; SUBPLOT( 2, 1, 2) ; pl ot ( k, Hchannel , k, abs( R) / ( 2*max( abs( R) ) ) ) ; t i t l e( ' Channel Fi l t ered BPSK and Channel Spect r a' ) ; xl abel ( ' k' ) ; yl abel ( ' H( f ) and R( f ) ' ) ; pr i nt - dj peg Fi g2_BPSKSpect r a;

    For a low number of bits, the input and output spectra are difficult to see because they are so lowfrequency as shown in Fig. 3.2.

  • 8/12/2019 2013_V5_BPSKpiAWGN

    5/11

    5

    Figure 3.2: (top) Channel input BPSK spectrum. (bottom) Bandlimited output spectrum of BPSK.

    To generate the pseudo-random AWGN sequence we use randn() in MATLAB and add to thesignal r0(t) such that

    twtstr ~0 (2)

    The MATLAB code for the AWGN is

    %% Gaussi an di st r i but ed noi sew=STD*r andn( 1, N) ; r =r 0+w; f i gur e( 3) pl ot ( t , r ) ; t i t l e( ' BPSK Modul at i on wi t h Noi se' ) ; xl abel ( ' n' ) ; yl abel ( ' r ( n) =s( n) +w( n) ' ) ; pr i nt - dj peg Fi g3_BPSKPl usNoi se;

    The noisey signal is shown in Fig. 3.3.

  • 8/12/2019 2013_V5_BPSKpiAWGN

    6/11

    6

    Figure 3.3: Signal output of channel with noise.

    4.DemodulationandSignalAnalysisWe will use a mixer followed by a low pass filter to demodulate the BPSK signal as shown in

    Fig. 4.1. Only one mixer is needed because the phase modulation is which means that a 1 bitwill demodulate to a 1 and a 0 bit will demodulate to -1. A mixer multiplies the received signal

    with a replica of the carrier signal which must be in phase with the modulated carrier. The

    multiplication creates what is known as a baseband and two frequency translated replicas of the

    baseband centered at +/- 2kcfrequencies. So to reconstruct the signal we simply low pass filterthe multiplier output with a cutoff around kcutoff. Mathematically this is

    thNtktrtr LPcb *2cos

    (3)

  • 8/12/2019 2013_V5_BPSKpiAWGN

    7/11

    7

    Figure 4.1: Mixer based demodulator.

    The MATLAB code for the demodulator is

    %% DEMODULATI ON USI NG A MI XERsr ef =sc; % r ef er ence si gnal % mi x t he r ef er ence wi t h t he i nput r 1=r . *sr ef ;

    % f orm reconstr uct i on f i l t er % f i l t er wi t h some r ecommended paramet ersNor der=8; f max=N/ 2; K=8; % f i l t er gai n[ f H] =l p_but t er wort h_oN_df t ( kcut of f , K, f max, N, Nor der ) ; % f i l t er si gnal t hr ough channel vi a f r equency domai nR1=f f t ( r 1) ; R=R1. *H; rb=real ( i f f t (R) ) ;

    To detect 0 and 1 bits separately, we do not want to sample the bit boundaries else we wouldget errors from the transitions. So we define binary windows within the bit boundaries, one for

    the 1 detection and the other for the 0 detection.

    % def i ne sampl i ng r egi on f or det ect or ueye=zer os( 1, Nsampl e) ; ueye( 1, f l oor ( Nsampl e/ 4) : f l oor ( 3*Nsampl e/ 4) ) =1; bkeye=kr on( bi t s, ueye) ; bkeyenot=kron( ( 1- bi t s) , ueye) ; beye=zer os( 1, N) ;beyenot =zeros( 1, N) ;beye(1: Nb)=bkeye( 1: Nb) ; %Force si gnal t o be N sampl es l ongbeyenot ( 1: Nb)=bkeyenot ( 1: Nb) ; %Force si gnal t o be N sampl es l ong

    where beye is within the one boundaries and beyenot is within the zero boundaries. All these

    signals are shown in Fig. 4.1

  • 8/12/2019 2013_V5_BPSKpiAWGN

    8/11

    8

    Figure 4.2: Demodulated signal with the detection windows superimposed.

    Using the window sequences we estimate pdfs for the 0 and 1 signals separately as

    %% seper at e out t he two noi se di st r i but i onsJ 0=f i nd(beyenot>0. 5) ; J 1=f i nd(beye>0. 5) ; r b0=r b( J 0) ; r b1=r b( J 1) ; %

    [ f 0 n0] = PDFest i mat or ( r b0, Nbi n) ; [ f 1 n1] = PDFest i mat or ( r b1, Nbi n) ; %f i gur e( 5) ; pl ot ( n0, f 0, n1, f 1) ; t i t l e( ' Demodul ated PDF Est i mat i on' ) ; xl abel ( ' r ' ) ; yl abel ( ' f ( r ) ' ) ; l egend( ' Detected Zeros' , ' Detect ed Ones' ) ; pr i nt - dj peg Fi g5_Demodul at edSi gnal PDFest i mat i on;

  • 8/12/2019 2013_V5_BPSKpiAWGN

    9/11

    9

    Figure 4.3: Estimated pdfs within the "0" and "1" detection windows with case 1

    5. Case2ResultsRerun your simulation with Nbit=300 and STD=0.5 and re-plot Figs. 3.2 and 4.3 as Figs. 5.1 and

    5.2, respectively.

  • 8/12/2019 2013_V5_BPSKpiAWGN

    10/11

    10

    Figure 5.1: (top) Channel input BPSK spectrum. (bottom) Bandlimited output spectrum of BPSK. Blue line is bandpass

    filter envelope.

  • 8/12/2019 2013_V5_BPSKpiAWGN

    11/11

    11

    Figure 5.2: Estimated pdfs within the "0" and "1" detection windows with case 2.