| ??? 10/01/09 09:26 Modified: 10/01/09 09:36 Read: times Msg Score: +1 +1 Good Question |
#169322 - TEMPERATURE MONITORING DEVICE USING AT89C51 |
Hi! I've been working on a project for my computer architecture class. I selected this project and, somehow, I'm stuck.
It's a temperature monitoring device using LM5 and an AT89C51 as the microcontroller. Now before using the microcontroller, I plugged the temperature onto 8 LEDs (I'm using a DeccanRobots package, and so this was supplied with the board). It worked, showing the temperature in binary form . Now when I tried using my microcontroller with this program I wrote to output the number on 4 7-segments(also included in the DeccanRobots package), it ended up showing me "29.9". And when I touched the LM5 to make the temperature increase, nothing happened. transferring it back to the LEDs, it would work. What can be wrong with my program? here is my program (quite lengthy, mind you) and the circuit diagram
ORG 0
;P1 EQU 11111111
DIGIT1 EQU P3.0
DIGIT2 EQU P3.1
DIGIT3 EQU P3.2
DIGIT4 EQU P3.3
ZERO EQU 01110111b
ONE EQU 01000001b
TWO EQU 00111011b
THREE EQU 01101011b
FOUR EQU 01001101b
FIVE EQU 01101110b
SIX EQU 01111110b
SEVEN EQU 01000011b
EIGHT EQU 01111111b
NINE EQU 01101111b
DOT EQU 10000000b
PDATA EQU P2
MOV PDATA,#00h
CLR DIGIT1
CLR DIGIT2
CLR DIGIT3
CLR DIGIT4
MAIN:
ACALL GETNUM
ACALL AHUNDS
ACALL ATENS
ACALL AONES
ACALL DISPLAY
ACALL DELAY
JMP MAIN
GETNUM:
MOV A, P1
MOV B, #100
DIV AB
MOV R0, A ; 1st digit
MOV A, B
MOV B, #10
DIV AB
MOV R1, A ; 2nd digit
MOV R2, B ; 3rd digit
RET
AHUNDS:
MOV A, R0
FZERO:
CJNE A, #0, FONE
MOV R3, #ZERO
FONE:
CJNE A, #1, FTWO
MOV R3, #ONE
FTWO:
MOV R3, #TWO
RET
ATENS:
MOV A, R1
SZERO:
CJNE A, #0, SONE
MOV R4, #ZERO
SONE:
CJNE A, #1, STWO
MOV R4, #ONE
STWO:
CJNE A, #2, STHREE
MOV R4, #TWO
STHREE:
CJNE A, #3, SFOUR
MOV R4, #THREE
SFOUR:
CJNE A, #4, SFIVE
MOV R4, #FOUR
SFIVE:
CJNE A, #5, SSIX
MOV R4, #FIVE
SSIX:
CJNE A, #6, SSEVEN
MOV R4, #SIX
SSEVEN:
CJNE A, #7, SEIGHT
MOV R4, #SEVEN
SEIGHT:
CJNE A, #8, SNINE
MOV R4, #EIGHT
SNINE:
MOV R4, #NINE
RET
AONES:
MOV A, R2
TZERO:
CJNE A, #0, TONE
MOV R5, #ZERO
TONE:
CJNE A, #1, TTWO
MOV R5, #ONE
TTWO:
CJNE A, #2, TTHREE
MOV R5, #TWO
TTHREE:
CJNE A, #3, TFOUR
MOV R5, #THREE
TFOUR:
CJNE A, #4, TFIVE
MOV R5, #FOUR
TFIVE:
CJNE A, #5, TSIX
MOV R5, #FIVE
TSIX:
CJNE A, #6, TSEVEN
MOV R5, #SIX
TSEVEN:
CJNE A, #7, TEIGHT
MOV R5, #SEVEN
TEIGHT:
CJNE A, #8, TNINE
MOV R5, #EIGHT
TNINE:
MOV R5, #NINE
RET
DISPLAY:
setb DIGIT1
MOV A,R3
MOV PDATA,A
LCALL DELAY
CLR DIGIT1
setb DIGIT2
MOV A,R4
ORL A,#DOT
MOV PDATA,A
LCALL DELAY
CLR DIGIT2
setb DIGIT3
MOV A,R5
MOV PDATA,A
LCALL DELAY
CLR DIGIT3
RET
DELAY:
MOV TMOD,#01h
MOV TH0,#240
Wait:
setb TR0
JNB TF0,Wait
CLR TF0
CLR TR0
RET
|



