Documente Academic
Documente Profesional
Documente Cultură
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
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
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)
% Distinct data symbols %appearing in sig % Probability of each data symbol % Create the dictionary. % Encode the data. % Decode the code.
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, Stepsize, 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
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+1 eta=input('eta = '); for i=1:N, e(i)=d(i)-w(:,i)'*x(:,i); w(:,i+1)=w(:,i)+eta*e(i)*x(:,i);
end yd=sum(w(:,1:N).*x); % 1 by N, output of LMS filter ax=[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')
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)
13. Comparison of effect in a dispersive channel for BPSK, QPSK and MSK
BPSK
close all clear all clc N = 10^6 % number of bits or symbols rand(state,100); % initializing the rand() function randn(state,200); % initializing the randn() function % Transmitter ip = rand(1,N)>0.5; % generating 0,1 with equal probability s = 2*ip-1; % BPSK modulation 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); % 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 % Number of taps % Rolloff factor %Transmitter filter coefficients %Receiver filter coefficients
[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
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 % even bits % odd bits
ai = kron(ipMod(1:2:end),ones(1,2*T)); aq = kron(ipMod(2:2:end),ones(1,2*T));
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');
% 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');
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
To approximate the Hilbert Transform we'll filter the message signal with the filter Hd.
m_tilde = filter(Hd,m);
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.
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) 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 = npwgnthresh(Pfa,num,'coherent');