Advanced Communication Engg Lab T7

33
2. Sigma delta modulation Aim: To design and set up a Sigma-Delta Modulator circuit Components and equipments required: ICs 324, 7474, counter, resistors, capacitors, DC source, signal generators, bread board and CRO Theory: Sigma-delta (ΣΔ) modulation is a method for encoding high-resolution or analog signals into lower-resolution digital signals . The conversion is done using error feedback, where the difference between the two signals is measured and used to improve the conversion. The low-resolution signal typically changes more quickly than the high-resolution signal and it can be filtered to recover the high-resolution signal with little or no loss of fidelity. This technique has found increasing use in modern electronic components such as analog-to-digital converters (ADCs) and digital-to-analog converters (DACs), frequency synthesizers , switched-mode power supplies and motor controllers . Delta-sigma modulation converts the analog voltage into a pulse frequency and is alternative known as Pulse Density modulation or Pulse Frequency modulation. In general frequency may vary smoothly in infinitesimal steps as may voltage and both may serve as an analog of an infinitesimally varying physical variable such as acoustic pressure, light intensity etc. so the substitution of frequency for voltage is entirely natural and

Transcript of Advanced Communication Engg Lab T7

Page 1: Advanced Communication Engg Lab T7

2. Sigma delta modulation

Aim: To design and set up a Sigma-Delta Modulator circuit

Components and equipments required: ICs 324, 7474, counter, resistors, capacitors, DC

source, signal generators, bread board and CRO

Theory: Sigma-delta (ΣΔ) modulation is a method for encoding high-resolution or analog

signals into lower-resolution digital signals. The conversion is done using error feedback, where

the difference between the two signals is measured and used to improve the conversion. The low-

resolution signal typically changes more quickly than the high-resolution signal and it can be

filtered to recover the high-resolution signal with little or no loss of fidelity. This technique has

found increasing use in modern electronic components such as analog-to-digital converters

(ADCs) and digital-to-analog converters (DACs), frequency synthesizers, switched-mode power

supplies and motor controllers.

Delta-sigma modulation converts the analog voltage into a pulse frequency and is

alternative known as Pulse Density modulation or Pulse Frequency modulation. In general

frequency may vary smoothly in infinitesimal steps as may voltage and both may serve as an

analog of an infinitesimally varying physical variable such as acoustic pressure, light intensity

etc. so the substitution of frequency for voltage is entirely natural and carries in its train the

transmission advantages of a pulse stream. The different names for the modulation method are

the result of pulse frequency modulation by different electronic implementations which all

produce similar transmitted waveforms.

Circuit Diagram:

Page 4: Advanced Communication Engg Lab T7

Procedure:

1. Set up circuit

2. Apply Vin vary from 0.4 V initially to 1.0 V and then to zero volts.

3. Observe waveforms at different points on CRO

Page 5: Advanced Communication Engg Lab T7

8. 4 Channel digital multiplexing

(using PRBS signal and digital multiplexer)

Aim: To design and set up a 4 channel digital multiplexer circuit

Components and equipments required: ICs 74153, 7486, 7496, DC source, signal generators,

bread board and CRO

Theory: A data selector, more commonly called a Multiplexer, shortened to "Mux" or "MPX",

are combinational logic switching devices that operate like a very fast acting multiple position

rotary switch. They connect or control, multiple input lines called "channels" consisting of either

2, 4, 8 or 16 individual inputs, one at a time to an output. Then the job of a multiplexer is to

allow multiple signals to share a single common output. For example, a single 8-channel

multiplexer would connect one of its eight inputs to the single data output. Multiplexers are used

as one method of reducing the number of logic gates required in a circuit or when a single data

line is required to carry two or more different digital signals.

Digital Multiplexers are constructed from individual analogue switches encased in a

single IC package as opposed to the "mechanical" type selectors such as normal conventional

switches and relays. Generally, multiplexers have an even number of data inputs, usually an even

power of two, n2 , a number of "control" inputs that correspond with the number of data inputs

and according to the binary condition of these control inputs, the appropriate data input is

connected directly to the output.

Circuit Diagram:

Page 6: Advanced Communication Engg Lab T7

Procedure:

1. Set up PRBS circuit

2. Apply PRBS o/p signal to select lines of Multiplexer IC 74153

3. Apply different signals to 4 input pins of IC 74153

4. Observe waveforms at different points on CRO

Page 7: Advanced Communication Engg Lab T7

9. Mean Square Error estimation of a signal.

x = 0:0.01:1;ip = sin(x); % inputsignal err_sig = sin(2*x); % error signal rx = ip+err_sig; err = zeros(1,length(ip));err_sq = zeros(1,length(ip));for i = 1:length(ip) err(i) = rx(i)-ip(i); err_sq(i) = err(i)*err(i);end mse = 0;temp = 0;for i = 1:length(ip) sum = temp+err_sq(i); temp = sum;end mse = sum/length(ip)

Page 8: Advanced Communication Engg Lab T7

10. Huffman Coding and Decoding

sig = repmat([3 3 1 3 3 3 3 3 2 3],1,50); % Data to encode

symbols = [1 2 3]; % Distinct data symbols %appearing in sig

p = [0.1 0.1 0.8]; % Probability of each data symbol

dict = huffmandict(symbols,p); % Create the dictionary.

hcode = huffmanenco(sig,dict); % Encode the data.

dhsig = huffmandeco(hcode,dict); % Decode the code.

Page 9: Advanced Communication Engg Lab T7

11. Implementation of LMS Algorithm

LMS Filter computes output, error, and weights using LMS adaptive algorithm

The LMS Filter block can implement an adaptive FIR filter using five different algorithms. The block estimates the filter weights, or coefficients, needed to minimize the error, e(n), between the output signal y(n) and the desired signal, d(n). Connect the signal you want to filter to the Input port. This input signal can be a sample-based scalar or a single-channel frame-based signal. Connect the desired signal to the desired port. The desired signal must have the same data type, frame status, complexity, and dimensions as the input signal. The Output port outputs the filtered input signal, which is the estimate of the desired signal. The output of the Output port has the same frame status as the input signal. The Error port outputs the result of subtracting the output signal from the desired signal.

When you select LMS for the Algorithm parameter, the block calculates the filter weights using the least mean-square (LMS) algorithm. This algorithm is defined by the following equations.

y(n) = wT(n-1)u(n)

e(n) = d(n)-y(n)

w(n) = w(n-1) + f(u(n),e(n), µ)

The weight update function for the LMS adaptive filter algorithm is defined as

f(u(n),e(n), µ)= µe(n)u*(n)

The variables are as follows.

Variable Description

n The current time index

u(n) The vector of buffered input samples at step n

u*(n) The complex conjugate of the vector of buffered input samples at step n

w(n) The vector of filter weight estimates at step n

y(n) The filtered output at step n

e(n) The estimation error at step n

d(n) The desired response at step n

µ The adaptation step size

Page 10: Advanced Communication Engg Lab T7

When you select Normalized LMS for the Algorithm parameter, the block calculates the filter weights using the normalized LMS algorithm. The weight update function for the normalized LMS algorithm is defined as

f(u(n),e(n), µ)= µe(n)u*(n)/[ε+uH(n)u(n)]

To overcome potential numerical instability in the update of the weights, a small positive constant, epsilon, has been added in the denominator. For double-precision floating-point input, epsilon is 2.2204460492503131e-016. For single-precision floating-point input, epsilon is 1.192092896e-07. For fixed-point input, epsilon is 0.

When you select Sign-Error LMS for the Algorithm parameter, the block calculates the filter weights using the LMS algorithm equations. However, each time the block updates the weights, it replaces the error term e(n) with +1 when the error term is positive, -1 when it is negative, or 0 when it is zero.

When you select Sign-Data LMS for the Algorithm parameter, the block calculates the filter weights using the LMS algorithm equations. However, each time the block updates the weights, it replaces each sample of the input vector u (n) with +1 when the input sample is positive, -1 when it is negative, or 0 when it is zero.

When you select Sign-Sign LMS for the Algorithm parameter, the block calculates the filter weights using the LMS algorithm equations. However, each time the block updates the weights, it replaces the error term e(n) with +1 when the error term is positive, -1 when it is negative, or 0 when it is zero. It also replaces each sample of the input vector u (n) with +1 when the input sample is positive, -1 when it is negative or 0 when it is zero.

Use the Filter length parameter to specify the length of the filter weights vector.

The Step size (mu) parameter corresponds to µ in the equations. For convergence of the normalized LMS equations, 0<µ<2. You can either specify a step size using the input port, Step-size, or by entering a value in the Block Parameters: LMS Filter dialog.

Use the Leakage factor (0 to 1) parameter to specify the leakage factor 1 – μα where 0 < 1 – μα ≤ 1 in the leaky LMS algorithm shown below.

w(n) = (1-µα)w(n-1)+ f(u(n),e(n), µ)

When you select LMS from the Algorithm list, the weight update function in the above equation is the LMS weight update function. When you select Normalized LMS from the Algorithm list, the weight update function in the above equation is the normalized LMS weight update function.

Enter the initial filter weights w(0) as a vector or a scalar in the Initial value of filter weights text box. When you enter a scalar, the block uses the scalar value to create a vector of

Page 11: Advanced Communication Engg Lab T7

filter weights. This vector has length equal to the filter length and all of its values are equal to the scalar value.

When you select the Adapt port check box, an Adapt port appears on the block. When the input to this port is greater than zero, the block continuously updates the filter weights. When the input to this port is less than or equal to zero, the filter weights remain at their current values.

When you want to reset the value of the filter weights to their initial values, use the Reset port parameter. The block resets the filter weights whenever a reset event is detected at the Reset port. The reset signal rate must be the same rate as the data signal input.

From the Reset port list, select None to disable the Reset port. To enable the Reset port, select one of the following from the Reset port list:

The least mean squares (LMS) algorithm is to remove noise from an input signal. The LMS algorithm computes the filtered output, filter error, and filter weights given the distorted and desired signals.

The baseline function signature for the algorithm is:

function [ signal_out, err, weights ] = ... lms_01(signal_in, desired)

The filtering is performed in the following loop:

for n = 1:SignalLength % Compute the output sample using convolution: signal_out(n,ch) = weights' * signal_in(n:n+FilterLength-1,ch); % Update the filter coefficients: err(n,ch) = desired(n,ch) - signal_out(n,ch) ; weights = weights + mu*err(n,ch)*signal_in(n:n+FilterLength-1,ch);end

where SignalLength is the length of the input signal, FilterLength is the filter length, and mu is the adaptation step size

LMS Algorithm

clear all% generate a time series y(n) = sin(2*pi*n*w0+phi)+epsilon(n)N=input('length of sequence N = ');randn('seed',sum(100*clock));w0=0.001; phi=0.1;d=sin(2*pi*[1:N+2]*w0+phi);y=d+randn(1,N+2)*0.2;x=[y(1:N);y(2:N+1);y(3:N+2)];randn('seed',sum(100*clock)); w=[randn(3,1) zeros(3,N)]; % 3 x N+1eta=input('eta = ');for i=1:N, e(i)=d(i)-w(:,i)'*x(:,i); w(:,i+1)=w(:,i)+eta*e(i)*x(:,i);

Page 12: Advanced Communication Engg Lab T7

endyd=sum(w(:,1:N).*x); % 1 by N, output of LMS filterax=[1:N]; bx=[3:N+2];clf, figure(1)subplot(221),plot(ax,w(1,ax+1)),ylabel('w0')subplot(222),plot(ax,w(2,ax+1)),ylabel('w1')subplot(223),plot(ax,w(3,ax+1)),ylabel('w2')subplot(224),plot([1:N],e),ylabel('error')figure(2)subplot(311),plot(ax,y(bx),'.g',ax,d(bx),'r-','linewidth',2),ylabel('noisy y')title('noiseless output (red), noisy output (1), filtered output (2), and error')axis1=axis; subplot(312),plot(ax,yd,'.g',ax,d(bx),'r-','linewidth',2),ylabel('filtered y'),axis(axis1);subplot(313),plot(ax,abs(y(bx)-d(bx)),'g:',ax,abs(yd-d(bx)),'r-')legend('original noise','filtered noise')

Page 13: Advanced Communication Engg Lab T7

12. Time delay estimation using correlation function

x = [0: 0.25*pi:10*pi];

ref = sin(x); %Reference ip = cos(x); c = xcorr2(ref,ip);

delay = abs(max(c));

fprintf('The estimated symbol delay is %g.\n ',delay)

Page 14: Advanced Communication Engg Lab T7

13. Comparison of effect in a dispersive channel for

BPSK, QPSK and MSK

BPSK

close allclear allclc

N = 10^6 % number of bits or symbolsrand(’state’,100); % initializing the rand() functionrandn(’state’,200); % initializing the randn() function

% Transmitterip = rand(1,N)>0.5; % generating 0,1 with equal probabilitys = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB varianceEb_N0_dB = [0:5:40]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)% Noise additiony = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise

% receiver – hard decision decodingipHat = real(y)>0;

% counting the errorsnErr(ii) = size(find([ip- ipHat]),2);

end

simBer = nErr/N; % simulated bertheoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical bertheoryBer1 = 0.5*erfc(sqrt(0.5.*(10.^(Eb_N0_dB/10)))); % theoretical ber

figuresemilogy(Eb_N0_dB,theoryBer,’b.-’);hold onaxis([-3 10 10^-5 0.5])grid onlegend(‘theory’);xlabel(‘Eb/No, dB’);ylabel(‘Bit Error Rate’);title(‘Bit error probability curve for BPSK modulation’);

Page 15: Advanced Communication Engg Lab T7

QPSK

clear; clc; sr=256000.0; % Symbol rate ml=2; % QPSK:ml=2 br=sr.*ml; % Bit rate nd=100; % Number of symbols that simulates in each loop ebn0=0; % Eb/N0 IPOINT=8; % Number of oversamples sample2=32; % Filter initialization irfn=21; % Number of taps alfs=0.5; % Rolloff factor [xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients [xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients % START CALCULATION nloop=100; % Max number of simulation loops noe = 0; % Number of error data nod = 0; % Number of transmitted data j=sqrt(-1); for iii=1:nloop % Data generation

Page 16: Advanced Communication Engg Lab T7

data1=rand(1,nd*ml)>0.5; % rand: built in function % QPSK Modulation [ich,qch]=qpskmod(data1,1,nd,ml);

[ich1,qch1]= compoversamp(ich,qch,length(ich),IPOINT); [ich2,qch2]= compconv(ich1,qch1,xh);

R1=ich2+j.*qch2; Mag1=abs(R1); %Add signals to carriers ich_sample2=oversample2(ich2,sample2); qch_sample2=oversample2(qch2,sample2); %Frequency of carriers is 4 times as large as %that of singnals after oversample(IPOINT=8) cos_carrier=cos((8*pi/sample2)*[1:length(ich_sample2)]); sin_carrier=sin((8*pi/sample2)*[1:length(qch_sample2)]); ich_sample2=ich_sample2.*cos_carrier; qch_sample2=qch_sample2.*sin_carrier; % Fading Channel % define a frequency vector and a magnitude vector to simulate the classic 'bathtub' shape f=(0.0:0.05:1.0); m=[1.0,1.2,1.5,1.9,2.8,4.0,6.0,9.0,15.0,25.0,1.00,0.05,0.03,0.02,0.01,0.005,0.005,0.005,0.005,0.005,0.005]; B=fir2(16,f,m); % design an FIR filter based on the shape above. ich_sample2_R=filter(B,1,ich_sample2); qch_sample2_R=filter(B,1,qch_sample2); % Attenuation Calculation

spow=sum(ich2.*ich2+qch2.*qch2)/nd; % sum: built in function

attn=0.5*spow*sr/br*10.^(-ebn0/10); attn=sqrt(attn); % sqrt: built in function

% Add White Gaussian Noise (AWGN)

[ich31,qch31]= comb(ich_sample2_R,qch_sample2_R,attn);% add white gaussian noise R2=ich31+j.*qch31; Mag2=abs(R2); %Resume signals from carriers ich3=ich31.*cos_carrier; qch3=qch31.*sin_carrier; %butterworth filter(cut-off frequency is chosen as same as carrier) [b,a]=butter(10,0.25);

Page 17: Advanced Communication Engg Lab T7

%filter the signals ich3=filter(b,a,ich3); qch3=filter(b,a,qch3); %resume dada from oversampled signals every 32 points ich3_data=ich3(1:sample2:length(ich3)); qch3_data=qch3(1:sample2:length(qch3)); [ich4,qch4]= compconv(ich3_data,qch3_data,xh2); syncpoint=irfn*IPOINT+1; ich5=ich4(syncpoint:IPOINT:length(ich4)); qch5=qch4(syncpoint:IPOINT:length(qch4)); % QPSK Demodulation [demodata]=qpskdemod(ich5,qch5,1,nd,ml); % Bit Error Rate (BER) noe2=sum(abs(data1-demodata)); % sum: built in function nod2=length(data1); % length: built in function noe=noe+noe2; nod=nod+nod2; fprintf('%d\t%e\n',iii,noe2/nod2);

MSK

Page 18: Advanced Communication Engg Lab T7

clearN = 5*10^5; % number of bits or symbols fsHz = 1; % sampling periodT = 4; % symbol duration Eb_N0_dB = [0:10]; % multiple Eb/N0 valuesct = cos(pi*[-T:N*T-1]/(2*T));st = sin(pi*[-T:N*T-1]/(2*T)); for ii = 1:length(Eb_N0_dB) % MSK Transmitter ipBit = rand(1,N)>0.5; % generating 0,1 with equal probability ipMod = 2*ipBit - 1; % BPSK modulation 0 -> -1, 1 -> 0 ai = kron(ipMod(1:2:end),ones(1,2*T)); % even bits aq = kron(ipMod(2:2:end),ones(1,2*T)); % odd bits ai = [ai zeros(1,T)];%padding with zero to make the matrix dimension match aq = [zeros(1,T) aq ]; % adding delay of T for Q-arm % MSK transmit waveform xt = 1/sqrt(T)*[ai.*ct + j*aq.*st]; % Additive White Gaussian Noise nt = 1/sqrt(2)*[randn(1,N*T+T) + j*randn(1,N*T+T)]; % white gaussian noise, 0dB variance % Noise addition yt = xt + 10^(-Eb_N0_dB(ii)/20)*nt; % additive white gaussian noise %% MSK receiver % multiplying with cosine and sine waveforms xE = conv(real(yt).*ct,ones(1,2*T)); xO = conv(imag(yt).*st,ones(1,2*T)); bHat = zeros(1,N); bHat(1:2:end) = xE(2*T+1:2*T:end-2*T) > 0 ; % even bits bHat(2:2:end) = xO(3*T+1:2*T:end-T) > 0 ; % odd bits % counting the errors nErr(ii) = size(find([ipBit - bHat]),2); end simBer = nErr/N; % simulated bertheoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber % plotclose allfiguresemilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);hold onsemilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2);axis([0 10 10^-5 0.5])grid on

Page 19: Advanced Communication Engg Lab T7

legend('theory - bpsk', 'simulation - msk');xlabel('Eb/No, dB');ylabel('Bit Error Rate');title('Bit error probability curve for MSK modulation');

Page 20: Advanced Communication Engg Lab T7
Page 21: Advanced Communication Engg Lab T7

14. Study of eye diagram of PAM transmission system

x = randint(n,1,M); % Create message signal.hMod = pammod(x,M); % Modulate.% Square root raised cosine filtersb = rcosfir(rollOff, [], nSamps, [], 'sqrt'); b = b /sum(b);hTxFlt = dfilt.dffir(b*nSamps); hTxFlt.PersistentMemory = true;hRxFlt = dfilt.dffir(b); hRxFlt.PersistentMemory = true;

% Generate modulated and pulse shaped signalframeLen = 1000;msgData = randsrc(frameLen,1,0:hMod.M-1,4321);msgSymbols = modulate(hMod, msgData);msgTx = hTxFlt.filter(upsample(msgSymbols, nSamps));

t = 0:1/Fs:50/Rs-1/Fs; idx = round(t*Fs+1);hFig = figure; plot(t, real(msgTx(idx)));title('Modulated, filtered in-phase signal');xlabel('Time (sec)'); ylabel('Amplitude'); grid on;

% Manage the figuresmanagescattereyefig(hFig);

% Create an eye diagram objecteyeObj = commscope.eyediagram(... 'SamplingFrequency', Fs, ... 'SamplesPerSymbol', nSamps, ... 'OperationMode', 'Complex Signal')

% Update the eye diagram object with the transmitted signaleyeObj.update(0.5*msgTx);

% Manage the figuresmanagescattereyefig(hFig, eyeObj, 'right');

Page 22: Advanced Communication Engg Lab T7

15. Generation of QAM signal and constellation graph

Constellation for 8-QAM

M = 8;x = [0:M-1];y = modulate(modem.qammod('M',M,'SymbolOrder','Gray'),x);

% Plot the Gray-coded constellation.scatterplot(y,1,0,'b.'); % Dots for points.% Include text annotations that number the points in binary.hold on; % Make sure the annotations go in the same figure.annot = dec2bin([0:length(y)-1],log2(M));text(real(y)+0.15,imag(y),annot);axis([-4 4 -4 4]);title('Constellation for Gray-Coded 8-QAM');hold off;

Constellation for 32-QAM

M = 32;x = [0:M-1];y = modulate(modem.qammod(M),x);scale = modnorm(y,'peakpow',1);y = scale*y; % Scale the constellation.scatterplot(y); % Plot the scaled constellation.

% Include text annotations that number the points.hold on; % Make sure the annotations go in the same figure.for jj=1:length(y) text(real(y(jj)),imag(y(jj)),[' ' num2str(jj-1)]);endhold off;

Page 23: Advanced Communication Engg Lab T7

16. DTMF encoder/decoder using simulink

Analog DTMF telephone signalling is based on encoding standard telephone Keypad digits and symbols in two audible sinusoidal signals of frequencies FL and FH. Thus the scheme gets its name as dual tone multi frequency (DTMF).

Hz 1209 1336 1477 697 1 2 3 770 4 5 6 852 7 8 9 941 * 0 #

Each key pressed can be represented as a discrete time signal

% First, let's generate the twelve frequency pairssymbol = {'1','2','3','4','5','6','7','8','9','*','0','#'};lfg = [697 770 852 941]; % Low frequency grouphfg = [1209 1336 1477]; % High frequency groupf = [];for c=1:4, for r=1:3, f = [ f [lfg(c);hfg(r)] ]; endendf'%%% Next, let's generate and visualize the DTMF tonesFs = 8000; % Sampling frequency 8 kHzN = 800; % Tones of 100 mst = (0:N-1)/Fs; % 800 samples at Fspit = 2*pi*t; tones = zeros(N,size(f,2));for toneChoice=1:12, % Generate tone tones(:,toneChoice) = sum(sin(f(:,toneChoice)*pit))'; % Plot tone subplot(4,3,toneChoice),plot(t*1e3,tones(:,toneChoice)); title(['Symbol "', symbol{toneChoice},'": [',num2str(f(1,toneChoice)),',',num2str(f(2,toneChoice)),']']) set(gca, 'Xlim', [0 25]); ylabel('Amplitude'); if toneChoice>9, xlabel('Time (ms)'); endendset(gcf, 'Color', [1 1 1], 'Position', [1 1 1280 1024])annotation(gcf,'textbox', 'Position',[0.38 0.96 0.45 0.026],... 'EdgeColor',[1 1 1],... 'String', '\bf Time response of each tone of the telephone pad', ... 'FitBoxToText','on');

Page 24: Advanced Communication Engg Lab T7
Page 25: Advanced Communication Engg Lab T7

17. Phase shift method of SSB generation

To implement the SSB modulation shown above we need to calculate the Hilbert

Transform of our message signal m[n] and modulate both signals. But before we do that we need

to point out the fact that ideal Hilbert transformers are not realizable. However, algorithms that

approximate the Hilbert Transformer, such as the Parks-McClellan FIR filter design technique,

have been developed which can be used. MATLAB® Signal Processing Toolbox™ provides the

firpm function which designs such filters. Also, since the filter introduces a delay we need to

compensate for that delay by adding delay (N/2, where N is the filter order) to the signal that is

being multiplied by the cosine term as shown below.

Page 26: Advanced Communication Engg Lab T7

For the FIR Hilbert transformer we will use an odd length filter which is computationally

more efficient than an even length filter. Albeit even length filters enjoy smaller passband errors.

The savings in odd length filters is a result that these filters have several of the coefficients that

are zero. Also, using an odd length filter will require a shift by an integer time delay, as opposed

to a fractional time delay that is required by an even length filter. For an odd length filter, the

magnitude response of a Hilbert Transformer is zero for w = 0 and w = pi. For even length filers

the magnitude response doesn't have to be 0 at pi, therefore they have increased bandwidths. So

for odd length filters the useful bandwidth is limited to

Let's design the filter and plot its zero-phase response.

d = fdesign.hilbert('N,TW',60,.1);Hd = design(d,'equiripple');hfv = fvtool(Hd,'Analysis','Magnitude',... 'MagnitudeDisplay','Zero-phase',... 'FrequencyRange','[-pi, pi)');set(hfv,'Color','white');

To approximate the Hilbert Transform we'll filter the message signal with the filter Hd.

m_tilde = filter(Hd,m);

The upper sideband signal is then

G = order(Hd)/2; % Filter delaym_delayed = [zeros(1,G),m(1:end-G)];f = m_delayed.*cos(2*pi*fo*t) - m_tilde.*sin(2*pi*fo*t);

and the spectrum is

Page 27: Advanced Communication Engg Lab T7

msspectrum(h,f,opts)

% Zooming in we getXlims = get(gca,'XLim');set(gca,'XLim',Xlims,'YLim',[-75 0])set(gcf,'Color','white');

As seen in the plot above we successfully modulated the message signal (three tones) to the carrier frequency of 3.5k Hz and kept only the upper sideband.

Page 28: Advanced Communication Engg Lab T7

18. Post Detection SNR estimation in Additive white Gaussian environment

Calculate the SNR threshold that achieves a probability of false alarm 0.01 using a

detection type of 'real' with a single pulse. Then, verify that this threshold is producing a Pfa of

approximately 0.01. Do so by constructing 10000 white real Gaussian noise samples and

counting how many times the sample passes the threshold.

snrthreshold = npwgnthresh(0.01,1,'real');

npower = 1; Ntrial = 10000;

noise = sqrt(npower)*randn(1,Ntrial);

threshold = sqrt(npower*db2pow(snrthreshold));

calculated_Pfa = sum(noise>threshold)/Ntrial;

 

Plot the SNR threshold against the number of pulses, for real and complex data. In each

case, the SNR threshold achieves a probability of false alarm of 0.001.

snrcoh = zeros(1,10); % Preallocate space

snrreal = zeros(1,10);

Pfa = 1e-3;

for num = 1:10

snrreal(num) = npwgnthresh(Pfa,num,'real');

snrcoh(num) = npwgnthresh(Pfa,num,'coherent');

end

plot(snrreal,'ko-'); hold on;

plot(snrcoh,'b.-');

legend('Real data with integration',...

'Complex data with coherent integration',...

'location','southeast');

xlabel('Number of Pulses');

ylabel('SNR Required for Detection');

title('SNR Threshold for P_F_A = 0.001')

hold off

Page 29: Advanced Communication Engg Lab T7