pandeeey
Newbie level 3
hello everyone.
i am doing project on temperature control and monitoring system .i have completed adc0804 interfacing with at89c51 microcontroller and now i am working on lcd n keypad interfacing with microcontroller.I need a two line LCD one for displaying the measured temperature and other for displaying the desired temperature taken from keypad input.
i have written test program for lcd and keypad interfacing..this program displays "temperature " on first line and "temp i/p :" followed by a letter from keypad input......As soon as another input is given from keypad previous keypad input gets deleted. i need to 2 chracter input from keypad (temperature) and it must be converted to binary form and be supplied to microcontroller port on second line
On first line of lcd i need to display the digitized temperature in decimals....
the adc converts temperature in the following format. 1 bit change per 2 Centigrade rise in temperature .
1 C , 2C ----------- 1 (adc o/p)
3 C , 4 C--------------- 10
5C ,6 C----------------- 11
plz help me ,I have tried my best but couldn,t get output.......I am attaching the ckt diagram n codes
codes:
INCLUDE 8051.mc
;port 1 lcd, port 2 keypad
;EN EQU P3.0
;RS EQU P3.1
;RW EQU P3.2
org 0000H
LJMP main
ORG 0013H ; INT1 ISR
CLR ie.7
INC R0
RETI
org 0030H
main:
MOV R4, #0 ; Counters for LCD
MOV R5, #0
MOV R6, #0
MOV R0, #0
mov A,#38H ; Setting Up the LCD
lcall command
mov A,#0EH ; Display On
lcall command
mov A,#06H ; Entry Mode
lcall command
mov a,#82H
lcall command
lcall disp ; Function Disp Called
mov a,#02H ; Setting DDRAM Address to Home position
lcall command
lcall delay1
; Displays temperature measured ON FIRST LINE OF LCD
mov a,#'T'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#'M'
lcall datw
mov a,#'P'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#'R'
lcall datw
NOP
mov a,#'A'
lcall datw
NOP
mov a,#'T'
lcall datw
NOP
mov a,#'U'
lcall datw
NOP
mov a,#'R'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#':'
lcall datw
NOP
MOV A,#255 ; Moving Value 255 to PORT 2
MOV P2,A
; Keypad Scan Begins
sd:
lcall delay1
lcall key1
lcall delay
lcall key2
lcall delay
lcall key3
lcall delay
lcall key4
lcall delay
lcall sd
; Function to Send Commands to LCD
command:
clr P3.2
clr P3.1
setB P3.0
MOV P1,A
lcall delay
clr P3.0
RET
; Function to Clear the DDRAM Content
clear:
mov A,#01H
lcall command
lcall delay
mov A,#02H ; Set The DDRAM Address to Home Position
lcall command
lcall delay
RET
; Function to Display Data on LCD Screen
datw:
SETB P3.1
clr P3.2
SETB P3.0
MOV P1,A
lcall delay
clr P3.0
RET
;Function to Display The Key Pressed
datw1:
lcall delay1
lcall disp
lcall delay1
MOV A,R7
lcall datw
RET
; Generating Small Delay
delay:
mov r0,#255
loop: DJNZ r0,loop;
RET
; Generating a Bigger Delay
delay1:
mov r1,#255
loop1: mov r3,#120
loop2: djnz r3,loop2
djnz r1,loop1
RET
; Checking for Key Press on The First Column of 4x4 Matrix
KEY1:
MOV A,r5
MOV r6,A
clr p2.4
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,n1
MOV r7,#'1'
lcall datw1
lcall delay1
n1: cjne r2,#13,n2
mov r7,#'4'
lcall datw1
lcall delay1
n2: cjne r2,#11,n3
mov r7,#'7'
lcall datw1
lcall delay1
n3: cjne r2,#7,n4
mov r7,#'*'
lcall datw1
lcall delay1
n4: lcall delay1
SETB P2.4
RET
; Checking for Key Press on the Second Column of 4x4 Matrix
KEY2:
clr p2.5
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,q1
mov r7,#'2'
lcall datw1
lcall delay1
q1: cjne r2,#13,q2
mov r7,#'5'
lcall datw1
lcall delay1
q2: cjne r2,#11,q3
mov r7,#'8'; A=65
lcall datw1
lcall delay1
q3: cjne r2,#7,q4
mov r7,#'0'
lcall datw1
lcall delay1
q4: lcall delay
SETB p2.5
RET
; Checking for Key Press On The Third Column of 4x4 Matrix
KEY3:
clr p2.6
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,w1
mov r7,#'3'
lcall datw1
lcall delay1
w1: cjne r2,#13,w2
mov r7,#'6'
lcall datw1
lcall delay1
w2: cjne r2,#11,w3
mov r7,#'9'
lcall datw1
lcall delay1
w3: cjne r2,#7,w4
mov r7,#'#'
lcall datw1
lcall delay1
w4: lcall delay1
SETB p2.6
RET
; Checking for Key Press on the Fourth Column of 4x4 Matrix
KEY4:
clr p2.7
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,e1
mov r7,#' '
lcall datw1
lcall delay1
e1: cjne r2,#13,e2
mov r7,#' '
lcall datw1
lcall delay1
e2: cjne r2,#11,e3
mov r7,#' '
lcall datw1
lcall delay1
e3: cjne r2,#7,e4
mov r7,#' '
lcall datw1
lcall delay1
e4: lcall delay1
SETB p2.7
RET
disp:
mov a,#0c0H ; Setting DDRAM Address on Second Line
lcall command
; Clearing the Previous Key Pressed Information from Screen
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#0c0H ; Setting DDRAM Address on Second Line To Display “Key Pressed”
lcall command
; Display "KEY" and Pressed Information
mov a,#' '
lcall datw
mov a,#'T'
lcall datw
mov a,#'E'
lcall datw
mov a,#'M'
lcall datw
mov a,#'P'
lcall datw
mov a,#' '
lcall datw
mov a,#'I'
lcall datw
mov a,#'/'
lcall datw
mov a,#'P'
lcall datw
mov a,#' '
lcall datw
RET
END
i am doing project on temperature control and monitoring system .i have completed adc0804 interfacing with at89c51 microcontroller and now i am working on lcd n keypad interfacing with microcontroller.I need a two line LCD one for displaying the measured temperature and other for displaying the desired temperature taken from keypad input.
i have written test program for lcd and keypad interfacing..this program displays "temperature " on first line and "temp i/p :" followed by a letter from keypad input......As soon as another input is given from keypad previous keypad input gets deleted. i need to 2 chracter input from keypad (temperature) and it must be converted to binary form and be supplied to microcontroller port on second line
On first line of lcd i need to display the digitized temperature in decimals....
the adc converts temperature in the following format. 1 bit change per 2 Centigrade rise in temperature .
1 C , 2C ----------- 1 (adc o/p)
3 C , 4 C--------------- 10
5C ,6 C----------------- 11
plz help me ,I have tried my best but couldn,t get output.......I am attaching the ckt diagram n codes
codes:
INCLUDE 8051.mc
;port 1 lcd, port 2 keypad
;EN EQU P3.0
;RS EQU P3.1
;RW EQU P3.2
org 0000H
LJMP main
ORG 0013H ; INT1 ISR
CLR ie.7
INC R0
RETI
org 0030H
main:
MOV R4, #0 ; Counters for LCD
MOV R5, #0
MOV R6, #0
MOV R0, #0
mov A,#38H ; Setting Up the LCD
lcall command
mov A,#0EH ; Display On
lcall command
mov A,#06H ; Entry Mode
lcall command
mov a,#82H
lcall command
lcall disp ; Function Disp Called
mov a,#02H ; Setting DDRAM Address to Home position
lcall command
lcall delay1
; Displays temperature measured ON FIRST LINE OF LCD
mov a,#'T'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#'M'
lcall datw
mov a,#'P'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#'R'
lcall datw
NOP
mov a,#'A'
lcall datw
NOP
mov a,#'T'
lcall datw
NOP
mov a,#'U'
lcall datw
NOP
mov a,#'R'
lcall datw
NOP
mov a,#'E'
lcall datw
NOP
mov a,#':'
lcall datw
NOP
MOV A,#255 ; Moving Value 255 to PORT 2
MOV P2,A
; Keypad Scan Begins
sd:
lcall delay1
lcall key1
lcall delay
lcall key2
lcall delay
lcall key3
lcall delay
lcall key4
lcall delay
lcall sd
; Function to Send Commands to LCD
command:
clr P3.2
clr P3.1
setB P3.0
MOV P1,A
lcall delay
clr P3.0
RET
; Function to Clear the DDRAM Content
clear:
mov A,#01H
lcall command
lcall delay
mov A,#02H ; Set The DDRAM Address to Home Position
lcall command
lcall delay
RET
; Function to Display Data on LCD Screen
datw:
SETB P3.1
clr P3.2
SETB P3.0
MOV P1,A
lcall delay
clr P3.0
RET
;Function to Display The Key Pressed
datw1:
lcall delay1
lcall disp
lcall delay1
MOV A,R7
lcall datw
RET
; Generating Small Delay
delay:
mov r0,#255
loop: DJNZ r0,loop;
RET
; Generating a Bigger Delay
delay1:
mov r1,#255
loop1: mov r3,#120
loop2: djnz r3,loop2
djnz r1,loop1
RET
; Checking for Key Press on The First Column of 4x4 Matrix
KEY1:
MOV A,r5
MOV r6,A
clr p2.4
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,n1
MOV r7,#'1'
lcall datw1
lcall delay1
n1: cjne r2,#13,n2
mov r7,#'4'
lcall datw1
lcall delay1
n2: cjne r2,#11,n3
mov r7,#'7'
lcall datw1
lcall delay1
n3: cjne r2,#7,n4
mov r7,#'*'
lcall datw1
lcall delay1
n4: lcall delay1
SETB P2.4
RET
; Checking for Key Press on the Second Column of 4x4 Matrix
KEY2:
clr p2.5
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,q1
mov r7,#'2'
lcall datw1
lcall delay1
q1: cjne r2,#13,q2
mov r7,#'5'
lcall datw1
lcall delay1
q2: cjne r2,#11,q3
mov r7,#'8'; A=65
lcall datw1
lcall delay1
q3: cjne r2,#7,q4
mov r7,#'0'
lcall datw1
lcall delay1
q4: lcall delay
SETB p2.5
RET
; Checking for Key Press On The Third Column of 4x4 Matrix
KEY3:
clr p2.6
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,w1
mov r7,#'3'
lcall datw1
lcall delay1
w1: cjne r2,#13,w2
mov r7,#'6'
lcall datw1
lcall delay1
w2: cjne r2,#11,w3
mov r7,#'9'
lcall datw1
lcall delay1
w3: cjne r2,#7,w4
mov r7,#'#'
lcall datw1
lcall delay1
w4: lcall delay1
SETB p2.6
RET
; Checking for Key Press on the Fourth Column of 4x4 Matrix
KEY4:
clr p2.7
MOV A,p2
ANL A,#0FH
MOV r2,A
cjne r2,#14,e1
mov r7,#' '
lcall datw1
lcall delay1
e1: cjne r2,#13,e2
mov r7,#' '
lcall datw1
lcall delay1
e2: cjne r2,#11,e3
mov r7,#' '
lcall datw1
lcall delay1
e3: cjne r2,#7,e4
mov r7,#' '
lcall datw1
lcall delay1
e4: lcall delay1
SETB p2.7
RET
disp:
mov a,#0c0H ; Setting DDRAM Address on Second Line
lcall command
; Clearing the Previous Key Pressed Information from Screen
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#' '
lcall datw
mov a,#0c0H ; Setting DDRAM Address on Second Line To Display “Key Pressed”
lcall command
; Display "KEY" and Pressed Information
mov a,#' '
lcall datw
mov a,#'T'
lcall datw
mov a,#'E'
lcall datw
mov a,#'M'
lcall datw
mov a,#'P'
lcall datw
mov a,#' '
lcall datw
mov a,#'I'
lcall datw
mov a,#'/'
lcall datw
mov a,#'P'
lcall datw
mov a,#' '
lcall datw
RET
END