You are on page 1of 38

LABORATORY MANUAL

ECE 303 and ECE353 Unified Electronics Lab-III

S.No

Name of the Experiments MATLAB

Sr no

1. 2. 3. 4. 5.

To develop program for designing an FIR and IIR filter

To develop a program for Computing discrete Convolution and Correlation 10 To develop a program for Computing Circular Convolution To develop a program for Computing DFT and IDFT in MATLAB To develop a program for Computing Inverse Z-Transform BREAD BOARD 13

6.

To design and implement on a breadboard a circuit to perform Amplitude Modulation. MTE

7.

To design and implement on a breadboard a circuit to perform Frequency Modulation. Compile, Elaborate, and Simulate a 2-to-1 mux Design using Incisive Simulator MICROPROCESSOR

8.

9. 10. 11.

Interfacing and control of stepper motor using 8085 microprocessor. Generation of delay in binary counting using 8085 microprocessor. To implement a moving 7-segment display with suitable delay using 8085 microprocessor. Write a program to interface two digit numbers using seven Segment LEDs, use 8086 microprocessor and 8255 PPI.

12.

FIR filters AIM: To verify FIR filters. EQUIPMENTS: Constructor MATLAB Software THEORY: A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is based on the weighted summation of a finite number of past inputs. An FIR transversal filter structure can be obtained directly from the equation for discrete-time convolution.

In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is the transversal filter coefficients at time n. These coefficients are generated by using FDS (Filter Design Software or Digital filter design package). FIR filter is a finite impulse response filter. Order of the filter should be specified. Infinite response is truncated to get finite impulse response. placing a window of finite length does this. Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter. PROGRAM: %fir filt design window techniques clc; clear all; close all; rp=input('enter passband ripple'); rs=input('enter the stopband ripple'); fp=input('enter passband freq'); fs=input('enter stopband freq'); f=input('enter sampling freq '); wp=2*fp/f; ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0) n1=n; n=n-1; end c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');
3

if(c==1) y=rectwin(n1); disp('Rectangular window filter response'); end if (c==2) y=triang(n1); disp('Triangular window filter response'); end if(c==3) y=kaiser(n1); disp('kaiser window filter response'); end %LPF b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); title('LPF'); ylabel('Gain in dB-->'); xlabel('(a) Normalized frequency-->'); %HPF b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); title('HPF'); ylabel('Gain in dB-->'); xlabel('(b) Normalized frequency-->'); %BPF wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); title('BPF'); ylabel('Gain in dB-->'); xlabel('(c) Normalized frequency-->'); %BSF b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4);plot(o/pi,m); title('BSF'); ylabel('Gain in dB-->'); xlabel('(d) Normalized frequency-->')
4

RESULTS:

IIR filters AIM: To design and implement IIR (LPF/HPF)filters. EQUIPMENTS: Software - MATLAB THEORY: The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer function, described by polynomials in z in both the numerator and the denominator:

The difference equation for such a system is described by the following:

M and N are order of the two polynomials. bk and ak are the filter coefficients. These filter coefficients are generated using FDS (Filter Design software or Digital Filter design package). IIR filters can be expanded as infinite impulse response filters. In designing IIR filters, cutoff frequencies of the filters should be mentioned. The order of the filter can be estimated using butter worth polynomial. Thats why the filters are named as butter worth filters. Filter coefficients can be found and the response can be plotted. PROGRAM: % IIR filters LPF & HPF clc;clear all;close all; disp('enter the IIR filter design specifications'); rp=input('enter the passband ripple'); rs=input('enter the stopband ripple'); wp=input('enter the passband freq'); ws=input('enter the stopband freq'); fs=input('enter the sampling freq'); w1=2*wp/fs;w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs,'s'); c=input('enter choice of filter 1. LPF 2. HPF \n '); if(c==1) disp('Frequency response of IIR LPF is:'); [b,a]=butter(n,wn,'low','s'); end
7

if(c==2) disp('Frequency response of IIR HPF is:'); [b,a]=butter(n,wn,'high','s'); end w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); figure,subplot(2,1,1);plot(om/pi,m); title('magnitude response of IIR filter is:'); xlabel('(a) Normalized freq. -->'); ylabel('Gain in dB-->'); subplot(2,1,2);plot(om/pi,an); title('phase response of IIR filter is:'); xlabel('(b) Normalized freq. -->'); ylabel('Phase in radians-->'); RESULTS:

LINEAR CONVOLUTION AND CORRELATION AIM: To verify Linear Convolution. EQUIPMENTS: Software -- MATLAB 7.5 THEORY: Convolution is a formal mathematical operation, just as multiplication, addition, and integration. Addition takes twonumbers and produces a thirdnumber, while convolution takes twosignals and produces a thirdsignal. Convolution is used in the mathematics of many fields, such as probability and statistics. In linear systems, convolution is used to describe the relationship between three signals of interest: the input signal, the impulse response, and the output signal.

In this equation, x1(k), x2(n-k) and y(n) represent the input to and output from the system at time n. Here we could see that one of the input is shifted in time by a value every time it is multiplied with the other input signal. Linear Convolution is quite often used as a method of implementing filters of various types. ALGORITHM: 1. 2. 3. 4. 5. 6. Enter the input Sequence ,x having length=4 Enter the Impulse Sequence, h having length=4 Performing the Convolution, store the value in y Plotting the Input Sequence. Plotting the Impulse Sequence. Plotting the Output Sequence.

PROGRAM: %linear convolution program clc; clear all; close all; disp('linear convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p h(n):'); n=length(h); x=[x,zeros(1,n)]; subplot(2,2,1), stem(x);
10

title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; h=[h,zeros(1,m)]; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('convolution of x(n) & h(n) is y(n):'); y=zeros(1,m+n-1); for i=1:m+n-1 y(i)=0; for j=1:m+n-1 if(j<i+1) y(i)=y(i)+x(j)*h(i-j+1); end end end y subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is :'); xlabel('---->n'); ylabel('---->y(n)');grid; RESULT:

11

%program for discrete Correlation x=[1 2 3 4]; y=[2 3 4 5]; z=xcorr(x,y); stem(z); subplot(2,2,1),stem(x) title(input sequence 1) subplot(2,2,2),stem(y) title(input sequence 2) subplot(2,2,3),stem(z) title(output sequence) ALGORITHM: 1 Enter the input Sequence ,x having length=4 2 Enter the Impulse Sequence, y having length=4 3 Performing the Correlation, store the value in y 4 Plotting the Output Sequence ,store in z. RESULT:
input sequence 1 4 3 2 1 0 2 6 input sequence 2

output sequence 40 30 20 10 0

12

CIRCULAR CONVOLUTION AIM: To verify Circular Convolution. EQUIPMENTS: Software - MATLAB 7.5 THEORY: Circular convolution is another way of finding the convolution sum of two input signals. It resembles the linear convolution, except that the sample values of one of the input signals is folded and right shifted before the convolution sum is found. Also note that circular convolution could also be found by taking the DFT of the two input signals and finding the product of the two frequency domain signals. The Inverse DFT of the product would give the output of the signal in the time domain which is the circular convolution output. The two input signals could have been of varying sample lengths. But we take the DFT of higher point, which ever signals levels to. For eg. If one of the signal is of length 256 and the other spans 51 samples, then we could only take 256 point DFT. So the output of IDFT would be containing 256 samples instead of 306 samples, which follows N1+N2 1 where N1 & N2 are the lengths 256 and 51 respectively of the two inputs. Thus the output which should have been 306 samples long is fitted into 256 samples. The 256 points end up being a distorted version of the correct signal. This process is called circular convolution. PROGRAM:
%circular convolution program clc;clear all;close all; disp('circular convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p sequence h(n)'); n=length(h); subplot(2,2,1), stem(x); title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('circular convolution of x(n) & h(n) is y(n):'); if(m-n~=0) if(m>n) h=[h,zeros(1,m-n)]; n=m; end

13

x=[x,zeros(1,n-m)]; m=n; end y=zeros(1,n); y(1)=0; a(1)=h(1); for j=2:n a(j)=h(n-j+2); end %ciruclar conv for i=1:n y(1)=y(1)+x(i)*a(i); end for k=2:n y(k)=0; % circular shift for j=2:n x2(j)=a(j-1); end x2(1)=a(n); for i=1:n if(i<n+1) a(i)=x2(i); y(k)=y(k)+x(i)*a(i); end end end y subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is:'); xlabel('---->n'); ylabel('---->y(n)');grid;

RESULT:

14

DFT AND IDFT AIM: To develop a program for Computing DFT and IDFT in MATLAB REQUIREMENTS: MATLAB 7.5 THEORY: The discrete Fourier transform (DFT) X[k] of a finite-length sequence x[n] can be easily computed in MATLAB using the function fft. There are two versions of this function. fft(x) computes the DFT X[k] of the sequence x[n] where the length of X[k] is the same as that of x[n]. fft(x,L) computes the L-point DFT of a sequence x[n] of lengthN where L N. IfL > N, x[n] is zero-padded with LN trailing zero-valued samples before the DFT is computed. The inverse discrete Fourier transform (IDFT) x[n] of a DFT sequence X[k] can likewise be computed using the function ifft, which also has two versions. PROGRAM CODE:
% Program to perform Discrete Fourier Transform clc;clear all; close all hidden; x=input('The given sequence is x(n): '); N=length(x); for k=1:N X(k)=0; for n=1:N X(k)=X(k)+x(n).*exp(-j.*2.*pi.*(n-1).*(k-1)./N); end

15

end display('The DFT of the given sequence is:') X p=0:(N-1); stem(p,abs(X)),grid

Input Sequence:-

ALGORITHM: 1 Enter the input Sequence ,x having length=4 2 Set the range of k according to the length of x. 3 Computing DFT, store the value in X(k). 4 Plotting the DFT of given Sequence,store in X(k). RESULT:
20 18 16 14 12 10 8 6 4 2 0

0.5

1.5

2.5

Fig shows DFT of input sequence


% Program to perform Inverse Discrete Fourier Transform clc;clear all; close all hidden; x=input('The given sequence is x(n): '); N=length(x); for k=1:N X(k)=0; for n=1:N

16

X(k)=X(k)+x(n).*exp(j.*2.*pi.*(n-1).*(k-1)./N); end end display('The DFT of the given sequence is:') X p=0:(N-1); stem(p,abs(X)),grid

Input Sequence:

ALGORITHM: 1 Enter the input Sequence, x having length=4 2 Set the range of k according to the length of x. 3 Computing IDFT, store the value in X(k). 4 Plotting the IDFT of given Sequence, store in X(k). RESULT:
10 9 8 7 6 5 4 3 2 1 0

0.5

1.5

2.5

Fig shows IDFT of input sequence

17

INVERSE Z TRANSFORM AIM: To develop a program for Computing Inverse Z-Transform EQUIPMENTS: MATLAB 7.5 THEORY: Description: In mathematics and signal processing, the Z-transform converts a discrete time-domain signal, which is a sequence of real or complex numbers, into a complex frequencydomain representation. The Z-transform, like many other integral transforms, can be defined as either a one-sided or two-sided transform. The bilateral or two-sided Z-transform of a discrete-time signal x[n] is the function X(z) defined as

. Alternatively, in cases where x[n] is defined only for n 0, the single-sided or unilateral Z-transform is defined as

In signal processing, this definition is used when the signal is causal. Rational Z-transform to partial fraction form: Consider the transfer function in the rational form i-e;
18

18z3 G(z)= -----------------18z3+3z2-4z-1 We can evaluate the partial fraction form of the above system using matlab command. The partial fraction form be, G(z)= 0.36__ + __0.24__ + _0.4____ 1 0.5z-1 1+0.33 z-1 (1+0.33 z-1) Matlab command that converts rational z-transform in to partial fraction form is residuez. If you want to see the poles and zeros in a zplane. This function displays the poles and zeros of discrete-time systems. Use the under given matlab command zplane(b,a) PROGRAM CODE:
%program to perform Inverse Z-Transform b=[1,0.4*sqrt(2)]; a=[1,-0.8*sqrt(2),0.64]; [R,P,C]=residuez(b,a); m=abs(P'); subplot(1,2,1); plot(m); title('magnitude'); A=angle(P')/pi; subplot(1,2,2); plot(A); title('Angle'); freqz(a,b,10)

ALGORITHM: 1. Write the poles and zeros of the input sequence. 2. Returned vector R contains the residues,Column vector contains P contains the pole locations. And row vector contains the direct terms. 3. Plot the pole magnitudes. 4. Plot the pole angles in pi units. 5. Plot the frequency response of given z-transform of the given function. Input Sequence:

RESULT: MAGNITUDE AND ANGLE:-

19

20
magnitude
Magnitude (dB)

Angle 0.25 0.2

10 0

1.5

0.15 0.1

-10 -20

0.1

0.2

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample)

0.9

0.05 0

150
Phase (degrees)

0.5

-0.05 -0.1

100
0

50

-0.15 -0.2

0.1

0.2

0.3 0.4 0.5 0.6 0.7 0.8 Normalized Frequency ( rad/sample)

0.9

-0.5

1.5

-0.25

1.5

Experiment no 6 AIM : To design and implement on a breadboard a circuit to perform Amplitude modulation. APPARATUS: Two IC BC 107BP,33k, 100k,two 4.7k,270ohm resistor, two 4.7F capacitor, CRO(20 Mhz),Function generator(1Mhz),connecting wires and probes.

20

PROCEDURE:1. Connect the circuit as per the given circuit diagram. 2. Apply fixed frequency carrier signal to carrier input terminals. 3. Apply modulating signal from function generator of 1VP-P of 500Hz. 4. Note down and trace the modulated signal envelop on the CRO screen. 5. Find the modulation index by measuring Vmax and Vmin from the modulated (detected/ traced) envelope. M=(Vmax Vmin)/(Vmax+Vmin) 6. Repeat the steps 3,4 & 5 by changing the frequency or/& amplitude of the modulating signal so as to observe over modulation, under modulating and perfect modulation. 7. For demodulation, apply the modulated signal (A.M) as an input to the demodulator and verify the demodulated output with respect to the applied modulating signals and their respective outputs.

21

Observed m= (Vmax + V min) / (V max V min )


22

ERROR ANALYSIS: Calculate Modulation index using mathematical formula mc = Vm/Vc. %AGE ERROR = ((m mc)/ mc)x100% RESULT:

23

Experiment no 7 AIM : To design and implement on a breadboard a circuit to perform Frequency modulation. APPARATUS: IC LM 2206,10k, two 100k,three 4.7k,220ohm resistor,22F,1F,10F,0.01F, CRO(20 Mhz),Function generator(1Mhz),connecting wires and probes. CIRCUIT DIAGRAM:

1. Connect the circuit as per the given circuit diagram. 2. 2. Apply the modulating signal of 500HZ with 1Vp-p. 3. Trace the modulated wave on the C.R.O & plot the same on graph. 4. Find the modulation index by measuring minimum and maximum frequency deviations from the carrier frequency using the CRO. M = S/f = maximum Frequency deviation / modulating signal frequency 5. Repeat the steps 3& 4 by changing the amplitude and /or frequency of the modulating Signal.

EXPECTED WAVEFORMS

24

OBSERVATION TABLE Formula used: m f = / f m where = k Vm fc K is the proportionality constant

25

Find the average m f. Calculated mf = kVm fc /fm mf min = mf max = mf avg cal = %age error = ((Calculated mf - observed mf ) / Calculated mf )x100%

26

Result Experiment no.-8


AIM: Compile, Elaborate, and Simulate a 2-to-1 mux Design using Incisive Simulator. Equipment: CADENCE Incisive Simulator Theory: Incisive Simulator is created for verification teams developing complex system-level environments, Cadence Incisive Enterprise Simulator simplifies and accelerates your workflow. Its blend of leading-edge process automation technology, high-performance engines, power analysis, and advanced debug capabilitiesintegrated with the Incisive platformhelps you verify the most complex chips and systems. With support for all IEEE-standard languages, Si2s Common Power Format, and the comprehensive Plan-to-Closure Methodology, Incisive Enterprise Simulator improves productivity, project predictability, and product quality, helping you take the risk out of verification.
Flow Chart:

INCISIVE ENTERPRISE SIMULATOR: Incisive Enterprise Simulator is the only product on the market that supports all IEEE-standard languages and design abstractions, from the gate level all the way up to system modeling and verification. Additionally it supports the verification plan (v-Plan) executable specification, Si2s Common Power Format (CPF) specification, and all Plan-to-Closure Methodology flows. Verification engineers can extend the functionality of Enterprise Simulator with Incisive Software Extensions that provide a high-throughput channel between the test-bench and the device under test (DUT), and enables automated Plan-to-Closure verification of embedded software exactly as if it were another part of the DUT. With other elements from the Incisive platform, including verification IP, hardware acceleration and emulation, analog/mixed-signal/RF verification, and formal assertion verification, Enterprise Simulator supports any test-bench, HDL, CPF file, software, and assertion IP created with the Incisive platforms other simulators: the HDL Simulator and the Design Team Simulator; or vPlans created by Enterprise Manager.

27

Experiment -8
AIM Interfacing 8x8 keyboard using 8085 microprocessor. Apparatus required Push Switches (64) SAMPLE PROGRAM: Block Diagram

28

Source program MVI A, 90H : Initialize Port A as input and OUT CR : Port B as Output START: MVI A, 00 : Make all scan lines zero OUT PB BACK: IN PA CPI FF : Check for key release JNZ BACK : If not, wait for key release CALL DELAY : Wait for key debounce BACK 1: IN PA CPI FF : Check for key press JZ BACK 1 : If not, wait for key press CALL DELAY : Wait for key debounce MVI L, 00H : Initialize key counter MVI C, 08H MVI B, FEH : Make one column low NEXTCOL: MOV A, B 29

OUT PB MVI D, 08H : Initialize row counter IN PA : Read return line status NEXTROW: RRC : Check for one row JNC DISPLAY : If zero, goto display else continue INR L : Increment key counter DCR D : Decrement row counter JNZ NEXTROW : Check for next row MOV A, B RLC : Select the next column MOV B, A DCR C : Decrement column count JNZ NEXTCOL : Check for last column if not repeat JMP START : Go to start INTERFACING SCHEME

Delay subroutine: Delay: LXI D, Count Back: DCX D MOV A, D ORA E JNZ Back RET FLOWCHART

30

Conclusion A stepper motor is a digital motor. It can be driven by digital signal. Fig. shows the typical 2 phase motor rated 12V /0.67 A/ph interfaced with the 8085 microprocessor system using 8255. Motor shown in the circuit has two phases, with center-tap winding. The center taps of these windings are connected to the 12V supply. Due to this, motor can be excited by grounding four terminals of the two windings. Motor can be rotated in steps by giving proper excitation sequence to these windings. The lower nibble of port A of the 8255 is used to generate excitation signals in the proper sequence. These excitation signals are buffered using driver transistors. The transistors are selected such that they can source rated current for the windings.Motor is rotated by 1.80 per excitation. ____________________________________________________________________________

Experiment 9
AIM Generation of delay in binary counting using 8085 microprocessor . SAMPLE PROGRAM Write a program for displaying binary up counter. Counter should count numbers from 00 to FFH and it should increment after every 0.5 sec. Source Program: LXI SP, 27FFH : Initialize stack pointer MVI C, OOH : Initialize counter BACK: CALL Display : Call display subroutine CALL Delay : Call delay subroutine INR C : Increment counter MOV A, C CPI OOH : Check counter is > FFH JNZ BACK : If not, repeat HLT : Stop Delay Subroutine:
31

Delay: LXI B, count : Initialize count BACK: DCX D : Decrement count MOV A, E ORA D : Logically OR D and E JNZ BACK : If result is not 0 repeat RET : Return to main program

Experiment 10 AIM: TO implement a moving 7-segment display with suitable delay using 8085 microprocessor. Apparatus required 7-segment display Sample program Interface an 8-digit 7 segment LED display using 8255 to the 8085
microprocessor system and write an 8085 assembly language routine to display message on the display.

INTERFACING SCHEME

32

33

CONCLUSION Fig. shows the multiplexed eight 7-segment display connected in the 8085 system using 8255. In this circuit port A and port B are used as simple latched output ports. Port A provides the
34

segment data inputs to the display and port B provides a means of selecting a display position at a time for multiplexing the displays. A0-A7 lines are used to decode the addresses for 8255. For this circuit different addresses are: PA = 00H PB = 01H PC = 02H CR = 03H. The register values are chosen in Fig. such that the segment current is 80 mA. This current is required to produce an average of 10 mA per segment as the displays are multiplexed. In this type of display system, only one of the eight display position is 'ON' at any given instant. Only one digit is selected at a time by giving low signal on the corresponding control line. Maximum anode current is 560 mA (7-segments x 80 mA = 560 mA), but the average anode current is 70 mA.

35

Experiment 11
Aim: Write a program to interface two digit numbers using seven Segment LEDs, use 8086
microprocessor and 8255 PPI

Apparatus required 7-segment display Flow Chart

36

Circuit Diagram

37

Conclusion Fig. shows the interfacing of eight 7-segment digits to 8085 through 8279. As shown in the figure eight display lines (Bo-B3 and Ao-A3) are buffered with the help of transistor and used to drive display digits. These buffered lines are connected in parallel to all display digits. So, Sl and S2 lines are decoded and decoded lines are used for selection of one of the eight digits Source program: LXI B, 6200B : Initialize lookup table pointer MVI C, 08H : Initialize counter MVI A, 00H : Initialize keyboard/display OUT 8IH : Mode MVI A, 3EH : Initialize prescaler count OUT 8IH MVI A, 90H : Initial size 8279 in write Display OUT 8IH : RAM-mode BACK : MOV A, M : Get the 7-segment code OUT 80H : Write 7-segment code in display RAM INX H : Increment lookup table pointer DCR C : Decrement counter JNZ BACK : if count = 0 stop, otherwise go to back HLT : Stop program execution

38

You might also like