MP3 Download Box - Download Unlimited MP3 Legally. As low as $1/month
Spyware Doctor with AntiVirus - Easy Spyware Removal - FREE SCAN
Interfacing with LM35 and display temperature in 7 Segment Display
Atmel 8051 microcontroller (asm source code)
How to interface with LM35 temperature sensor
Convert ADC value to temperature
Display temperature into 7 segment display
;======================================================================
; Global variables
;======================================================================
SEVENSEGMENT EQU P0
K1 EQU P1.0
K2 EQU P1.1
INCSWITCH EQU P1.2
DECSWITCH EQU P1.3
BUZZER EQU P1.4
ADC_RD EQU P3.0
ADC_WR EQU P3.1
ADC_INTR EQU P3.2
FAN EQU P3.3
DisplayTemp:
mov DPTR,#Tens ;use lookup table to show tens
MOv A,R3 ;get value from ADC
Movc A,@A+DPTR ;compare value in lookup table
mov R4,A ;collect data for checkspeed
Mov DPTR,#Decoder7Segment ;use lookup table
Movc A,@A+DPTR ;compare value in lookup table
mov SEVENSEGMENT, #0 ;clear seven segment display
clr K1 ;select display 1
setb K2
Mov SEVENSEGMENT,A ;send data to seven segment display
mov DPTR,#Ones ;use lookup table to show ones
MOv A,R3 ;get value from ADC
Movc A,@A+DPTR ;compare value in lookup table
Mov DPTR,#Decoder7Segment ;use lookup table
Movc A,@A+DPTR ;compare value in lookup table
mov SEVENSEGMENT, #0 ;clear seven segment display
setb K1 ;select display 2
clr K2
Mov SEVENSEGMENT,A ;7seg
ret
;======================================================================
; Lookup Table
; Decoder to Seven Segment
;======================================================================
Decoder7Segment:
DB 00111111b,00000110b,01011011b,01001111b,01100110b
DB 01101101b,01111101b,00000111b,01111111b,01101111b
;======================================================================
; Lookup Table
; Temperature = DataADC*100/255
;======================================================================
Ones:
db 0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9,9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9,9
db 0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9,9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9
db 9,0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9,9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8
db 9,9,0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9,9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8
db 8,9,9,0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9,9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9,9,0
Tens:
db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
db 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
db 3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
db 5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
db 7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0
end
Popularity: 7%
Tags: 7segment, 8051, 8051/8052, asm, atmel, display, Hardware, interfacing, lm35, microcontroller, programming, temperature, temperature-sensor
Related Posts:
7 Segment Display Interfacing with 8051
About Seven Segment LED
Superconductors
What is My IP? Check Browser Info
Speeding Up Start Menu Display
Sag and Tension Analysis
Fix Desktop White Dot Bug When Using Latest ATI 8.1 Drivers
Create A Personal Screen Saver In Windows Xp
When is the right time to display ads?
Display Flash Behind JavaScript Menu
Comments
Leave a Reply











