Você está na página 1de 78

1

EX.NO: 1 Date:

FIR ADAPTIVE FILTER DESIGN USING LMS ALGORITHM

AIM
To design a FIR adaptive filter using least mean square algorithm.

APPARATUS USED/TOOLS RERQUIRED


MATLAB 2009 Software

THEORY
There are number of techniques for processing nonstationary signals using adaptive filters. These techniques have been exclusively used in a variety of applications including system identification, signal modeling, spectrum estimation, noise cancellation and adaptive equalization. The FIR adaptive filters are designed in such a way to minimize the mean square error (n)=E |e(n)| between a desired process d(n) and an estimate of this process that is formed by filtering another process x(n).Since the gradient of (n) involves an expectation of e(n)x*(n),this approach requires knowledge of statistics of x(n) and d(n) and therefore is of limited one in practice. Next if we replace the ensemble average E{|e(n)|} with the instantaneous squared error |e(n)| this leads to the LMS algorithm, a simple and often effective algorithm, that does not require any ensemble average to be known. For wide sense stationary processes, the LMS algorithm converges in the mean, if the step size is positive and not larger than 2/max (where max is the maximum Eigen value of autocorrelation matrix Rx) and it converges in the mean-square. If the step size is positive and no larger than 2/tr (Rx) there are several types of LMS algorithm available. The first is the normalized LMS algorithm, which simplifies the selection of the step size to ensure that the coefficients converge. Next is the leaky LMS algorithm, which is useful in overcoming the problems that occur when the autocorrelation matrix of the input process is singular. There are also block LMS algorithm and the sign algorithms, which are designed to increase the efficiency of the LMS algorithm. In the block LMS algorithm, the filter coefficients are held constant over blocks of length L, which allows for the use of fast convolution algorithm to compute the filter output .The sign algorithm, on the other hand ,achieve their simplicity by replacing e(n) with sgn{e(n)} or x(n) with sgn{x(n)} or both. A lattice filter can be used as an alternative structure for adaptive filter. Due to the orthogonalization of the input process, the gradient adaptive lattice filter converges more rapidly than the LMS adaptive filter and tends to be less sensitive to Eigen value spread in the autocorrelation matrix of x (n).

ALGORITHM

1. 2. 3. 4. 5.

Generate the desired output signal and plot it. Generate noise sequence and plot it. Add the noise to the desired signal and to get the observed signal. Initialize the step size in such a way that the mean square error is minimized. Noise is minimized using the filter coefficient update equation using LMS algorithm.

PROGRAM
clc; clear all; close all; n=0:150; d=sin(.125*pi*n); subplot(2,2,1); plot(n,d); xlabel('n'); ylabel('d(n)'); title('desired signal'); v=.75*rand(size(n)); subplot(2,2,2); plot(n,v); xlabel('n'); ylabel('v(n)'); title('noise signal'); x=sin(.125*pi*n)+.75*rand(size(n)); subplot(2,2,3); plot(n,x); xlabel('n'); ylabel('x(n)'); title('observed signal'); N=21; mu=0.01; M=length(x) y=zeros(1,M) h=zeros(1,N) for n=N:M x1=x(n:-1:n-N+1); y=h*x1' e=d(n)-y; h=h+mu*e*x1; end disp(h); y1=conv(x,h); n1=0:150; y1=y1(:,1:151); subplot(2,2,4); plot(n1,y1); xlabel('n'); ylabel('y(n)'); title('filtered signal');

OUTPUT

RESULT

EX.NO: 2 Date:

RECURSIVE LEAST SQUARES ALGORITHM

AIM:-

To stimulate the MATLAB program for construction of the filters for Recursive least squares algorithm.

SOFTWARE REQUIREMENT: MAT LAB

THEORY:The Recursive least squares (RLS) adaptive filter is an algorithm which recursively finds the filter coefficients that minimize a weighted linear least squares cost function relating to the input signals. This is in contrast to other algorithms such as the least mean squares (LMS) that aim to reduce the mean square error. In the derivation of the RLS, the input signals are considered deterministic, while for the LMS and similar algorithm they are considered stochastic. Compared to most of its competitors, the RLS exhibits extremely fast convergence. However, this benefit comes at the cost of high computational complexity, and potentially poor tracking performance when the filter to be estimated (the "true system") changes

PROCEDURE: Log on to the windows. Open the MATLAB R2008a. In the MATLAB R2008a in the menu bar go to (File ->new-> M-file). Enter the coding for RLS algorithm. After complete the coding go to menu (File ->Save or (Ctrl + s) save the experiment as (Filename.m). Then go to menu bar (Debug -> Run or (f5)) to execute the program. Go the command window in the in the MATLAB and enter the input. If there is any error, get the error code and try to correct the error. If there is no error get the output.

Then the experiment is successfully completed.

BOCK DIAGRAM:-

Output:Figure 1:

SYSTEM OUTPUT

PROGRAM:clear all close all hold off % Number of system points N=2000; inp = randn(N,1); n = randn(N,1); [b,a] = butter(2,0.25); Gz = tf(b,a,-1); sysorder = 10 ; h=[0.097631 0.287310 0.335965 0.220981 0.096354 0.017183 -0.015917 -0.020735 -0.014243 -0.006517 -0.001396 0.000856 0.001272 0.000914 0.000438 0.000108 -0.000044 -0.00008 -0.000058 -0.000029]; h=h(1:sysorder); y = lsim(Gz,inp); %add some noise n = n * std(y)/(10*std(n)); d = y + n; totallength=size(d,1); %Take only 70 points for training ( N - systorder 70 = 80 - 10 ) N=80 ; %begin of the algorithm %forgetting factor lamda = 0.9995 ; %initial P matrix delta = 1e10 ; P = delta * eye (sysorder ) ; w = zeros ( sysorder , 1 ) ; for n = sysorder : N u = inp(n:-1:n-sysorder+1) ; phi = u' * P ; k = phi'/(lamda + phi * u ); y(n)=w' * u; e(n) = d(n) - y(n) ; w = w + k * e(n) ;

10

P = ( P - k * phi ) / lamda ; % Just for plotting Recordedw(1:sysorder,n)=w;

Figure 2:

ERROR CURVE

Figure 3:

COMPARISON OF THE FILTER WEIGHTS AND ESTIMATED WEIGHTS

11

end %check of results for n = N+1 : totallength u = inp(n:-1:n-sysorder+1) ; y(n) = w' * u ; e(n) = d(n) - y(n) ; end hold on plot(d) plot(y,'r'); title('System output') ; xlabel('Samples') ylabel('True and estimated output') figure semilogy((abs(e))) ; title('Error curve') ; xlabel('Samples'); ylabel('Error value'); figure plot(h, 'r+') hold on plot(w, '.')

12

legend('filter weights','Estimated filter weights'); title('Comparison of the filter weights and estimated weights') ; figure plot(Recordedw(1:sysorder,sysorder:N)'); title('Estimated weights convergence') ; xlabel('Samples'); ylabel('Weights value'); axis([1 N-sysorder min(min(Recordedw(1:sysorder,sysorder:N)')) max(max(Recordedw(1:sysorder,sysorder:N)')) ]); hold off

13

14

RESULT:-

15

EX.NO: 3 Date: AIM


To generate linear block code for data transmission and identify the errors in received message.

LINEAR BLOCK CODES

APPARATUS USED/TOOLS REQUIRED


MATLAB 2009 software FORMULA USED: In matrix form, C=UG C: Codeword U: Message vector G: Generator matrix

THEORY
Block coding is a special case of error-control coding. Block coding techniques map a fixed number of message symbols to a fixed number of code symbols. A block coder treats each block of data independently and is a memory less device. The Binary Linear Encoder block creates a binary linear block code using a generator matrix that you specify. If K is the message length of the code, then the Generator matrix parameter must have K rows. If N is the codeword length of the code, then Generator matrix must have N columns.

16

The input must contain exactly K elements. If it is frame-based, then it must be a column vector. The output is a vector of length N. The Binary Linear Decoder block recovers a binary message vector from a binary codeword vector of a linear block code. The input must contain exactly N elements. If it is frame-based, then it must be a column vector. The output is a vector of length K.

17

The decoder tries to correct errors, using the Decoding table parameter. Decoding table must be a 2N-K-by-N binary matrix. The rth row of this matrix is the correction vector for a received binary codeword whose syndrome has decimal integer value r-1. The syndrome of a received codeword is its product with the transpose of the parity-check matrix.

ALGORITHM
1. 2. 3. 4. 5. 6. Initialize code length n and message vector length k Specify the k bit message vectors to be transmitted and the generator matrix of order k*n Encode the message in linear format to get n bit code vector Add a random noise to code vector Decode the noisy code at receiver The message vectors have to be received, displayed and those which are corrupted with noise has to be specified.

PROGRAM
clc; clear all; close all; n=6,k=4 msg=[1 1 0 0;1 1 1 1 ;0 1 1 0] % input message genmat=[1 0 0 0 1 0;0 1 0 0 1 1 ;0 0 1 0 0 1;0 0 0 1 0 0] code=encode(msg,n,k,'linear',genmat) noisycode1=rem(code+randerr(3,6,[0 1]),4) noisycode=sign(noisycode1); [newmsg, err]=decode(noisycode,n,k,'linear',genmat) err_word = find(err~=0)

% generator matrix

18

OUTPUT
n= k= 6 4

msg = 1 1 0 1 1 1 0 1 1 0 1 0

genmat = 1 0 0 0 code = 1 1 0 1 1 1 0 1 1 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 0 0 0 1 1 0

noisycode1 = 1 1 0 1 1 1 0 1 1 0 1 0 0 0 1 1 1 0

newmsg = 1 1 0 err = 1 1 1 0 0 1 0 1 0

19

0 1 0 err_word = 2

RESULT

20

21

EX.NO: 4 Date:

CYCLIC CODES

AIM
To generate a cyclic block code for transmission and to detect the errors in the received message

APPARATUS USED/TOOLS RERQUIRED


MATLAB 2009 Software

THEORY
Block coding is a special case of error-control coding. Block coding techniques map a fixed number of message symbols to a fixed number of code symbols. A block coder treats each block of data independently and is a memory less device. Cyclic codes are subset of linear block codes with additional property that every cyclic shift of a codeword is also a codeword. If X={X1,X2,.Xn)is a codeword ,then the shifted version is X=[Xn,X1,..,X(n-1) ) is also a codeword..They have algebraic properties that allow a polynomial to determine the coding process completely. This so-called generator polynomial is a degree-(n-k) divisor of the polynomial xn-1. The cyclpoly function produces generator polynomials for cyclic codes. Cyclpoly represents a generator polynomial using a row vector that lists the polynomial's coefficients in order of ascending powers of the variable. Cyclic codes are usually easier to encode and decode than all other linear block codes. The encoding operation is performed using shift registers, and decoding is more practical due to the algebraic structure.

ALGORITHM:
1. 2. 3. 4. 5. Initialize cyclic code length n and message vector length k Generate generator polynomial from a cyclic code of length n and message length k. Specify the k bit message vectors to be transmitted Encode the message in cyclic format to get n bit code vector Add a random noise to code vector

22

6. Decode the noisy code at receiver 7. The message vectors have to be received, displayed and those which are corrupted with noise need to be specified.

OUTPUT
n=7 k=3 genpoly = 1 msg = 1 1 0 code = 0 0 1 noise = 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 1 1 1

noisycode = 0 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 1 1 0 1 0

rxmsg = 1 1 1 0 1 1 1 1 0

23

PROGRAM
clc; clear all; close all; n=7; k=3; genpoly = cyclpoly(7,3) % generator polynomial msg=[1 1 0 ;1 1 1 ;0 1 0] % input message code = encode(msg,n,k,'cyclic',genpoly) noise=randerr(3,n,[0,2]) % 3rows n columns of noise matrix noisycode=xor(code,noise) % noise addition [rxmsg,nerr] = decode(noisycode,n,k,'cyclic',genpoly) chk=isequal(noisycode,code); if chk==1 display ('no error in codes'); else display('ther is error in code'); end err_codes = find(nerr~=0)

24

nerr = 2 0 2 There is error in code err_codes = 1 3

25

RESULT

26

EX.NO: 5 Date:

IMPLEMENTATION OF DISCRETE COSINE TRANSFORM

27

AIM
To stimulate the MATLAB program for construction of the discrete cosine transform.

APPARATUS USED/TOOLS RERQUIRED


MATLAB 2009 Software

THEORY
DCT is one of the most frequently used transformations for the image compression. It is obtained by the following , g(x,y,u,v)=h(x,y,u,v) =(u)(v) cos[(2x+1)u/2N]cos[(2y+1)v/2N] where

1 for u = 0 N (u ) = 1 for u = 1,2,3.....N - 1 N 1 for v = 0 ( v) = N 1 for v = 1,2,3.....N - 1 N


the picture were defined (i.e)obtained by diiding the original image into subimage of size 88 representing each subimage using on efo the transforms i.e DCT and DFT truncation 50% of the the resulting coefficient and taking the inverse transform of a coefficient and taking the inverse transform of a truncated coefficient arrays. The transform coefficient masking function is defined as,

28

0 T(u, v) satisfies a specified truncated estimation r(u, v) = otherwise 1

compare to the other input independent transform it has the advantage of having been implemented in a single integrated circuits packing and minimizes the block like appearance boundaries between subimage become visible because the boundary pixels of the subimage assume the mean value of discontinuos this effects,because its implicit 2n input peridiocity doesnt inherent produce boundary discontinuities.

PROCEDURE:-

29

Log on to the windows. Open the MATLAB R2008a. In the MATLAB R2008a in the menu bar go to (File ->new-> M-file). Enter the coding for discrete cosine transform.. After complete the coding go to menu (File ->Save or (Ctrl + s) save the experiment as (Filename.m). Then go to menu bar (Debug -> Run or (f5)) to execute the program. Go the command window in the in the MATLAB and enter the input. If there is any error, get the error code and try to correct the error. If there is no error get the output. Then the experiment is successfully completed

PROGRAM
%Image compression for color images clear all; close all; clc; % Reading an image file [imagefile1 , pathname]= uigetfile('*.bmp;*.BMP;*.tif;*.TIF;*.jpg','Open An image'); if imagefile1 ~= 0 cd(pathname); I=imread(char(imagefile1)); end; X=I; % inputting the decomposition level and name of the wavelet n=input('Enter the decomposition level:');

OUTPUT:Figure 1:- DECOMPOSITION LEVEL 4

30

wname = 'haar'; x = double(X); TotalColors = 255; map = gray(TotalColors); x = uint8(x);

31

%Conversion of RGB to Grayscale x = double(X); xrgb = 0.2990*x(:,:,1) + 0.5870*x(:,:,2) + 0.1140*x(:,:,3); colors = 255; x = wcodemat(xrgb,colors); map = pink(colors); x = uint8(x); % A wavelet decomposition of the image [c,s] = wavedec2(x,n,wname); % wdcbm2 for selecting level dependent thresholds alpha = 1.5; m = 2.7*prod(s(1,:)); [thr,nkeep] = wdcbm2(c,s,alpha,m) % Compression [xd,cxd,sxd,perf0,perfl2] = wdencmp('lvd',c,s,wname,n,thr,'h'); disp('Compression Ratio'); disp(perf0); % Decompression R = waverec2(c,s,wname); rc = uint8(R); % Plot original and compressed images. subplot(221), image(x); colormap(map); title('Original image') subplot(222), image(xd); colormap(map); title('Compressed image') % Displaying the results xlab1 = ['2-norm rec.: ',num2str(perfl2)]; xlab2 = [' % -- zero cfs: ',num2str(perf0), ' %']; xlabel([xlab1 xlab2]); subplot(223), image(rc); colormap(map); title('Reconstructed image');

Figure 2:- OUTPUT

OF DISCRETE COSINE TRANSFORM

32

33

RESULT:-

34

EX.NO: 6

M-ary PHASE SHIFT KEYING

35

Date: AIM
To obtain bit error performance curve for M-ary PSK for various values of M.

APPARATUS USED/TOOLS REQUIRED


MATLAB 2009 software

THEORY
Phase Shift Keying (PSK) is a method of digital communication in which the phase of a transmitted signal is varied to convey information. In M-ary or Multiple Phase Shift Keying (MPSK), there are more than two phases, usually four (0,+90,-90 and 180 degrees) or eight (0,+45,-45,+90,-90,+135 and 180 degrees) . If there are four phases (m=4), the MPSK mode is called Quadrature Phase-Shift Keying. Multi-level modulation techniques permit high data rates within fixed bandwidth constraints. A convenient set of signals for M-ary PSK is,
i

(t) = A

t+ i)

0<t Ts

=0, ,

,2(M-1) /M

M number of Phase Angles. The symbol duration Ts , so the information rate Tb satisfies, Ts =Tblog2M The potential bandwidth efficiency of M-ary PSK can be shown to be,
b

= log2 M bps/Hz.

ALGORITHM
1. Initialize various values of M for which error performance has to be plotted. 2. Define the range of SNR required in performance curve.

36

3. Initialize an array variable err with zeros to store BER of corresponding SNR. a) In a loop for each values of M, proceed till the end of step.

OUTPUT

37

b) In a loop for each values of SNR proceed till end of step. c) Initialize a random input to x. d) PSK modulate the random input data e) Pass the modulated signal through Gaussian noise channel. f) Demodulate the received signal. g) Calculate BER for each SNR and arr 4. Plot the graph with SNR along X axis and BER along y axis.

PROGRAM
clc; clear all; close all; M=[4 8 16]; snr=-25:25; err=zeros(1,length(snr)); for i=1:3 for j=1:length(snr) x=randsrc(1,20000,[0,M(i)-1]); msg_tx=pskmod(x,M(i)); msg_nois = awgn(msg_tx,snr(j),... 'measured'); msg_rx=pskdemod(msg_nois,M(i)); display(msg_rx); [num,BER]=biterr(x,msg_rx); err(i,j)=BER; end end semilogy(snr(1,:),err(1,:),'r',snr(1,:),err(2,:),'k',snr(1,:),err(3,:),'b'); xlabel('snr'); ylabel('BER');

38

39

RESULT

40

EX.NO: 7 Date:

M-ary FREQUENCY SHIFT KEYING

41

AIM
To obtain bit error performance curve for M-ary FSK for various values of M.

APPARATUS USED/TOOLS REQUIRED


MATLAB 2009 software

THEORY
In Binary Frequency-Shift Keying (BFSK) carrier is shifted between two frequencies. A convenient way of trading bandwidth for signaling speed is to increase the spread between the lowest and highest frequency (increasing the bandwidth) but to increase the signaling speed by extending the number of frequencies to a number M. Such a system is called an M-ary frequency shift keying system. The transmitted signals are defined by,

Si(t) =

cos 2 [fo + (i-1)

]t

0 t T , i=1,2,.,M

min

=1/2T is the minimum frequency spacing such that adjacent signals are orthogonal.

ALGORITHM
1. Initialize various values of M for which error performance has to be plotted. 2. Define the range of SNR required in performance curve. 3. Initialize an array variable err with zeros to store BER of corresponding SNR. a) In a loop for each values of M, proceed till the end of step. b) In a loop for each values of SNR proceed till end of step. c) Initialize a random input to x. d) FSK modulate the random input data. e) Pass the modulated signal through Gaussian noise channel. f) Demodulate the received signal. g) Calculate BER for each SNR and arr. 4. Plot the graph with SNR along X axis and BER along y axis.

OUTPUT

42

PROGRAM
clc;

43

close all; clear all; m=[4 8 16] fs=64 freqsep=4; nsamp=8; snr=-25:25; err=zeros(1,length(snr)); for i=1:3 for j=1:length(snr) x=randsrc(1,20000,[0,m(i)-1]); msg_tx=fskmod(x,m(i),freqsep,nsamp,fs); msg_noise=awgn(msg_tx,snr(j),'measured'); msg_rx=fskdemod(msg_noise,m(i),freqsep,nsamp,fs); [num,BER]=biterr(x,msg_rx); err(i,j)=BER; end end

44

45

RESULT

46

EX.NO: 8 Date: AIM

M-ary QUADRATURE AMPLITUDE MODULATION

To obtain bit error performance curve for M-ary QAM for various values of M.

47

APPARATUS USED/TOOLS REQUIRED


MATLAB 2009 software

THEORY
By allowing the amplitude to vary along with the phase, a new modulation scheme called Quadrature Amplitude Modulation (QAM) is obtained. The general form of an M-ary QAM signal can be defined as,

Si(t) =

ai cos(2

t) +

bi sin(2

t)

0 t T, i=1, 2,., M Where, Emin is the energy of the signal with lowest amplitude, a i and bi are integers chosen according to the location of the particular signal point.

M-ary QAM does not have constant energy per symbol; nor does it have constant distance between possible symbol states. The power spectrum and bandwidth efficiency of QAM modulation is identical to M-ary PSK Modulation. But in terms of power efficiency, QAM is superior to M-ary PSK.

ALGORITHM
1. Initialize various values of M for which error performance has to be plotted. 2. Define the range of SNR required in performance curve. 3. Initialize an array variable err with zeros to store BER of corresponding SNR. a) In a loop for each values of M, proceed till the end of step. b) In a loop for each values of SNR proceed till end of step. c) Initialize a random input to x. d) QAM modulate the random input data.

OUTPUT

48

e) Pass the modulated signal through Gaussian noise channel. f) Demodulate the received signal. g) Calculate BER for each SNR and arr. 4. Plot the graph with SNR along X axis and BER along y axis.

49

PROGRAM
clc; clear all; close all; M=[4 8 16]; snr=-25:25; err=zeros(1,length(snr)); for i=1:3 for j=1:length(snr) x=randsrc(1,20000,[0,M(i)-1]); msg_tx=qammod(x,M(i)); msg_nois = awgn(msg_tx,snr(j),'measured'); msg_rx=qamdemod(msg_nois,M(i)); display(msg_rx); [num,BER]=biterr(x,msg_rx); err(i,j)=BER; end end semilogy(snr(1,:),err(1,:),'r',snr(1,:),err(2,:),'k',snr(1,:),err(3,:),'b'); xlabel('snr'); ylabel('BER');

50

51

RESULT

52

EX.NO: 9 Date:

ANTENNA RADIATION PATTERN

AIM
To plot the radiation pattern and find out the gain of a waveguide antenna.

53

COMPONENTS REQUIRED
1. 2. 3. 4. 5. 6. Microwave source(Klystron) with power supply Frequency meter Isolator Variable attenuator Detector mount antenna SWR meter and accessories

THEORY
If a transmission line propagating energy is left open at one end, there will be radiation from this end. In case of a rectangular wave-guide, this presents a mismatch of about 2:1 and it radiates in many directions. The match will improve if the open wave-guide is a horn-shape. The radiation pattern of an antenna is a diagram of field strength or more often the power intensity as a function of the aspect angle at a constant distance from the radiating antenna. An antenna pattern is of course three dimensional but for practical reasons, it is normally presented as a two dimensional pattern in one or several planes. An antenna pattern consists of several lobes, the main lobe, side lobes and the back lobe. The major power is concentrated in the main lobe and it is required to keep the power in the side lobes and the back lobe as low as possible. The power intensity at the maximum of the main lobe compared to the power intensity achieved from an imaginary Omni-directional antenna (radiating equally in all directions) with the same power fed to the antenna is defined as gain of the antenna.

3dB BEAM WIDTH: This is the angle between the two points on a main lobe where the power intensity is half the maximum power intensity. When measuring an antenna pattern, it is normally most interesting to plot the pattern far from the antenna.

SETUP FOR THE ANTENNA RADIATION PATTERN PLOTTING

VARAIBLE ATTENUATOR

POWER SUPPLY

54

MICROWAVE SOURCE

ISOLATOR

FREQUENCY METER

DETECTOR MOUNT

SWR METER

CRO

TABULATION
S.No Degree Frequency(in GHz) VSWR GAIN(in dB)

Far field pattern is achieved at a minimum distance of 2D2/0(for rectangular horn antenna) Where, D is the size of the broad wall of horn aperture, 0 is the free space wavelength.

PROCEDURE
ANTENNA RADIATION PATTERN PLOTTING:

55

1. Set up the equipments as shown in the figure, keeping the axis of both antennas in same axis line & for start connect the horn antennas at both the ends. 2. Energize the microwave source for maximum output at desired frequency with square wave modulation by tuning square wave amplitude and frequency of modulating signal of Klystron Power Supply and by tuning the detector. 3. Obtain maximum reading (0 dB) at any convenient range switch position of the SWR meter by gain control knob of SWR meter or by variable attenuator. 4. Rotate the receiving horn in 2 or 5steps and note the corresponding dB reading. When necessary change the range switches to next higher range and add 10dB to the observed value. 5. Draw a radiation pattern. 6. Now replace the antenna by another given antenna at receiver position. 7. From polar plot, determine the 3dB beam width of the horn antenna.

CALCULATION:

56

57

RESULT

58

EX.NO: 10 Date: AIM

ORTHOGONAL FREQUENCY DIVISION MULTIPLEXING

To simulate the MATLAB program for construction of the OFDM signal.

59

SOFTWARE REQUIREMENTS
MATLAB 2009 Software

THEORY
OFDM belongs to a family of transmission schemes called multicarrier modulation, which is based on the idea of dividing a given high-bit-rate data stream into several parallel lower bitrate streams and modulating each stream on separate carriers-often called subcarriers, or tones. Orthogonal frequency-division multiplexing (OFDM) is a method of encoding digital data on multiple carrier frequencies. OFDM has developed into a popular scheme for wideband digital communication.

ALGORITHM
1. Assign QPSK signal constellation, m as 4, data points as 64 and OFDM block size as 8. 2. In the Transmitter Side, a) Obtain the data source using m and data points. b) Perform QPSK Modulation on the data source. c) Reshape the modulated data into matrix form. d) Perform IFFT on the obtained data matrix. e) For each value of i from 1 to length of cyclic prefix, append the cyclic prefix. f) Reconvert the appended matrix to data signal. g) Combine the Noise with the data signal and transmit it to the receiver/destination. 3. In the Receiver Side, a) Filter the received OFDM signal. b) Reconstruct the processed signal into matrix form. c) Remove the appended cyclic prefix. d) Perform FFT on the obtained matrix. e) Reshape the matrix into signal form. f) Perform the PSK demodulation on the reconstructed signal and retrieve the original message.

BLOCK DIAGRAM
Binar y Input data Binar y outp ut data Channe l correcti on

RF TX

DAC
paralle l to

Coding

Interleav ing

QPSK mappin g

Pilot insertio n

serial to Paralle l

IFFT (TX) FFT (RX)

serial

Add cyclic extension and windowin g Remove cyclic extension Frequenc y corrected Timing signal and frequency synchroniza

Decodi ng

Deinterlea ving

QPSK demappi ng

paralle l to serial

serial to Paralle l

Symbol timing

RF RX

ADC

60

PROGRAM
clear all; clc; close all; M = 4; % QPSK signal constellation no_of_data_points = 64; % have 64 data points block_size = 8; % size of each ofdm block cp_len = ceil(0.1*block_size); % length of cyclic prefix

61

no_of_ifft_points = block_size; no_of_fft_points = block_size;

% 8 points for the FFT/IFFT

% TRANSMITTER +++++ data_source = randsrc(1, no_of_data_points, 0:M-1); figure(1) stem(data_source); grid on; xlabel('Data Points'); ylabel('Amplitude') title('Transmitted Data "O"') % 2. Perform QPSK modulation qpsk_modulated_data = pskmod(data_source, M); scatterplot(qpsk_modulated_data);title('MODULATED TRANSMITTED DATA'); num_cols=length(qpsk_modulated_data)/block_size; data_matrix = reshape(qpsk_modulated_data, block_size, num_cols); % Second: Create empty matix to put the IFFT'd data cp_start = block_size-cp_len; cp_end = block_size; % Third: Operate columnwise & do CP for i=1:num_cols, ifft_data_matrix(:,i) = ifft((data_matrix(:,i)),no_of_ifft_points); % Compute and append Cyclic Prefix for j=1:cp_len, actual_cp(j,i) = ifft_data_matrix(j+cp_start,i); end % Append the CP to the existing block to create the actual OFDM block ifft_data(:,i) = vertcat(actual_cp(:,i),ifft_data_matrix(:,i)); end % 4. Convert to serial stream for transmission [rows_ifft_data cols_ifft_data]=size(ifft_data); len_ofdm_data = rows_ifft_data*cols_ifft_data;

OUTPUT

62

% Actual OFDM signal to be transmitted ofdm_signal = reshape(ifft_data, 1, len_ofdm_data); figure(3)

63

plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude'); title('OFDM Signal');grid on; % C: HPA +++++ % 1. Generate random complex noise noise = randn(1,len_ofdm_data) + sqrt(-1)*randn(1,len_ofdm_data); % 2. Transmitted OFDM signal after passing through HPA avg=0.4; for i=1:length(ofdm_signal) if ofdm_signal(i) > avg ofdm_signal(i) = ofdm_signal(i)+noise(i); end if ofdm_signal(i) < -avg ofdm_signal(i) = ofdm_signal(i)+noise(i); end end figure(4) plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude'); title('OFDM Signal after HPA');grid on; % D: CHANNEL channel = randn(1,block_size) + sqrt(-1)*randn(1,block_size); % E: RECEIVER +++++ % 1. Pass the ofdm signal through the channel after_channel = filter(channel, 1, ofdm_signal); % 2. Add Noise awgn_noise = awgn(zeros(1,length(after_channel)),0); % 3. Add noise to signal... recvd_signal = awgn_noise+after_channel; % 4. Convert Data back to "parallel" form to perform FFT recvd_signal_matrix = reshape(recvd_signal,rows_ifft_data, cols_ifft_data); % 5. Remove CP recvd_signal_matrix(1:cp_len,:)=[]; % 6. Perform FFT for i=1:cols_ifft_data, % FFT fft_data_matrix(:,i) = fft(recvd_signal_matrix(:,i),no_of_fft_points); end % 7. Convert to serial stream recvd_serial_data = reshape(fft_data_matrix, 1,(block_size*num_cols)); scatterplot(recvd_serial_data);title('MODULATED RECEIVED DATA');

64

% 8. Demodulate the data qpsk_demodulated_data = pskdemod(recvd_serial_data,M); scatterplot(recvd_serial_data);title('MODULATED RECEIVED DATA'); figure(5) stem(qpsk_demodulated_data,'rx'); grid on;xlabel('Data Points');ylabel('Amplitude');title('Received Data "X"')

65

66

67

RESULT

68

EX.NO: 11 Date:

ANALOG DATA TRANSMISSION THROUGH FIBER

69

OPTIC LINK
AIM
To setup fiber optic analog link and to study the relationship between the input signal and received signal.

COMPONENTS REQUIRED
1. Fiber optic trainer kit 2. Fiber optic cable 3. Probe 4. CRO

THEORY
Fiber optic links can be used for transmission of digital as well as analog signals. Basically a fiber optic link contains three elements, a transmitter, an optical fiber and a receiver. The transmitter module takes the input signal in electric form and then transforms it into optical energy containing the same information. The optical fiber is the medium which takes the energy to the receiver. At the receiver, light is coming back into electrical form with the same pattern as originally fed to the transmitter. TRANSMITTER Fiber optic transmitters are typically composed of a buffer, driver and optical source. The buffer provides both an electrical connection and isolation between the transmitter & the electrical system supplying the data. The driver provides electrical power to the optical source. Finally, the optical source converts the electrical current to the light energy with the same pattern. Commonly used optical source are light emitting diodes (LEDs) and beam. Simple LED circuits, for digital and analog transmissions are shown below. Figure shows transconductance drive circuits for analog transmission-common emitter configuration. The transmitter section comprises of: 1. Function generator 2. Frequency modulator & 3. Pulse Width Modulator block.

70

BLOCK DIAGRAM OF FIBER OPTIC ANALOG LINK

Fiber optic cable


Functio n generat or Emitter circuit Detector circuit

AC Amplifi er Circuit

The function generator generates the input signals that are going to be used as information to transmit through the fiber optic link. The output voltage available is 1 KHz sinusoidal signal of adjustable amplitude and fixed amplitude 1 KHz square wave signal. The

71

modulator section accepts the information signal and converts it into suitable form for transmission through the fiber optic link. THE FIBER OPTIC LINK The emitter and detector circuit on board form the fiber optic link. This section provides the light source for the optic fiber and the light detector at the far field of the fiber optic links. The optic fiber plugs into the connectors provided in this part of the board. THE RECEIVER: The comparator circuit, low pass filter, phase locked loop, AC amplifier circuits form receiver on the board. It is able to undo the modulation process in order to recover the original information signal. In this experiment, the trainer board is used to illustrate one way communication between digital transmitter and receiver circuits.

PROCEDURE
1. Connect the power supply to the board.

2. Ensure that all switched faults are OFF. 3. Make the following connections: a) Connect the 1 KHz sine wave output to emitter 1s input. b) Connect the fiber optics cable between emitter output and detectors input. c) Detector 1s output to amplifier 1 input. 4. On the board, switch emitter 1s driver to analog mode. 5. Switch on the power. 6. Observe the input to emitter 1 with the output from AC amplifier 1 and note that the two signals are same.

TABULATION:-

72

S. No 1 2

Wave form Analog Analog

Transmitter/receiver Transmitted data Received data

Amplitude (V)

73

RESULT

74

EX.NO: 12 Date: AIM

DIGITAL DATA TRANSMISSION THROUGH FIBER OPTIC LINK

75

To setup fiber optic digital link and to study the relationship between the input and received signal.

COMPONENTS REQUIRED
1. Fiber optic trainer kit 2. Fiber optic cable 3. Probe 4. CRO

PROCEDURE
1. Connect the power supply to the board. 2. Ensure that all switched faults are OFF. 3. Make the following connections: a. Connect the 1 KHz square wave output to emitter 1s input. b. Connect the fiber optic cable between emitter output and detectors input. c. Detector 1s output to comparator 1s input. d. Comparator 1s output to AC amplifier 1s input. 4. On the board, switch emitter 1s driver to digital mode. 5. Switch on the power. 6. Monitor both the inputs to comparator 1. Slowly adjust the comparators bias preset, until DC level on the input lies midway between the high and low level of the signal on the positive input. 7. Observe the input to emitter 1 with the output from AC amplifier 1 and note that the two signals are same.

76

BLOCK DIAGRAM OF A FIBER OPTICAL DIGITAL LINK

Fiber optic cable


Functi on genera tor Emitter circuit Detector circuit Compara tor circuits

AC Amplifi er Circuit

TABULATION:-

S. No 1 2

Wave form Analog Digital

Transmitter/receiver Transmitted data Received data

Amplitude (V)

77

78

RESULT

Você também pode gostar