0% found this document useful (0 votes)
36 views

Temperature Sensor

The document describes a circuit using an LM35 temperature sensor, AT89C51 microcontroller, ADC0809 analog to digital converter, and 74LS393 decoder to measure temperature and display the readings on LEDs. It includes the circuit diagram and assembly code to initialize the components, take 8 ADC readings and average them, convert the value to a 2-digit BCD number, and display the digits on the LEDs using ports P1 and P2. The code takes readings every second and continuously displays the temperature.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Temperature Sensor

The document describes a circuit using an LM35 temperature sensor, AT89C51 microcontroller, ADC0809 analog to digital converter, and 74LS393 decoder to measure temperature and display the readings on LEDs. It includes the circuit diagram and assembly code to initialize the components, take 8 ADC readings and average them, convert the value to a 2-digit BCD number, and display the digits on the LEDs using ports P1 and P2. The code takes readings every second and continuously displays the temperature.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Nguyn Ng$c S'n 26.09.

2008

BK3i2_K50 (*i h$c Bch khoa H N,i
1
CM BI#N NHI&T ()

S d#ng LM35 + AT89C51 + ADC0809 + 74LS393

XTAL2
18
XTAL1
19
ALE
30
EA
31
PSEN
29
RST
9
P0.0/AD0
39
P0.1/AD1
38
P0.2/AD2
37
P0.3/AD3
36
P0.4/AD4
35
P0.5/AD5
34
P0.6/AD6
33
P0.7/AD7
32
P1.0
1
P1.1
2
P1.2
3
P1.3
4
P1.4
5
P1.5
6
P1.6
7
P1.7
8
P3.0/RXD
10
P3.1/TXD
11
P3.2/INT0
12
P3.3/INT1
13
P3.4/T0
14
P3.7/RD
17
P3.6/WR
16
P3.5/T1
15
P2.7/A15
28
P2.0/A8
21
P2.1/A9
22
P2.2/A10
23
P2.3/A11
24
P2.4/A12
25
P2.5/A13
26
P2.6/A14
27
U1
AT89C51
2 -1MSB
21
ADD B
24
ADD A
25
ADD C
23
VREF(+)
12
VREF(-)
16
IN3
1
IN4
2
IN5
3
IN6
4
IN7
5
START
6
2 -5
8
EOC
7
OUTPUT ENABLE
9
CLOCK
10
VCC
11
2 -2
20
GND
13
2 -7
14
2 -6
15
2 -8LSB
17
2 -4
18
2 -3
19
IN2
28
IN1
27
IN0
26
ALE
22
U2
ADC0809
G
N
D
3
+
V
S
1
VOUT
2
U3
25
CLK
1
Q0
3
Q1
4
Q2
5
Q3
6
MR
2
U4:A
74LS393


#include <Sfr51.inc>

;********************************************************************
; CAM BIEN NHIET DO

;********************************************************************
;8 ngo ra of ADC noi voi P0
;chan 1 of 74LS393 noi voi chan 18 of 8951
;chan 6 of 74LS393 noi voi chan 10 of adc de tao xung clock
;3 dia chi C, B, A noi voi P3.2, P3.1, P3.0
;tin hieu ALE, START noi voi P3.3
;EOC noi voi P3.4
;OE noi voi P3.5
;led hang don vi noi voi p1
;led hang chuc noi voi p2

org 00h
ljmp main
PDF created with pdfFactory Pro trial version www.pdffactory.com
Nguyn Ng$c S'n 26.09.2008

BK3i2_K50 (*i h$c Bch khoa H N,i
2
;delay 1ms
delay1:
mov tmod,#01h
mov th0,#high(-1000)
mov tl0,#low(-1000)
setb tr0
jnb tf0,$
clr tf0
clr tr0
ret

;chuong trinh con tao tre 1s
delay1s:
mov r0,#100

loopp9:
mov r1,#10
loo:
acall delay1
djnz r1,loo
djnz r0,loopp9
ret

;chuyen doi adc
adc:
clr p3.5 ;ko cho phep du lieu ra

clr p3.0 ;chon kenh 0
clr p3.1
clr p3.2

mov dptr,#4000h ;dia chi ram ngoai cua ADC

clr p3.3 ;tao xung Start va ALE
setb p3.3
clr p3.3

jnb p3.4,$ ;cho EOC len 1
setb p3.5 ;cho phep du lieu ra

movx a,@dptr ;cat du lieu vao thanh chua A

ret

;cong lien tiep 8 lan gia tri do roi chia trung binh
adc1:
PDF created with pdfFactory Pro trial version www.pdffactory.com
Nguyn Ng$c S'n 26.09.2008

BK3i2_K50 (*i h$c Bch khoa H N,i
3
mov r1,#40h
lopo:
acall adc
mov @r1,a ;luu vao o nho 40h
inc r1 ;luu vao o nho tiep theo
mov a,r1

acall delay1
nop
cjne a,#48h,lopo ;thoat khi da luu vao 6 o nho tu 40h toi 47h

clr c ;xoa co nho
mov a,#00h
mov r3,#8 ;so lan cong
mov r1,#47h

lppo:
addc a,@r1
dec r1
djnz r3,lppo

mov b,#4 ;gia tri hien thi bang output of ADC nhan 2 chia 8
div ab

mov 50h,a ;luu gia tri tinh duoc vao o nho 50h

ret
;chuyen ma bcd sang ma 7 doan tuong ung
chuyen:
mov dptr,#data1
movc a,@a+dptr
acall delay1

ret
;xuat ra led
xuat:

mov a,50h ;xuat ra chu so hang don vi
anl a,#0fh

acall chuyen
mov p1,a

mov a,50h ;xuat ra chu so hang chuc

swap a
PDF created with pdfFactory Pro trial version www.pdffactory.com
Nguyn Ng$c S'n 26.09.2008

BK3i2_K50 (*i h$c Bch khoa H N,i
4
anl a,#0fh

acall chuyen
mov p2,a

ret
org 100h

data1: db 3fh,06h,5bh,4fh,0e6h,0edh,0fdh,07h,0ffh,6fh


org 300h
main:

mov sp,#30h
acall adc1

acall xuat

acall delay1s
acall delay1s

ljmp main
end
PDF created with pdfFactory Pro trial version www.pdffactory.com

You might also like