Documente Academic
Documente Profesional
Documente Cultură
ECE-306
Experiment :1
Procedure:
For 8255, Port A and B are used as output ports. The control word format of 8255 according to
hardware connections is:
Source program:
DISPLAY MESSAGE:
Delay subroutine:
Procedure:
Experiment: 3
Title: To develop a program for discrete convolution and correlation without using
inbuilt functions.
EQUIPMENT: MATLAB
PROCEDURE:
ALGORITHM:
PROGRAM CODE:
x=[1,1,1,2];
h=[1,1,2,1];
Nx=length(x);
Nh=length(h);
y=conv(x,h);
n=0:1:Nx-1;
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
title('input sequence');
n=0:1:Nh-1;
subplot(2,2,2),stem(n,h);
xlabel('n'),ylabel('h(n)');
title('impulse sequence');
n=0:1:Nx+Nh-2
subplot(2,2,3),stem(n,y);
xlabel('n'),ylabel('y(n)');
RESULT:
1.5 1.5
x(n)
h(n)
1 1
0.5 0.5
0 0
0 1 2 3 0 1 2 3
n n
output sequence(linear convolution)
6
4
y(n)
0
0 2 4 6
n
ALGORITHM:
X = [1 2 3 4];
Y = [2 3 4 5];
Z = xcorr(x,y);
stem(z);
RESULT:
40
35
30
25
20
15
10
0
1 2 3 4 5 6 7
Fig shows discrete Correlation of two signals
EXPERIMENT NO:4
TITLE: to develop program for computing DFT and FFT in MATLAB and compare
this simulation.
Equipment: MATLAB
Procedure:
Function
function [Xkl = dft(111.N)
% Computes Discrete Fourier Transform
% Ixkl = dft(xn.N)
% Xk = DFT coeff. array over 0 <= k <= N-I
% xn = N-point finite-duration sequence
% N = Length of DFT
X
n = [O:l:N-11; % row vector for n
k = CO:I:N-11; X row vecor for k
UN = eq(-j*l*pi/N); % Wn factor
nk = nl*k;
UNnk =UN .- nk;
xk = m * UNnk;
% creates a N by N matrix of nk values
% DFT matrix
% row vector for DFT coefficients
ALGORITHM:
PROGRAM CODE:
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
end
p=0:(N-1);
stem(p,abs(X)),grid
Input Sequence:-
RESULT:
20
18
16
14
12
10
0
0 0.5 1 1.5 2 2.5 3
For FFT
Function:
% Nmar = 2048;
% fft-time=zeros(l,Nmar);
% for n-1:l:Nmax
% I-raud(1,n) ;
%t-ciock;fft(x) ;fft-time(n)=etime(clock,t) ;
% end
>> n=Cl:l:Nmaxl;
>> plot(n,fft-time. I . ' )
>> xlabel('NS) ;ylabel('Time in Sec. ')
>> title('FFT execution times')
Experiment:5
PROCEDURE:
ALGORITHM:
PROGRAM CODE:
N2=length(h);
N=max(N1,N2);
N3=N1-N2;
if(N3==0)
x=[x,zeros(1,N3)];
h=[h,zeros(1,N3)];
end
if(N1>N2)
h=[h,zeros(1,N3)];
end
if(N1<N2)
x=[x,zeros(1,-N3)];
end
for n=1:N,
y(n)=0;
for i=1:N,
j=n-i+1;
if(j==0)
j=N+j;
end
if(j<0)
j=N+j;
end
y(n)=y(n)+x(i).*h(j);
end
end
display('convoluted sum:');
p=0:(N-1);
stem(p,y),grid;
RESULT:
40
35
30
25
20
15
10
0
0 0.5 1 1.5 2 2.5 3
Input:
Experiment no:6
Procedure:
b) Title: sending string “HELLO” to PC using serial communication port of
8051.
c) Addition of two numbers and display the result on PC using serial
communication.
EXPERIMENT NO: 8
start:
SETB P3.3 ; |
SETB P3.4 ; | enable display 3
MOV P1, #11111001B ; put pattern for 1 on display
MOV P1, #0FFH ; clear the display
CLR P3.3 ; enable display 2
MOV P1, #10100100B ; put pattern for 2 on display
MOV P1, #0FFH ; clear the display
CLR P3.4 ; |
SETB P3.3 ; | enable display 1
MOV P1, #10110000B ; put pattern for 3 on display
MOV P1, #0FFh ; clear the display
CLR P3.3 ; enable display 0
MOV P1, #10011001B ; put pattern for 4 on display
MOV P1, #0FFH ; clear display
JMP start ; jump back to start
for Port 0
MOV A,#55H
BACK: MOV P0,A
ACALL DELAY
CPL A
SJMP BAC
Port 0 as Input
MOV A,#0FFH ; A = FF hex
MOV P0,A ; make P0 an input port
BACK: MOV A,P0 ;get data from P0
MOV P1,A ;send it to port 1
SJMP BACK
Experiment no:9
8051 Assembly language programming using Keil compiler. (At least 5 programs.).
a) Write a program to add two numbers lying at two memory locations and
display result.
Sample program:
Start
.org 4000h
MOV A,30h
MOV B,31h
ADD A,B Load the Two
MOV 80h,A numbers from
memory to register
.end
A&B
END
Sample program:
.org 4000h
MOV A,30h
MOV B,31h
MUL AB
MOV 80h,A
.end
Sample program
.org 4000h
MOV A,30h
MOV B,#10h
MUL AB
MOV B,31h
ADD A,B
MOV B,#0Fh
DIV AB
.end
sample program
.ORG 00h
MOV R0, #0Fh
LOOP1: MOV DPTR, #2050h
MOV A, R0
MOV R1, A
Experiment no:10
Title: 8051 Interfacing
a. ADC
b. DAC
c. LCD
d. Keyboard
Program code:
after identifying the row to check the column following steps are followed
WAIT_LCD:
CLR EN ;Start LCD command
CLR RS ;It's a command
SETB RW ;It's a read command
MOV DATA,#0FFh ;Set all pins to FF initially
SETB EN ;Clock out command to LCD
MOV A,DATA ;Read the return value
JB ACC.7,WAIT_LCD ;If bit 7 high, LCD still busy
CLR EN ;Finish the command
CLR RW ;Turn off RW for future commands
RET