Вы находитесь на странице: 1из 37

ANALOG TO DIGITAL CONVERTOR INTERFACE

WITH 8051 MICROCONTROLLER


DEBANAND MAJHI (109EE0278)
BRAJESH ANAND (109EE0638)
SASHAM MISHRA (109EE0639)
D!"#$%&!'% () E*!+%$,+#* E'-,'!!$,'-
N#%,('#* I'.%,%/%! () T!+0'(*(-1 R(/$2!*#
ANALOG TO DIGITAL CONVERTOR INTERFACE
WITH 8051 MICROCONTROLLER
A Thesis submitted in partial fulfillment of the requirements for the degree
of Bachelor of Technology in Electrical Engineering
By
DEBANAND MAJHI (109EE0278)
BRAJESH ANAND (109EE0638)
SASHAM MISHRA (109EE0639)
Under guidance of
3$()4 S53RATIM G53TA
Department of Electrical Engineering
N#%,('#* I'.%,%/%! () T!+0'(*(-1
R(/$2!*#6769008 (ODISHA)
M#162013
- 2 -
DEPARTMENT OF EE!TR"!A EN#"NEER"N#
NAT"ONA "N$T"TUTE OF TE!%NOO#&' ROUR(EA
OD"$%A' "ND"A)*+,--.
CERTIFICATE
T/i0 i0 to certify t/at t/e t/e0i0 entitled A'#*(- %( D,-,%#* C('7!$%($ I'%!$)#+! 8,%0 8051
M,+$(+('%$(**!$' 0u1mitted 1y D!9#'#': M#;0, (R(**4 N(4 109EE0278)< B$#;!.0 A'#':
(R(**4 N(4 109EE0638) #': S#2.0#& M,.0$# (R(**4 N(4 109EE0639) in partial fulfilment of
t/e re2uirement0 for t/e a3ard of B#+0!*($ () T!+0'(*(-1 in E*!+%$,+#* E'-,'!!$,'- during
0e00ion 4-54)4-56 at National "n0titute of Tec/nology' Rour7ela8 A 1onafide record of re0earc/
3or7 carried out 1y t/em under my 0uper9i0ion and guidance8
T/e candidate0 /a9e fulfilled all t/e pre0cri1ed re2uirement08
T/e T/e0i0 3/ic/ i0 1a0ed on candidate0: o3n 3or7' /a9e not 0u1mitted el0e3/ere for a
degree;diploma8
"n my opinion' t/e t/e0i0 i0 of 0tandard re2uired for t/e a3ard of a 1ac/elor of tec/nology degree
in Electrical Engineering8
3*#+!= R(/$2!*#
D!"%4 () E*!+%$,+#* E'-,'!!$,'- 3$()4 S/"$#%,& G/"%#
N#%,('#* ,'.%,%/%! () T!+0'(*(-1
R(/$2!*#6769008
- 3 -
ACKNOWLEDGEMENTS
We woud ke to artcuate our deep grattude to our pro|ect gude Prof.
SUPRATIM GUPTA who has aways been source of motvaton and rm
support for carryng out the pro|ect. We woud aso ke to convey our
sncerest grattude and ndebtedness to a other facuty members and stah
of Department of Eectrca Engneerng, NIT Rourkea, who showed ther
great ehorts and gudance at requred tmes wthout whch t woud have
been very dmcut to carry out our pro|ect work. Moreover , an assembage of
ths nature coud never have been attempted wth our reference to the works
of others whose detas are mentoned n the references secton at the ast.
We acknowedge our ndebtedness to a of them. Furthermore, we woud ke
to take the name of our parents and God who drecty or ndrecty
encouraged and motvated us durng ths dssertaton.

ABSTRACT
In ths paper we sha study how a 8051 mcrocontroer s nterfaced wth an
anaog to dgta convertor(ADC). An ADC s a rea word devce whch
converts rea tme contnuous quanttes nto dgta vaues that represent the
amptude of the quantty. An ADC converts nput anaog sgnas by
quantzng t. Hgher the sampng rate used to dscretze the vaues more w
be the accuracy wth whch the output from ADC s obtaned. ADCs may be
used n
Dgta Sgna Processng, n commerca appcatons as we as n musc
ndustres to convert the data from anaog to dgta n order to create the
data that w be used n compact dsks. Further the crcut has been
smuated usng PROTEUS Demo verson.

CONTENTS
A10tract i
!ontent0 ii
i0t of Figure09
i0t of Ta1le0 9iii
!%APTER 5
INTROD5CTION
141M(%,7#%,(' 5
142M,+$(+('%$(**!$ A$+0,%!+%/$! 5
#) Feature0 of .-<5 4
9) Regi0ter0 4
+) Pin De0cription of .-<5 6
143ADC A$+0,%!+%/$! <
!%APTER 4
8051 MICROCONTROLLER WITH ADC
241 A*-($,%0& )($ "$(-$#&&,'- ADC .
242 A..!&9*1 "$(-$#& %( ,'%!$)#+! ADC 8,%0 8051 .

!%APTER 6
SIM5LATION AND O5T35T
341O/%"/% 5=
342O/%"/% A'#*1.,. 5<
!%APTER =
CONCL5SION
v
LIST OF FIG5RES
F,-4 N( N#&! () %0! F,-/$! 3#-!4 N(4
5 .-<5 Microcontroller Bloc7 Diagram 4
4 .-<5 Microcontroller <
6 AD! -.-. +
= Bloc7 Diagram for interfacing AD! 3it/ .-<5 Microcontroller .
< !ircuit Diagram for interfacing AD! 3it/ .-<5 5=
v
LIST OF TABLES
T#9*!4 N(4 N#&! () %0! T#9*! 3#-!4 N(4
5 Feature0 of .-<5 4
4 Output 5=
v
!%APTER1
"ntroduction
1
1.1 MOTIVATION=
"n em1edded 0y0tem' it i0 e00ential t/at microcontroller0 ta7e analog input8 $en0or0 and
tran0ducer0 u0ed in indu0try are analog in nature8 >e need to con9ert t/e analog output from t/e
0en0or0 to digital 0o t/at t/e corre0ponding 0ignal can 1e proce00ed 1y t/e controller8 T/e0e are
generally u0ed in control operation and in0trumentation in indu0trie08 AD!0 are u0ed e9ery3/ere
3/en 3e /a9e to proce00' 0tore or tran0mit an analog 0ignal in digital form8 AD!0 are u0ed in T?
tuner card0 and for digital data proce00ing in microcontroller0 in t/e form of on c/ip . 1it' 5- 1it
AD!08 !ommercial AD!0 are al0o u0ed a0 integrated circuit08 !on9ertor0 3it/ a re0olution of .
to 4= 1it0 are u0ed and it0 0ample fre2uency i0 in order of 0ome (%@' Mega and #iga 0ample
analog to digital con9ertor0 are al0o u0ed8 T/ey may 1e re2uired in digital 9ideo camera08 Digital
to Analog !on9ertor0 may al0o 1e re2uired in application0 0uc/ a0 !D player0' data 3/ic/ 3ill
1e 0tored in 1inary form may 1e con9erted into analog form 1y t/e digital to analog
con9ertor0A5B8 %ere AD! -.-. i0 u0ed8 "t i0 a .)c/annel multipleCer' .)1it analog to digital
con9erter and microproce00or compati1le control logic8
1.2 MICROCONTROLLER ARCHITECT5RE=
T/e .-<5 microcontroller i0 an .)1it microcontroller introduced 1y "ntel corporation8 t/i0
microcontroller /a0 54. 1yte0 of Random Acce00 MemoryDRAME' =( 1yte0 of on)c/ip Ream
Only MemoryDROME' t3o timer0' one 0erial port and four portDeac/ .)1it0 3ideE all on a 0ingle
c/ip8 T/e !entral Proce00ing UnitD!PUE can 3or7 only on .)1it of data at a time8 T/e .-<5 /a0
four ";O port0' eac/ .)1it0 3ideA4B8
1
Fig 5F .-<5 microcontroller 1loc7 diagramA<B
1.2.1 Features of 8051!"#
Feature Guantity
ROM =( 1yte0
RAM 54. 1yte0
Timer 4
";O pin0 64
$erial port 5
"nterrupt 0ource0 +
Ta1le No85 Feature0 of .-<5A6B
1.2.2 $egisters#
Regsters are used to store nformaton temporary. The vast ma|orty of
8051 regsters are 8-bt regsters. Wth an 8 bt data type, any data arger
than 8 bts must be broken nto 8-bts chunks before t s processed.
Commony used regsters of the 8051 are A(accumuator), B, R0, R1, R3, R4,
R5, R6, R7, DPTR(data ponter), PC(program counter).
Some speca purpose regsters are:
2
Program Status Word(PSW)
Stack Ponter(SP)
Data Ponter(DPTR)
Accumuator(ACC)
B Regster(B)
Tmer/Counter mode contro(TMOD)
Tmer/Counter contro(TCON)
Sera Contro(SCON)
Power Contro(PCON)
1.2.! %in &escription of 8051#
.-<5 microcontroller /a0 =- pin0 3/ic/ perform function0 0uc/ a0 input;output' read;3rite'
addre00' data interrupt08 Out of t/e =- pin0' 64 pin0 are for t/e four port0 namelyF P-' P5' P4' P68
?
!!'
#ND' HTA5' HTA4' ' ' AE and R$T are t/e ot/er . pin0 a9aila1le on microcontroller
c/ip8
'
((
)%in *0+
?oltage input i0 I<?' purpo0e of ?
!!
i0 to 0upply 9oltage to microcontroller8
,-&)%in 20+
#round i0 al0o pro9ided in .-<58
.TA/1 A-& .TA/ 2)%ins 18 and 10+
An eCternal cloc7 i0 re2uired to run .-<58 T3o capacitor0 of 66pF are connected in addition to a
2uart@ cry0tal o0cillator to HTA5 and HTA48 T/e cry0tal o0cillator u0ed in our circuit /a0 1een
0et at 558-<,4 M%@8
$1T)%in 0+
3
"t i0 normally lo3' 3/en a /ig/ pul0e i0 applied to t/i0 pin' microcontroller 3ill terminate all
acti9itie0 and re0et all regi0ter 9alue08
)%in !1+
"t i0 an input pin and 0/ould 1e connected to ?
!!8
"t i0 7no3n a0 ECternal Acce008
)%in 20+
DProgram $tore Ena1le pinE i0 an output pin8
A/2)%in !0+
"t i0 an output pin and 0tand0 for Addre00 atc/ Ena1le8
%0)%ort 0+)%ins !2 to !0+
Port - can 1e u0ed for addre00 a0 3ell a0 data8 "f AEJ5' P- /a0 addre00 A-)A* and if AEJ-'
P- pro9ide0 data D-)D*8 Port - need0 pull)up re0i0tor0 of 9alue 5-()o/m to 1e connected
eCternally 1ecau0e P- /a0 no in1uilt pull)up re0i0tor0 li7e P5' P4 and P68
%1)%ort1+)%ins 1 to 0+ and %2)%ort2+)%ins 21 to 28+
T/ey are u0ed a0 input;output pin08
%!)%ort!+)%ins 10 to 13+
"t i0 u0ed a0 input a0 3ell a0 output port8 No pull)up re0i0tor0 are re2uired in P68 Apart from
input;output it al0o pro9ide0 interrupt08
4
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RXD)
P3.0
8051
(TXD)
P3.1
(INT0)
P3.2
(INT1) P3.3
(T0) P3.4
(T1) P3.5
(WR) P3.6
(RD) P3.7
XTAL2
XTAL1
GND
Fig 4F .-<5 microcontrollerA<B
1.3 ADC ARCHITECT5RE
Vcc
P0.0
(AD0)
P0.1
(AD1)
P0.2
(AD2)
P0.3
(AD3)
P0.4
(AD4) P0.5
(AD5)

P0.6(AD6)
P0.7
(AD7)
EA/VPP
ALE/PRO
G
PSEN
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
T/e AD! u0ed in
t/e interfacing i0
AD! -.-.8 "t /a0
4. pin0' and can
/andle upto .
analog 0ignal0 u0ing
one
c/ip8 "t
/a0 got
an .)
1it
data
output8
T/e . input c/annel0 are "N-)"N*' and
?refDIEJ<?K ?refD)E /a0 1een grounded8 "n order
to 0elect t/e input0 "N-)"N*K A' B and !
addre00e0 are u0edA=B8
5
IN0
GND CLOCK Vcc
D
0
IN7
ADC0808
D
7
Vref(
+)
EOC
Vref(-
)
OE
SC ALE B B A
Fg 3: ADC0808|5|
6
!%APTER2
.-<5 M"!RO!ONTROER
>"T% AD!
7
ADC receves anaog sgna from the source. Ths anaog sgna s
receved from one of the 8 nput channes of ADC0808. Then ths sgna s
processed accordngy and converted to correspondng dgta sgna. Ths
sgna s then sent to the mcrocontroer and the output s dspayed
usng Lght Emttng Dode (LED)|5|.
ADC
8051 LE
D
microcontroller
Fg 4: bock dagram for nterfacng ADC wth 8051 mcrocontroer
241 ALGORITHM FOR 3ROGRAMMING ADC
1) An analog c/annel i0 0elected 1y gi9ing 1it0 to A' B' ! addre00e08
2) AEDAddre00 atc/ Ena1leE i0 acti9ated 1y a lo3 to /ig/ pul0e in order to latc/ in t/e
addre008
3) $!D$tart !on9er0ionE i0 acti9ated 1y a lo3 to /ig/ pul0e in order to 0tart t/e con9er0ion8
4) "f a /ig/ to lo3 output i0 o1tained at EO!DEnd of !on9er0ionE' it indicate0 t/at t/e data
con9er0ion i0 fini0/ed and t/e data i0 ready8
5) OEDOutput Ena1leE i0 acti9ated to read output data from t/e AD! c/ip8 "n order to 1ring t/e
digital data out of t/e c/ip a lo3 to /ig/ pul0e i0 i0 gi9en to t/e OE pin8
242 ASSEMBL> 3ROGRAM TO INTERFACE ADC WITH 8051
ORG 000AH
S|MP MAIN
ADC_DATA EOU P1 ;Give Name To Port Pins
ADC_SC BIT P3.0
ADC_EOC BIT P3.1
8
ADC_ALE BIT P3.2
ADC_OE BIT P3.3
ADD_A BIT P3.4
ADD_B BIT P3.5
ADD_C BIT P3.6
MAIN:
MOV ADC_DATA,#0FFH ;Port 1 is input port
SETB ADD_A ;select channel
SETB ADD_B
CLR ADD_C ;for channel 3 selection
ACALL DELAY1
ACALL ADC_COUNT
MOV P0,A
;ADC Programming Start
ADC_COUNT:
SETB ADC_EOC ;it is made as input Port
CLR ADC_ALE
CLR ADC_SC
CLR ADC_OE
BACK:
9
SETB ;High To o! Pulse is given to A"
ADC_ALE
ACALL
DELAY1
SETB
ADC_SC ;High To o! Pulse is given to SC
ACALL
DELAY1
CLR
ADC_ALE
CLR
ADC_SC
LOOP1:
|B ADC_EOC,LOOP1 ;#ait for conversion to $nish
LOOP2:
|NB
ADC_EOC,LOOP2 ;%utput &ecomes high
SETB
ADC_OE
;Set %" High to covert data on
controller
ACALL
DELAY1 ;'or 'urther dela(
CLR
ADC_OE
;digital converted data is saved in
memor(
MOV
B,#05H
DIV AB
;amplif( !ith gain in place of )*H for o&taining real
digital data
RET ;+eturn To ,ain +outine
Deay
;App- 1-3./3 Sec- Dela(
DELAY:
MOV R3,#3
10
LOOP3:
MOV R1,#254
LOOP4:
MOV R2,#254
LOOP5:
D|NZ R2,LOOP5
D|NZ R1,LOOP4
D|NZ R3,LOOP3
RET
;Appro0imatel( /3* 1sec
DELAY1:
MOV R3,#1
LOOP6:
MOV R1,#10
LOOP7:
MOV R2,#10
LOOP8:
D|NZ R2,LOOP8
D|NZ R1,LOOP7
D|NZ R3,LOOP6
11
RET
END
12
!%APTER3
$"MUAT"ON AND OUTPUT
13
Fig8 < !ircuit Diagram for interfacing AD! 3it/ .-<5
341 O5T35T
S.No Votage Input
Dgta output( n
hexadecma)
1 .5 V 1A
2 1 V 33
3 1.5 V 4D
4 2 V 66
5 2.5 V 7F
6 3 V 99
7 3.5 V B2
8 4 V CC
9 4.5 V E5
10 5 V FF
Ta1le No8 4 Output
14
342 O5T35T ANAL>SIS
A0 AD! -.-. i0 a .)1it AD!' 0o t/e num1er0 of 0tep0 i0 4<+8 !orre0pondingly t/e 0tep
0i@eD0malle0t c/ange t/at can 1e detected 1y an AD!E 1ecome0 e2ual to
<;4<+J5,8<6m?
$o' t/e 0malle0t c/ange in 9oltage t/at can 1e detected 1y t/e AD! i0 5,8<6m?8
15
!%APTER?
!ON!U$"ON
16
Smuaton of nterfacng of ADC and 7 segment dspay has been done usng
Proteus Demo Verson. Input s gven as DC votage wth a step ncrease of
0.5V and s ncreased t 5V. The correspondng dgta vaues of the sgnas
have been obtaned.
17
REFERENCES
[1] $8(' Mandal' Digital Electronic0 Principle0 and Application0' 4
nd
Edition' Tata
Mc#ra3 %ill' 4-558
[2] Pred7o My7e8' Programming and !u0tomi@ing t/e .-<5 Microcontroller' TATA
Mc#ra3 %ill Production' Lanuary 5,,,' $econd Edition8
[3] AD! -.-.;-.-, .)1it MP compati1le A;D con9erter0 3it/ .)c/annel MultipleCer'
National "n0trument0' Octo1er 5,,, Re9i0ed Marc/ 4-568
[4] (ennet/ L8 Ayala8' T/e .-<5 MicrocontrollerF Arc/itecture' Programming' and
Application0' T/om0on Delmer earning' Luly 4--=' T/ird edition8
[5] Ma@idi Mu/ammad Ali' T/e .-<5 Microcontroller And Em1edded $y0tem0 U0ing
A00em1ly And !' Pear0on Education' $eptem1er 4--*' $econd edition8
18

Вам также может понравиться