Advanced Communication Engg Lab T7

Share Embed Donate


Short Description

Download Advanced Communication Engg Lab T7...

Description

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 lowresolution 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:

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

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:

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

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)

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.

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 framebased 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

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 -1; 1 -> 0 n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white gaussian noise, 0dB variance Eb_N0_dB = [0:5:40]; % multiple Eb/N0 values for ii = 1:length(Eb_N0_dB) % Noise addition y = s + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise % receiver – hard decision decoding ipHat = real(y)>0; % counting the errors nErr(ii) = size(find([ip- ipHat]),2); end simBer = nErr/N; % simulated ber theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber theoryBer1 = 0.5*erfc(sqrt(0.5.*(10.^(Eb_N0_dB/10)))); % theoretical ber figure semilogy(Eb_N0_dB,theoryBer,’b.-’); hold on axis([-3 10 10^-5 0.5]) grid on legend(‘theory’); xlabel(‘Eb/No, dB’); ylabel(‘Bit Error Rate’); title(‘Bit error probability curve for BPSK modulation’);

QPSK clear; clc; sr=256000.0; ml=2; br=sr.*ml; nd=100; ebn0=0; IPOINT=8; sample2=32;

% % % % % %

Symbol rate QPSK:ml=2 Bit rate Number of symbols that simulates in each loop Eb/N0 Number of oversamples

% Filter initialization irfn=21; alfs=0.5; [xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); [xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0);

% Number of taps % Rolloff factor %Transmitter filter coefficients %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

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);

%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

clear N = 5*10^5;

% number of bits or symbols

fsHz = 1; T = 4;

% sampling period % symbol duration

Eb_N0_dB = [0:10]; % multiple Eb/N0 values ct = 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; ipMod = 2*ipBit - 1;

% generating 0,1 with equal probability % BPSK modulation 0 -> -1, 1 -> 0

ai = kron(ipMod(1:2:end),ones(1,2*T)); aq = kron(ipMod(2:2:end),ones(1,2*T));

% even bits % 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 ber theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber % plot close all figure semilogy(Eb_N0_dB,theoryBer,'bs-','LineWidth',2);

hold on semilogy(Eb_N0_dB,simBer,'mx-','LineWidth',2); axis([0 10 10^-5 0.5]) grid on legend('theory - bpsk', 'simulation - msk'); xlabel('Eb/No, dB'); ylabel('Bit Error Rate'); title('Bit error probability curve for MSK modulation');

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 filters b = 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 signal frameLen = 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 figures managescattereyefig(hFig);

% Create an eye diagram object eyeObj = commscope.eyediagram(... 'SamplingFrequency', Fs, ... 'SamplesPerSymbol', nSamps, ... 'OperationMode', 'Complex Signal') % Update the eye diagram object with the transmitted signal eyeObj.update(0.5*msgTx); % Manage the figures managescattereyefig(hFig, eyeObj, 'right');

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)]); end hold off;

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 pairs symbol = {'1','2','3','4','5','6','7','8','9','*','0','#'}; lfg = [697 770 852 941]; % Low frequency group hfg = [1209 1336 1477]; % High frequency group f = []; for c=1:4, for r=1:3, f = [ f [lfg(c);hfg(r)] ]; end end f' %% % Next, let's generate and visualize the DTMF tones Fs = 8000; % Sampling frequency 8 kHz N = 800; % Tones of 100 ms t = (0:N-1)/Fs; % 800 samples at Fs pit = 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)'); end end set(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');

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.

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 delay m_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

msspectrum(h,f,opts) % Zooming in we get Xlims = 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.

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

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF