EECS 865 SIMULATION PROJECT

VIJAYA CHANDRAN RAMASAMI, KUID 698659

1

2

VIJAYA CHANDRAN RAMASAMI, KUID 698659

Contents List of Figures 1. Overview 2. Simulation Setup and Block Diagram 2.1. Monte-Carlo Simulation Technique 2.2. Serial to Parallel Converter 2.3. π/4 - DQPSK Encoder 2.4. Transmit Filter 2.5. Delays 2.6. Channel Simulators 2.7. Receive Filter 2.8. π/4-DQPSK Decoder 2.9. Parallel to Serial Converter 2.10. Comparator and BER Counter 2.11. Noise Power Calculations 3. π/4 Shifted Differential Quadrature Phase Shift Keying (DQPSK) 3.1. I and Q Components 3.2. Phase Shift Mapping 3.3. Constellation 3.4. π/4-DQPSK Encoder Implementation 3.5. π/4-DQPSK Decoder Implementation 4. Rayleigh Fading Envelope Generation 4.1. Spectral Shaping Filter 4.2. Fade Power Adjustment 4.3. Simulated Envelope 4.4. Faded SNR per bit 5. Simulation Results 5.1. Simulation Parameters 5.2. Case - I 5.3. Case II 5.4. Case III 5.5. Comprehensive Plot 5.6. Notes 6. MATLAB Modules for Simulation Blocks 6.1. Serial To Parallel Converter 6.2. π/4-DQPSK Encoder 6.3. Transmit Filter 6.4. Rayleigh Fading Generator 6.5. Receive Filter 6.6. Coherent π/4-DQPSK Decoder 6.7. π/4-QPSK Encoder/Decoder (without Differential Encoding/Decoding) 7. MATLAB Source Code 7.1. Case-I : AWGN Channel 7.2. Case-II : LOS + Rayleigh Fading 4 5 6 6 7 7 7 7 7 7 7 8 8 8 9 9 9 9 10 10 11 11 12 12 13 14 14 14 15 15 15 15 18 18 18 19 19 20 21 21 22 22 23

EECS 865 SIMULATION PROJECT

3

7.3. Case-III : 2-ray Rayleigh (variable delays) 8. Appendix A - Raised Cosine Filtering 8.1. Description 8.2. Design 8.3. MATLAB Code 9. Appendix B - Rayleigh Fading Generation (Clarke/Gans Model) 9.1. Result 9.2. MATLAB Code

24 27 27 28 29 31 31 31

4 VIJAYA CHANDRAN RAMASAMI. KUID 698659 List of Figures S 1 imulation Block Diagram π 2 /4-DQPSK Constellation R 3 ayleigh Fading Generation at Baseband S 4 imulated Rayleigh Fading Signal at Baseband (E[Power] = 1) B 5 ER vs Eb /No plot for π/4-DQPSK (Case-1) B 6 ER vs Eb /No plot for π/4-DQPSK (Case-2) B 7 ER vs Eb /No plot for π/4-DQPSK (Case-3) C 8 omprehensive plot for all the Results R 9 aised Cosine Frequency Response for T = 1ms An 10 Example Impulse Response Typical Simulated Rayleigh Fading at 859 MHz carrier (Receiver Speed = 100 11 Miles/hr) 6 10 11 13 14 15 16 17 27 30 31 .

explains the basic math behind π/4 . • π/4 . • Simulation Setup and Block Diagram . • Appendix A . Simulation Parameters and a brief description of each of the Simulation blocks.DQPSK Modulation . .EECS 865 SIMULATION PROJECT 5 1.Raised Cosine Filtering . • MATLAB Modules for Simulation Blocks .provides the MATLAB code for each and every simulation block. The code presented in this section uses the simulation blocks presented in the previous section.explains the method used to generate the square root raised cosine filter coefficents that can be used directly in the code with minor modifications. • Rayleigh Fading Envelope Generation . • Appendix B .Rayleigh Fading Generation (Clarke/Gans Model) .explains the basic methodology adopted to generate the Rayleigh Fading envelope and to implement Spectral Shaping. Overview This project report is organized as follows. • Results .provide the results for the simualtion. • MATLAB Code .DQPSK Modulation and some implementation details.explains the method and the MATLAB code to generate Rayleigh Fading using the Clarke/Gans Model.explains the Simulation Block Diagram.contains the MATLAB code used for the simulation cases.

Simulation Setup and Block Diagram The Block Diagram for this simulation is illustrated in fig(1). the MC Simulation technique involves the following steps : (1) Decide on the minimum target BER to be estimated. (5) Iterate the simulation for some specified number of iterations and compute the average of the BERs obtained in these iterations. (3) Setup the baseband modulators. In the context of BER estimation in Digital Communication Systems. it is 10−3 ). Transmit/Receive Filters and Channel Simulators. The simulation methodology followed was the well-known Monte-Carlo simulation technique. (Here. demodulators. (Here. The various simulation blocks are explained in the following sections. (Here. KUID 698659 2.1. the number of simulation runs was chosen to be 20). (4) Run the BER simulation and estimate the BER.6 VIJAYA CHANDRAN RAMASAMI. it is atleast 104 bits). b1k bk Serial to Parallel Converter Ik b2k π Shifted DQPSK 4 Encoder Qk Transmit Filter (Symbol Repeater) Sk α1 Delay #1 Compare for Errors BER Counter Channel #1 Rayleigh (or) LOS α2 Delay #2 Channel #2 Rayleigh (or) LOS b’1k Parallel to Serial Converter b’k I’k b’2k π Shifted DQPSK 4 Decoder Q’k Receive Filter (Integrate and Dump Filter) S’k Diversity Combiner Figure 1. (2) Set the number of bits per simulation run to be atleast 10 times the inverse of the minimum target BER to be estimated. Simulation Block Diagram 2. . Monte-Carlo Simulation Technique.

This blocks performs Matched Filtering of the received signal. This block can also be used to perform Raised Cosine filtering if provided with the proper FIR filter coefficients for the SQRC filter. • Rayleigh Fading Channel Simulator.EECS 865 SIMULATION PROJECT 7 2. \\ Q_WaveformIn.No) function [I_WaveformOut . MATLAB Prototype. MATLAB Prototype. 2.5. hTransmitFilter. MATLAB Prototype.7. Transmit Filter. hReceiveFilter. MATLAB Prototype.2.6.BitStreamTwo) 2.4. b2k } into Modulation Symbols {Ik . Qk } using π/4-DQPSK Signal Mapping. They take the I and Q baseband waveforms and apply channel-specific distortions to them. MATLAB Prototypes. The output of this filter are the received symbols that are fed into the demodulator. Q_SymbolsTx] = DQPSKEncoder(BitStreamOne.3. Delays. Serial to Parallel Converter. function [BitStreamOne. In the case of an all-ones FIR impulse response (i. Two types of channel simulators are provided. one containing the even numbered bits and the other containing the odd numbered bits. This block introduces a delay of specific duration (represented as the number of samples). BitStreamTwo] = SerialToParallel(BitStream) 2. AvgFadePower). Fading and Noise addition are done independently for the I and Q components. this tranmit filter is just a symbol repeater (represented by an FIR impulse response of all ones for the symbol interval). π/4 . \\ Q_SymbolsTx.Q_SymbolsRx] = ReceiveFilter(I_WaveformRx. function [I_SymbolsRx. The output pair of bits constitute the input symbol stream to the π/4 DQPSK Modulator.Q_WaveformTx] = TransmitFilter(I_SymbolsTx.Q_WaveformRx] = AWGNChannel(I_WaveformTx.DQPSK Encoder. Q_WaveformRx. This block converts the incoming information bits into two streams. In the given problem. • AWGN Channel Simulator. These blocks simulate the channel response. function [I_WaveformTx. this filter essentially does an integrate and dump operation. numSamplesPerSymbol) \\ . Q_WaveformOut] = RayleighFader(I_WaveformIn. function [I_SymbolsTx.Q_WaveformTx. This block encodes the input information bits {b1k . This block converts the Modulation Symbols to Baseband Waveforms to be transmitted over the channel. 2. Receive Filter. symbol repetition). numSamplesPerSymbol) 2. Channel Simulators.e. function [I_WaveformRx.

Comparator and BER Counter. π/4-DQPSK Decoder. function [BitStreamOneRx. by counting the number of discrepancies between the input and the received bits. KUID 698659 2. (Eb /No )o ) can be obtained as follows : • If Nb is the number of bits used for simulation and Ik and Qk represent the inphase and quadrature phase components of the baseband signalling waveform. (1) 1 Eb = Nb N b/2 2 (Ik + Q2 ) k i=1 (2) It is important to note that Ik and Qk are represented by their sample values (8 samples/symbol).8. This block does the inverse of the Serial to Parallel Converter block. function [BitStream] = ParallelToSerial(BitStreamOneRx. BitStreamTwoRx) 2. The blocks compute the Probability of error (P e). BitStreamTwoRx] = DQPSKDecoder(I_SymbolsRx.10. Q_SymbolsRx) 2. MATLAB Prototype. Parallel to Serial Converter. Noise Power Calculations.e. MATLAB Prototype. The value of No for a given operating point (i.11. • The value of the noise PSD No can be found simply as. 2.9.8 VIJAYA CHANDRAN RAMASAMI. then the Average Energy per Bit (Eb ) 1 is given by. Eb No = (Eb /No )o 1This was the value of E that gave the desired result during the simulation b . This block performs the Maximum-Likelihood decoding of the received symbols and retrieves the information bits.

3.e. Further. but is more susceptible to envelope variations than OQPSK.1. Phase Shift Mapping. Hence. (The term “π/4 Shifted” appears in the context of constellation diagrams and will be explained later). defined by the following table. since the decoding of the present symbol depends upon the decoding (i. the information bits are mapped into phase transitions rather than absolute phase values. bi1 and bi2 are the information bits that constitute the input symbol di .3. . The constellation diagram shows that π/4 DQPSK is a combination of 2 QPSK constellations shifted with respect to each other by π/4 (and hence the name). • ∆θi is the phase difference between the symbols at the ith and the (i−1)th signalling intervals. (5) S(i) = S(i − 1) ∗ ej∆θi I(i) = I(i − 1) ∗ cos(∆θi ) − Q(i − 1) ∗ sin(∆θi ) Q(i) = I(i − 1) ∗ sin(∆θi ) + Q(i − 1) ∗ cos(∆θi ) Where. in π/4 DQPSK. The Phase shift ∆θi depends on the input symbol di = {00. the maximum phase shift is restricted to ±135o (as compared to 180o for QPSK and 90o for OQPSK). 3. Constellation.01. In such differential techniques. Thus. This encoding of information in the phase transitions overcomes the phase ambiguity problems resulting from the estimation of carrier phase in non-differential PSK systems. in π/4-DQPSK. the information bits that consitute the input symbol are encoded into one of the 4 possible phase transitions. the bandlimited π/4-DQPSK signal preserves the constant envelope property better than bandlimited QPSK. bi1 bi2 ∆θi = f (bi1 . Further.2. I and Q Components. π/4 Shifted Differential Quadrature Phase Shift Keying (DQPSK) This section deals with the math behind the π/4 Shifted DQPSK Modulation Technique. • I(i) and Q(i) are the in-phase and the quadrature phase components of the π/4 DPSK Modulated Symbol at the ith signalling interval. there is an inherent feedback. bi2 ) 0 0 π/4 0 1 3π/4 1 0 −3π/4 1 1 −π/4 Where. 3.EECS 865 SIMULATION PROJECT 9 3. The In-phase (I) and Quadrature Phase (Q) components of π/4 DQPSK can be expressed as : (3) (4) Or. This digital modulation technique is a special case of Differential M-ary Phase Shift Keying (D-MPSK) where M = 4. • S(i) is the ith modulated symbol.10}.11. the phase) of the past symbol. The Constellation of π/4 DQPSK Modulation is shown in fig(2).

2 Real(Modulated Symbol) −> 0. the π/4-DQPSK decision rule becomes.4 0.8 −0.4 −0. π/4-DQPSK decoding is generally accomplished using differentially coherent detection. 3.4. π/4-DQPSK Decoder Implementation. (7) (8) b1k = (sin ∆θk > 0) b2k = (cos ∆θk > 0) .6 −0.4 −0.8 0.2 −0. π/4-DQPSK Encoder Implementation.6 Imaginary(Modulated Symbol) −> 0.2 0 0. • Compute the phase angles of all the received baseband symbols.5. π/4-DQPSK Constellation 3. KUID 698659 1 0.8 −1 −1 −0.4 0. (6) ∆θk = ∠Sk − ∠Sk−1 • Demap the phase values into information bits using the inverse of the phase mapping function.6 −0. Once the value of ∆θk is obtained.8 1 Figure 2.6 0.10 VIJAYA CHANDRAN RAMASAMI. The encoding operation can be easily implemented using the recursive relations given in equations (4). • Compute the difference in phase angles between succesive symbols.2 0 −0.

the colored Gaussian samples can be generated by passing the white Gaussian Noise samples through a filter whose transfer function H(f ) can be obtained by solving. Rayleigh Fading Envelope Generation The generation of Rayleigh Fading envelopes follow from the basic fact that the envelope of a complex gaussian process (with independent real and imaginary parts) has a Rayleigh Distribution. The Spectral Shaping filter is usually specified in terms of its Autocorrelation function or Power Spectral density. If Ig (n) and Qg (n) represent the in-phase and quadrature phase components of the complex gaussian process (after spectral shaping). (10) H(f )H ∗ (f ) = Sxx (f ) . Rayleigh Fading Generation at Baseband The Spectral Shaping filter is needed to introduce a desired amount of correlation into the gaussian samples that produce the rayleigh distribution. The general method to generate a Rayleigh Fading envelope is illustrated in fig (3). (9) α(n) = Ig (n)2 + Qg (n)2 4. Gaussian Noise Source Spectral Shaping Filter • 2 Rayleigh Fading Envelope Gaussian Noise Source Spectral Shaping Filter • 2 Figure 3. Spectral Shaping Filter. the rayleigh fading envelope can be generated as. the spectral shaping filter takes the form of a Doppler Filter with the maximum doppler spread specified by the Mobile Speed (Clarke/Gans Model).1. When a Power Spectral Density is specified.EECS 865 SIMULATION PROJECT 11 4. In case of Mobile Communication Systems where Rayleigh fading has to be generated for a particular speed of the mobile.

Given the generated fading samples {αk }.3.72x[n] This system can be easily implemented using the “filter” command in MATLAB.8825z −1 Which converts to the simple differential equation. Thus we get. the PSD can be obtained taking the fourier transform of the specified autocorrelation as. The simulated rayleigh fading envelope at baseband is shown in fig(4). This works to to a sampling duration of T = 0. because of the slow fading assumption. backward/forward difference methods etc. the impulse response of the digital filter is obtained as. (11) Rxx (τ ) = e−1000τ ⇒ Sxx (f ) = 10002 2000 + (2πf )2 Further. In our case. In the given problem. 4. (15) y[n] = 0. √ 2000 (12) H(f ) = 1000 + j2πf The digital implementation of the above transfer function can be done in a plethora of ways. . we have to generate one rayleigh fading envelope sample per symbol (i.e. Suppose we require a specified average fade power P . √ P (16) αk = ˜ × αk E[α2 ] 4. it is much better to use impulse invariance rather then other techniques. 8000 samples per second). √ √ 2000 2000 (13) H(s) = ⇒ H(z) = 1000 s + 1000 1 − e− T z −1 Where T represents the sampling duration. the H(f ) can be obtained from the power spectral density as.12 VIJAYA CHANDRAN RAMASAMI. (14) H(z) = 44. we can generate the fading samples with the given average fade power P using the transformation. But the best (and the most relevant) method is the IIR implementation of the above filter using AR models. a choice has to be made between IIR filter synthesizing techniques such bilinear. Simulated Envelope.2. Proceeding futher. The digital implementation of H(f ) can be done either using FFT Techniques or FIR/IIR filtering depending on the situation and form of H(f ) obtained. Since the filter has a simple one-pole type transfer funtion. Sxx (f ) is the power spectral density of the filter. impulse-invariance. Even then.8825y[n − 1] + 44. Fade Power Adjustment.72 1 − 0. KUID 698659 Where.125ms.

EECS 865 SIMULATION PROJECT 13 10 1 10 0 Fade Level 10 −1 10 −2 0 2 4 6 8 10 12 Time (in milliseconds) −> 14 16 18 20 Figure 4. 2 Eb (17) γb = E{αk } No The operating points during the simulation are chosen based on the above expression for 2 γb . it is an implementation issue to decide on their values given a value of γb as an operating point. When fading is considered. Faded SNR per bit. the average signal to noise ratio per bit (γb ) has to be redefined as.4. Simulated Rayleigh Fading Signal at Baseband (E[Power] = 1) 4. Since the SNR per bit is a product of the average fade power (E{αk }) and the unfaded Eb /No . .

• Number of Bits per iteration = 10000 (Case I).QPSK Encoder/Decoder combination (without differential encoding/decoding) was used to calibrate the system.14 VIJAYA CHANDRAN RAMASAMI. 3000 (Case III). 5000 (Case II). . The theoritical and the practical curves for QPSK matched properly which implies that all the other modules are functioning properly. KUID 698659 5. The channel used for this simulation is an single ray. The simulation results are shown in fig(5). Simulation Parameters. • Number of iterations = 20.2.Monte Carlo Simulation. The Pe for QPSK is Q( 2 ∗ Eb /No ). BER vs Eb /No plot for π/4-DQPSK (Case-1) It is seen from the graph that the performance of π/4-DQPSK with differential detection is about 3-dB poorer that of π/4 QPSK operating under the same conditions. Calibration. Case . 5. Thus the system is properly calibrated. • Method .I. 10 0 Theoritical PI/4 QPSK PI/4 DQPSK (Differential Detection) −1 10 10 BER 10 −2 −3 10 −4 10 −5 0 1 2 3 4 5 Average SNR per bit −> 6 7 8 9 Figure 5.1.1. Simulation Results 5. A π/4.2. The Pe for π/4-DQPSK using differentially coherent demodulation is different from that of QPSK. AWGN channel with an average power gain of 1. 5.

.4. Combining all the three plots.EECS 865 SIMULATION PROJECT 15 5. Case III. • The simulations were repeated using Square-Root Raised Cosine Filters and identical results were obtained. The simulation results are shown in fig(6).2Ts were simulated.6. Only for this case. Case II.5.0. The channel used for this simulation consists of 2 independent rayleigh faded channels with an average power gain of 0. Three different values of delays (0.3. • A Rayleigh Fading Channel with an average power gain of 0. Comprehensive Plot. BER vs Eb /No plot for π/4-DQPSK (Case-2) 5.5. so that an integer value is obtained for the delay in terms of samples. 10 0 BER 10 −1 10 −2 0 1 2 3 Average SNR per bit −> 4 5 6 Figure 6. 5. Notes. we get fig(8).0.5. the number of samples per symbol was chosen to be 10. The channel used for this simulation is a 2-ray channel consisting of: • An LOS AWGN channel with an average power gain of 0. 5. The results are shown in fig(7).1Ts . There is no time delay in the response of these channels.5.

.16 VIJAYA CHANDRAN RAMASAMI. KUID 698659 10 0 Delay = 0 Delay = 1 Delay = 2 BER 10 −1 10 −2 0 1 2 3 Average SNR per bit −> 4 5 6 Figure 7. BER vs Eb /No plot for π/4-DQPSK (Case-3) • All the plots were generated by storing the simulation results in a data file and plotting them offline.

EECS 865 SIMULATION PROJECT 17 10 0 AWGN LOS + Rayleigh 2−ray Rayleigh (D = 0) 2−ray Rayleigh (D = 0. Comprehensive plot for all the Results .1 Ts) 2−ray Rayleigh (D = 0.2 Ts) BER 10 −1 10 −2 0 1 2 3 Average SNR per bit −> 4 5 6 Figure 8.

ModulatedSymbol(1) = (InitialSymbol)*exp(i*PhaseShift(1)). Serial To Parallel Converter. BitStreamTwo = BitStream(2:2:length(BitStream)). KUID 698659 6. ModulatedSymbol(index) = ModulatedSymbol(index-1)*exp(j*PhaseShift(index)). % Calculate the phase-shift due to the first symbol. % [0. Q_Symbols = imag(ModulatedSymbol). Q_Symbols] = DQPSKEncoder(BitStreamOneTx.BitStreamTwo] = SerialToParallel(BitStream) BitStreamOne = BitStream(1:2:length(BitStream)). InitialSymbol = (1+0i). 6. % Serial to Parallel Converter. function [BitStreamOne. end % Extract the I and Q parts of the Symbol. π/4-DQPSK Encoder.BitStreamTwoTx(index)]). I_Symbols = real(ModulatedSymbol). % The first modulated symbol. % The other symbols calculated iteratively. Q_StreamLength = I_StreamLength. PhaseShift(index) = CalcPhase([BitStreamOneTx(index). function Phase = CalcPhase(BitVector) switch BitVector(1) case 0. MATLAB Modules for Simulation Blocks Some implemenation issues and MATLAB code for all the simulation blocks are presented in this section.18 VIJAYA CHANDRAN RAMASAMI.0] case .1. 6. PhaseShift(1) = CalcPhase([BitStreamOneTx(1). for index = 2:1:I_StreamLength % The phase shift due to the ith modulated symbol.2. switch BitVector(2) case 0. % pi/4 shifter DQPSK Encoder. BitStreamTwoTx) % This is supposed to be (I(-1) + jQ(-1)). I_StreamLength = length(BitStreamOneTx). % -------------------> Differential Modulation <------------------------------.% % Do the Differential Modulation and generate the baseband-complex signal.BitStreamTwoTx(1)]). %-----------------> End of Code <----------------------------------------------% % CalcPhase -> does the phase mapping. function [I_Symbols. % Rotated the modulated symbol phasor to the new position.

Q_Gaussian = randn(1. % [0.numSamplesPerSymbol) lenWaveform = length(SymbolStream)*numSamplesPerSymbol.EECS 865 SIMULATION PROJECT 19 Phase = pi/4. % The next step is to filter the signal to obtain the transmit waveforms.72]. Q_Waveform = SymbolToWaveform(Q_Symbols. % [1. % Pass the samples thro a spectral shaping filter. AvgPower) % First generate the I and Q Gaussian Sequences. \\ hTransmitFilter. %----------------------------------------------------------------------------% % Converts a Symbol stream to a Waveform containing impulses. Waveform(1:numSamplesPerSymbol:lenWaveform) = SymbolStream.numSamplesPerSymbol). I_TxWaveform = conv(I_Waveform. The actual routine that generates the Rayleigh Fading Envelope is : % Rayleigh Fading generator function [fadeEnvelope] = GenerateRayleighFade(NumSamples.0] case Phase = -pi/4. . %[1.NumSamples). switch BitVector(2) case 0.numSamplesPerSymbol) % The first step is to convert the symbol stream into a digital signal so that it can % be filtered.NumSamples). end end 6. randn). I_Waveform = SymbolToWaveform(I_Symbols.numSamplesPerSymbol).lenWaveform).1] case Phase = -3*pi/4. Transmit Filter. [1 -0.Q_Symbols.8825]. I_Gaussian = randn(1. function [I_TxWaveform. end case 1. Rayleigh Fading Generator. I_Gaussian.hTransmitFilter).3. Q_TxWaveform] = TransmitFilter(I_Symbols. 6. Q_TxWaveform = conv(Q_Waveform. Waveform = zeros(1.hTransmitFilter). case 1.4. If_Gaussian = filter([44.1] case Phase = 3*pi/4. case 1. function [Waveform] = SymbolToWaveform(SymbolStream.

numSamplesPerSymbol). Q_RxSymbols = WaveformToSymbol(Q_FilterOutput(SymbolRange). KUID 698659 Qf_Gaussian = filter([44. fadeEnvelope = fadeEnvelope*sqrt(AvgPower).8825]. 6. The routine that applies this fading signal generated to the input waveform are : function [I_WaveformOut. Q_WaveformOut] = RayleighFader(I_WaveformIn.72]. [1 -0. AvgFadePower). randn). % Generate the Fade Envelope. I_WaveformOut = I_WaveformIn. % Adjust the fade power level to the one specified.hReceiveFilter).hReceiveFilter). % In actual it is ((Nt+Nr-1)-1)/2 = (Nt-1) = (Nr-1) (if Nt = Nr). \\ Q_WaveformIn. % It’s assumed here that the transmit and the receive filters are of the same length. rmsEnvelope = sqrt(mean(fadeEnvelope. fadeEnvelope = fadeEnvelope/rmsEnvelope.Q_RxSymbols] = ReceiveFilter(I_RxWaveform.*Qf_Gaussian). function [I_RxSymbols. N_FilterTrailer = length(hReceiveFilter)-1. Receive Filter.*I_Fade.Q_RxWaveform. \\ hReceiveFilter. numSamplesPerSymbol) SymbolStream = Waveform(1:numSamplesPerSymbol:length(Waveform)). SymbolRange = N_FilterTrailer+1:length(I_FilterOutput)-N_FilterTrailer. AvgFadePower). . Q_WaveformOut = Q_WaveformIn.numSamplesPerSymbol).20 VIJAYA CHANDRAN RAMASAMI.*fadeEnvelope)). taking into account the trailers due to the transmit and % receive filter impulse responses.5.*If_Gaussian + Qf_Gaussian. I_Fade = GenerateRayleighFade(lenWaveform. I_FilterOutput = conv(I_RxWaveform. function [SymbolStream] = WaveformToSymbol(Waveform. AvgFadePower) lenWaveform = length(I_WaveformIn). Q_FilterOutput = conv(Q_RxWaveform.*Q_Fade. Q_Fade = GenerateRayleighFade(lenWaveform. %-----------------------------------------------------------------------------------% % Converts a Waveform to a symbol stream. I_RxSymbols = WaveformToSymbol(I_FilterOutput(SymbolRange). fadeEnvelope = sqrt(If_Gaussian. % Convert to a symbol stream. Q_Gaussian.numSamplesPerSymbol) % Do the matched filtering first.

% Corresponding to a Phase of Zero.Q_SymbolsRx) InitialSymbol = 1+j*0. . function [BitStreamOne. DiffAngles = DiffAngles(1:end-1). BitStreamOne = sin(DiffAngles)<0. 6. BitStreamTwo = cos(DiffAngles)<0. 6. BitStreamTwo] = QPSKDecoder(I_Symbols. DiffAngles = [ModAngles 0] .6. function [I_Symbols.BitStreamTwo] = DQPSKDecoder(I_SymbolsRx. π/4-QPSK Decoder. π/4-QPSK Encoder/Decoder (without Differential Encoding/Decoding).7.1. function [BitStreamOne.7. π/4-QPSK Encoder. BitStreamTwo = Q_Symbols > 0.BitStreamTwo) I_Symbols = 2*BitStreamOne-1.2. Coherent π/4-DQPSK Decoder. Q_Symbols) BitStreamOne = I_Symbols > 0. Q_Symbols = 2*BitStreamTwo-1. ModAngles = angle(ModSymbols).[0 ModAngles]. 6.EECS 865 SIMULATION PROJECT 21 6. Q_Symbols] = QPSKEncoder(BitStreamOne. ModSymbols = (I_SymbolsRx + j*Q_SymbolsRx). streamLength = length(I_SymbolsRx).7. These modules are purely for calibrating the simulation setup.

BitStreamLength = 10000.5. .Q_WaveformTx] = TransmitFilter(I_SymbolsTx. nEnd = (Nf-1)/2 + (Nt-1)/2 + 1. hTransmitFilter = hSqRCFilter(nStart:nEnd). clear.BitStreamLength)>0. Nt = 31. hTransmitFilter = ones(1.. BitStream = rand(1. % LogEbNo = 0:0. % % % % % % % % Nf = 61. BitRate = 16000.BitStreamTwo] = SerialToParallel(BitStream). \\ hTransmitFilter.numSamplesPerSymbol). SamplingFrequency = numSamplesPerSymbol*BaudRate. hReceiveFilter = hTransmitFilter. KUID 698659 7.Q_SymbolsTx. SymbolDuration = 1/BaudRate. [BitStreamOne. hTransmitFilter = hTransmitFilter/max(hTransmitFilter).Complete the filter construction part first --> % Uncomment the following portion of the code to implement % Sqrt Raised Cosine Filtering.comment out this part for using RC filtering.22 VIJAYA CHANDRAN RAMASAMI. % <-.numSamplesPerSymbol). % Symbol Repetition ..5:6 -> for the comprehensive plot.SamplingFrequency).System test begins --> for EbNoIndex = 1:lenSim for iters = 1:nIters % The Transmitter. nIters = 20. numSamplesPerSymbol = 8. MATLAB Source Code 7.25.BitStreamTwo). lenSim = length(LogEbNo).SymbolDuration. LogEbNo = [0 1 2 3 4 5 6 7 8 9].1.Q_SymbolsTx] = DQPSKEncoder(BitStreamOne. nStart = (Nf-1)/2 . hReceiveFilter = hTransmitFilter. [I_SymbolsTx.. [I_WaveformTx. BaudRate = BitRate/2.0. Case-I : AWGN Channel. hSqRCFilter = SqRCFilter(Nf.(Nt-1)/2 + 1. % <-.

Eb1 = sum(I_WaveformTx. [I_SymbolsRx. Errors = sum(BitStream~=BitStreamRx).*I_WaveformTx)/(BitStreamLength). clear. \\ hTransmitFilter. BER(iters) = Errors/BitStreamLength. lenSim = length(LogFadeEbNo).Q_WaveformTx] = TransmitFilter(I_SymbolsTx. hReceiveFilter = hTransmitFilter. % The Receiver.System test begins --> for EbNoIndex = 1:lenSim for iters = 1:nIters % The Transmitter first BitStreamLength = 5000. % Eb/No and Avg Fade Power Calculations.BitStreamTwo).BitStreamLength)>0.EECS 865 SIMULATION PROJECT 23 % Power Calculations. BitStream = randn(1. No = (Eb1+Eb2)/(EbNo).*I_WaveformTx)/(BitStreamLength).Q_SymbolsRx] = ReceiveFilter(I_WaveformRx. BitStreamRx = ParallelToSerial(BitStreamOneRx. % <-.No). LogFadeEbNo = 0:0. numSamplesPerSymbol = 8. Eb2 = sum(Q_WaveformTx. AvgFadePower = 10^(LogFadeEbNo(EbNoIndex)/10).BitStreamTwoRx] = DQPSKDecoder(I_SymbolsRx.numSamplesPerSymbol). .*Q_WaveformTx)/(BitStreamLength).Q_SymbolsTx] = DQPSKEncoder(BitStreamOne. [I_SymbolsTx. [BitStreamOneRx. Eb1 = sum(I_WaveformTx.Q_WaveformRx.Q_SymbolsTx.Q_SymbolsRx). \\ hReceiveFilter. Case-II : LOS + Rayleigh Fading. EbNo = 10^(LogEbNo(EbNoIndex)/10).numSamplesPerSymbol). end AvBER(EbNoIndex) = sum(BER)/nIters end 7.5:6. [I_WaveformRx. nIters = 20.BitStreamTwo] = SerialToParallel(BitStream).Q_WaveformTx. [BitStreamOne.5.BitStreamTwoRx).numSamplesPerSymbol).2.Q_WaveformRx] = AWGNChannel(I_WaveformTx. hTransmitFilter = ones(1. [I_WaveformTx.

Eb = Eb1 + Eb2. I_WaveformRx = I_WaveformRay1+I_WaveformRay2.numSamplesPerSymbol). KUID 698659 Eb2 = sum(Q_WaveformTx.BitStreamTwoRx] = DQPSKDecoder(I_SymbolsRx. Errors = sum(BitStream~=BitStreamRx). I_WaveformTx = I_WaveformTx/sqrt(2).Q_WaveformRay2] = AWGNChannel(I_WaveformTx. \\ Q_FadedWaveform.24 VIJAYA CHANDRAN RAMASAMI. [I_SymbolsRx. BER(iters) = Errors/BitStreamLength. %change this param for varying delays.3.No). delay = 0. No = Eb/EbNo.Q_WaveformRx. EbNo = 1. % Channel Power Gains.No). EbNo = 10^(LogFadeEbNo(EbNoIndex)/10).Q_SymbolsRx). % THe Receiver.BitStreamTwoRx). Case-III : 2-ray Rayleigh (variable delays). Q_WaveformTx = Q_WaveformTx/sqrt(2). BitStreamRx = ParallelToSerial(BitStreamOneRx. hReceiveFilter = hTransmitFilter. No = Eb/EbNo. nIters = 20. LogFadeEbNo = 0:0.AvgFadePower). % Diversity Combining..Q_WaveformRay1] = AWGNChannel(I_FadedWaveform. [BitStreamOneRx. % The Ray #1 (Rayleigh Faded). hTransmitFilter = ones(1...numSamplesPerSymbol). Q_SymbolsRx] = ReceiveFilter(I_WaveformRx.. numSamplesPerSymbol = 10. clear.*Q_WaveformTx)/(BitStreamLength). [I_WaveformRay2. % AWGN Channel..Q_WaveformTx. [I_FadedWaveform. % Multipath-Fading. Q_FadedWaveform] = RayleighFader(I_WaveformTx. \\ Q_WaveformTx. [I_WaveformRay1. end AvBER(EbNoIndex) = sum(BER)/nIters end 7. .. Q_WaveformRx = Q_WaveformRay1+Q_WaveformRay2.5:6. %The Ray #2 (Line of Sight). lenSim = length(LogFadeEbNo). \\ hReceiveFilter.

\\ Q_WaveformTx.delay) I_WaveformRay2(1:end-delay)].. \\ Q_FadedWaveform1. % Channel Power Gains. Q_WaveformRx = Q_WaveformRay1+[zeros(1.numSamplesPerSymbol)..No).Q_WaveformTx] = TransmitFilter(I_SymbolsTx.EECS 865 SIMULATION PROJECT 25 % <-. Q_FadedWaveform1] = RayleighFader(I_WaveformTx. . Q_WaveformTx = Q_WaveformTx/sqrt(2).Q_WaveformRay2] = AWGNChannel(I_FadedWaveform2. [I_WaveformRay1..*Q_WaveformTx)/(BitStreamLength). EbNo = 10^(LogFadeEbNo(EbNoIndex)/10). Eb1 = sum(I_WaveformTx.BitStreamLength)>0. %The Ray #2 (Rayleigh Faded). \\ hTransmitFilter. % Diversity Combining (Delay is introduced here). [I_WaveformRay2. AvgFadePower = 1.*I_WaveformTx)/(BitStreamLength).Q_WaveformRay1] = AWGNChannel(I_FadedWaveform1. \\ Q_FadedWaveform2.5. \\ Q_WaveformTx. [I_FadedWaveform2.. Eb = Eb1 + Eb2.. No = Eb/EbNo. % Multipath-Fading. [I_SymbolsTx. [I_FadedWaveform1.AvgFadePower). BitStream = rand(1. Q_FadedWaveform2] = RayleighFader(I_WaveformTx. % AWGN Channel. No = Eb/EbNo. % Multipath-Fading.No).AvgFadePower). [I_WaveformTx. (independent of the other ray).delay) Q_WaveformRay2(1:end-delay)].System test begins --> for EbNoIndex = 1:lenSim for iters = 1:nIters % The Transmitter first BitStreamLength = 3000. Eb2 = sum(Q_WaveformTx.. % The Ray #1 (Rayleigh Faded). [BitStreamOne.Q_SymbolsTx] = DQPSKEncoder(BitStreamOne. % AWGN Channel..Q_SymbolsTx... I_WaveformTx = I_WaveformTx/sqrt(2).BitStreamTwo). I_WaveformRx = I_WaveformRay1+[zeros(1. % Eb/No and Avg Fade Power Calculations.BitStreamTwo] = SerialToParallel(BitStream).

end AvBER(EbNoIndex) = sum(BER)/nIters end . \\ hReceiveFilter. Errors = sum(BitStream~=BitStreamRx).numSamplesPerSymbol). [I_SymbolsRx. [BitStreamOneRx.BitStreamTwoRx). KUID 698659 % THe Receiver..BitStreamTwoRx] = DQPSKDecoder(I_SymbolsRx. Q_SymbolsRx] = ReceiveFilter(I_WaveformRx.Q_WaveformRx.26 VIJAYA CHANDRAN RAMASAMI. BER(iters) = Errors/BitStreamLength.Q_SymbolsRx). BitStreamRx = ParallelToSerial(BitStreamOneRx.

Appendix A . in Digital x 10 −3 Raised Cosine Frequency Response (T = 1ms) 1 0. The roll-off factor is an important paramter that determines the bandwidth of th pulse waveform and the time-sidelobe levels in adjacent symbol slots.2 0.  T.Raised Cosine Filtering As explained earlier. (These coefficients must be passed as parameters to the “TransmitFilter(. )” and the “ReceiveFilter(. Generally.1 0 0 100 200 300 400 500 600 Frequency −> 700 800 900 1000 Figure 9.5 0. This section explains the method used to generate the SQRC filter coefficients. Raised Cosine Filtering can be easily included in the simulation once the filter coefficients are known. A filter defined using the above transfer function produces zero-ISI over a low-pass channel.7 Roll−Off = 1 Amplitude −> 0. . )” functions).9 Roll−Off = 0 Roll−Off = 0.4 0. . The Raised Cosine filter is defined using the following frequency domain transfer function.8 Roll−Off = 0. 8.EECS 865 SIMULATION PROJECT 27 8. |f | ≥ 2T Where. the parameter α denotes the roll-off factor of the RC filter and T is the symbol rate. Description. 0 ≤ |f | ≤ (1−α)  2T (18) Hrc (f ) = T 1 + cos πT |f | − (1−α) .1.5 0.6 0. Raised Cosine Frequency Response for T = 1ms . .25 0.3 0. (1+α) ≤ |f | ≤ (1−α) α 2T 2T 2T 2  (1−α) 0. .

25. Generally. The design procedure can be split into the following steps : • Step 1: From the given frequency response H(f ) (this can either be the RC or the SQRC Response). the Symbol/Bit duration (Tb ) and the roll-off factor (α). . is to use linear-phase (FIR) digital filters with a magnitude repsonse given by. the Frequency Resolution factor (N = F s/∆f ) and the number of filter taps (Nt ) . (21) Hd (k) = H(kFs /N ).28 VIJAYA CHANDRAN RAMASAMI. k = 0. The Sampling frequency should be atleast 2/Tb . N will be specified as an odd integer. (20) |HT (f )| = |HR (f )| = Hrc (f ) The most commonly used design methodology is the Frequency Sampling design. For example. Design. In addition. Generally. Nt will be specified as an odd integer. where the frequency response of the filter is sampled at constant intervals and an inverse fourier transform (IDFT) is applied to the frequency samples to obtain the filter coeffcients. then the product (which is indeed. if HT (f ) is the transmit filter and HR (f ) is the receive filter. 1. Fs = 4kHz(= 4/Tb ).Required for the digital implementation. . The designed (RC) filter will have zeros at t = nTb • Roll-Off factor (α) . • Number of Filter Taps (Nt ) . Nt = 31). for simulation purposes. N = 61. more will the actual response match the desired response. • Frequency Resolution factor (N) . a casade of these two filters) HT (f )HR (f ) is designed to yeild zero-ISI. There are 3 fundemental parameters that one must specify for the filter design : the response type (Raised Cosine or Square Root Raised Cosine).2. Higher frequency resolution leads to a response that matches the desired response with more accuracy. .This determines the sharpness of the frequency response. Tb = 1ms. (N − 1)/2. the trasmit and the receive filters are jointly designed to produce zero-ISI. • Symbol/Bit duration (Tb ). for the frequency sampling design. The simplest way to design HT (f ) and HR (f ). .This is a fundemental parameter that determines the frequency response of the filter. there are 3 more additional parameters required : the sampling frequency (Fs ). form the frequency samples at uniform intervals of ∆f = Fs /N . for the first (N − 1)/2 samples. An example design specification can be like (T ype = RC.This determines the number of samples of the frequency response that are used in the design. KUID 698659 Communication Systems. More the number of frequency samples taken. α = 0. .This can be either Raised Cosine (RC) or Square Root Raised Cosine (SQRC). Design Specifications. Design Procedure. The explanation of these parameters are given below: • Type of Response .If more filter taps are used in the FIR filter. If we design HT (f ) and HR (f ) as : (19) HT (f )HR (f ) = Hrc (f ) then the combined effect if these two filters effectively produces zero ISI. a more accurate response is obtained. • Sampling Frequency (Fs ) . 8.

1. obtaining gd (n) as : (25) gd (n) = hd (n − (Nt − 1)/2) Now..Alpha. N n= −(Nt − 1) (Nt − 1) . . . . A cascade to two SQRC filters does yeild a zero ISI. n= −(Nt − 1) (Nt − 1) .. The remaining (N − 1)/2 samples (from (N + 1)/2 to N − 1). are filled using the above symmetry condition. The response does not have zeros at the symbol intervals. the frequency response must obey the following symmetry condition : (22) Hd (k) = Hd (N − k). • Step 4: The final step is to convert the computed (non-causal) impulse response into a realizable causal reponse by shifting the impulse response by (Nt − 1)/2 samples. i. using the above equation. for k = 1:(N-1)/2. . .Tb)). H(k+1) = sqrt(RaisedCosineResponse(k*Fs/N.Tb)). because it is a SQRC filter and not a RC filter... hd ((Nt − 1)/2). end for n = -(N-1)/2:(N-1)/2 h(n+((N-1)/2)+1) = H(0+1). we compute the impulse response values hd (−(Nt − 1)/2). 2 2 Using the symmetry of the frequency response. k = 0. . gd (n) exists from 0. . the above equation can be rewritten as. . The filter taps gd (n) for the above mentioned example specification is shown in fig(10)..Fs) H(1) = sqrt(RaisedCosineResponse(0. H(N-k+1) = H(k+1).3. N −1 2 (24) hd (n) = Hd (0) + i=0 Hd (k) cos( 2∗π kn).e.Alpha. end end . . 2 2 Thus.. 8..EECS 865 SIMULATION PROJECT 29 • Step 2: For a real-valued impulse response.. . 1. (Nt − 1) and is causal and realizable. function [h] = SqRCFilter(N. MATLAB Code. the inverse discrete fourier transform (IDFT) of the samples is taken as follows : N −1 (23) hd (n) = i=0 Hd (k)ej( 2∗π )kn N . . . h(n+((N-1)/2)+1) = h(n+((N-1)/2)+1) + 2*H(m+1)*cos(2*pi*m*n/N). .Alpha. • Step 3: Once the frequency samples are formed. N − 1. .Tb. for m = 1:(N-1)/2.

2 −15 −10 −5 0 Time (in milliseconds) 5 10 15 Figure 10. An Example Impulse Response . KUID 698659 1 0.2 0 −0.8 0.30 VIJAYA CHANDRAN RAMASAMI.4 0.6 Amplitude 0.

1 0.18 0. function [rayEnvelope] = RayleighEnvelope(MobileSpeed. MATLAB Code.2.16 0.08 0. NumSamples) % Step #1. .02 0.Rayleigh Fading Generation (Clarke/Gans Model) During the course of the project. a rayleigh fading generator using the Clarke/Gans Model was developed using the method described in Rappaport’s book on Wireless Communication. CarrierFrequency. Typical Simulated Rayleigh Fading at 859 MHz carrier (Receiver Speed = 100 Miles/hr) 9. Result.12 Time Elapsed (ms) −> 0. This section presents the code and an example result for USDC mobile transeiver travelling at 100 miles/hr. \\ SamplingFrequency.2 Figure 11. The Rayleigh Fading envelope for a USDC mobile receiver travelling at 100 miles/hr is plotted in fig(11).14 0.04 0.06 0. Appendix B . % --------% Calculate the doppler shift.1. 9.EECS 865 SIMULATION PROJECT 31 9. 10 1 Typical Simulated Rayleigh Fading at 859 MHz carrier (Receiver Speed = 100 Miles/hr) Signal Level about the RMS value −> 10 0 10 −1 0 0.

The pair of Gaussian random % processes are stationary inependent consisting of identically distributed % random variables. % Step #2 % -------% Two FFT’s are required for generating the spectra of the gaussian random process.32 VIJAYA CHANDRAN RAMASAMI. % Make them simple by taking a FFT with some 2^n points. % The DC component first. % Frequency Spacing. Nfft = 8. always better. % Convert the given miles/hr to meters/s first. while (Nfft < nActualPoints).Nfft). % 2. the filter response at fd can be obtained using polynomial fitting of the filter response curve. waveLength = 3e+08/CarrierFrequency. I_Gaussian = randn(1. % % % % % Step #4. A large sampling frequency must be choosen to resolve even the deepest of fades properly. Calculate the Wavelength from the carrier frequency. This will smoothen the fading envelope based on how much the sampling frequency is larger than 2*fd. . % Start with 8. % Take FFT’s of these Gaussian Random Variables. I_Gaussian_FFT = fft(I_Gaussian). KUID 698659 % 1. using fd = V/Lambda. Since the doppler filter has INFINITE response at f = fd. end Nfft % % % % The Number of samples for the IFFT will be more than the number of samples for the FFT by factor of (fs/2*fd). Q_Gaussian_FFT = fft(Q_Gaussian). % --------% Generate the complex gaussian random process. deltaF = 2*dopplerFrequency/Nfft. Generating the Doppler filters frequency response. Calulate the Maximum Doppler Shift ’fd’. Nfft = Nfft*2. --------The most difficult part. nActualPoints = ((2*dopplerFrequency)/SamplingFrequency)*NumSamples.609*MobileSpeed*1000/(3600*waveLength).Nfft). dopplerFrequency = 1. Q_Gaussian = randn(1. Nifft = ceil(Nfft*(SamplingFrequency/(2*dopplerFrequency))) % Step #3.

*sqrt(dopplerFilter).Finishing off % ------------------------% Take the magnitude squared of the I and Q components and add them together.Nifft-Nfft) \\ I_Filtered_Gaussian(Nfft/2+1:Nfft)]. rayRMS = sqrt(mean(rayEnvelope(1:NumSamples). % The other components for ONE side the spectrum. % Take the IFFT.nFitPoints). Q_Time_Response = ifft(Q_Freq_Points). %for i = 1:Nifft % rayEnvelope(i) = sqrt(abs(I_Time_Response(i))^2 + abs(Q_Time_Response(i))^2). I_Filtered_Gaussian = I_Gaussian_FFT. %end % Compute the Root Mean Squared Value and Normalize the envelope. dopplerFilter(Nfft-index+2) = dopplerFilter(index). .frequencyIndex(Nfft/2)+deltaF). rayEnvelope = rayEnvelope(1:NumSamples)/rayRMS. I_Freq_Points = [I_Filtered_Gaussian(1:Nfft/2) zeros(1. % Store the frequency indices for polynomial fitting. ZERO-PAD the frequency response % to Nifft points (as explained before). % ------% Do the filtering of the gaussian random variables here.*sqrt(dopplerFilter). % Step #5. dopplerFilter((Nfft/2)+1) = polyval(polyFreq.5/(pi*dopplerFrequency). for index = 2:Nfft/2.^2)). % Step #6 .EECS 865 SIMULATION PROJECT 33 dopplerFilter(1) = 1. Q_Freq_Points = [Q_Filtered_Gaussian(1:Nfft/2) zeros(1. Q_Filtered_Gaussian = Q_Gaussian_FFT.5/(pi*dopplerFrequency*sqrt(1\\ (frequencyIndex(index)/dopplerFrequency)^2)). rayEnvelope = sqrt(((abs(I_Time_Response)). dopplerFilter(index) = 1. \\ dopplerFilter((Nfft/2)-nFitPoints:(Nfft/2)). I_Time_Response = ifft(I_Freq_Points).^2) + ((abs(Q_Time_Response)). nFitPoints = 3 % good enough. % First to smoothen the points out. end % polynomial fitting using the last 3 frequency samples.Nifft-Nfft) \\ Q_Filtered_Gaussian(Nfft/2+1:Nfft)]. frequencyIndex(index) = (index-1)*deltaF. frequencyIndex(1) = 0.*rayEnvelope(1:NumSamples))). polyFreq = polyfit(frequencyIndex((Nfft/2)-nFitPoints:(Nfft/2)).

The University of Kansas .34 VIJAYA CHANDRAN RAMASAMI. KUID 698659 EECS Department.

Sign up to vote on this title
UsefulNot useful