Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/24/13 16:46
Read: times


 
#189453 - How to display data from a ADC0808 to a LCD
To start, I am using the ADC to read the analog input from a lm34 and display it on a lcd using a DS89C450 written in assembly. Now my lcd part of the code works just fine, the adc however works only partially. I know the output is right is right as I have hooked it up to led's and watched the output change as I heated up or cooled the sensor. Now one question I have is do I need the 10K pull-up resistors since im using P0, I know the datasheet says it does but just making sure if you need them with a ADC hooked up to P0 as I'm not trying to use it as an output to power something. Besides for that I have written the code from my school book that's all about the 8051 architecture and using trainer boards with the ds89c450. I will post the code also for everyone to see. From doing the math that happens through the binary to dec conversion and dec to ascii conversion it looks right but when the conversion happens it shows random symbols on the lcd, I have gotten a infinity symbol and question mark which is not even close, the temp where I am is 77 so the ascii should be 55 to represent the number 7.

So all in all I am asking is there anything wrong with my code or any suggestions, thanks.


...insert code here[ALE	BIT	P1.0
OE	BIT	P1.1
SC	BIT	P1.2
EOC	BIT	P1.3
MYDATA	EQU	P0
RAM_ADDR	EQU	40H
ASCI_RSULT	EQU	50H
COUNT	EQU	3

ORG	0H
                                                                                                                                    
	ACALL	LCD_INIT
	MOV	MYDATA,#0FFH
	SETB	EOC
	CLR	ALE
	CLR	SC
	CLR	OE
BACK:	
	ACALL	DELAY
	SETB	ALE
	ACALL	DELAY
	SETB	SC
	ACALL	DELAY
	CLR	ALE
	CLR	SC
	
HERE:
	JB	EOC,HERE
HERE1:
	JNB	EOC,HERE1
	SETB	OE
	ACALL	DELAY
	MOV	A,MYDATA
	CLR	OE
	ACALL	CONVERSION
	ACALL	DATA_DISPLAY
	SJMP	BACK

DATA_DISPLAY:
	ACALL	DELAY
	MOV	A,#91H
	ACALL	COMNWRT
	ACALL	DELAY
	MOV	A,@R1
	ACALL	DATAWRT
	ACALL	DELAY
	RET

CONVERSION:
	ACALL	BIN_DEC_CONVRT
	ACALL	DEC_ASCI_CONVRT
	RET
	
BIN_DEC_CONVRT:
	MOV	R0,#RAM_ADDR
	MOV	A,P0
	MOV	B,#10
	DIV	AB
	MOV	@R0,B
	INC	R0
	MOV	B,#10
	DIV	AB
	MOV	@R0,B
	INC	R0
	MOV	@R0,A
	RET
	
DEC_ASCI_CONVRT:
	MOV	R0,#RAM_ADDR
	MOV	R1,#ASCI_RSULT
	MOV	R2,#3
BACK1:
	MOV	A,@R0
	ORL	A,#30H
	MOV	@R1,A
	INC	R0
	INC	R1
	DJNZ	R2,BACK1
	RET

LCD_INIT:	ACALL	COMNWRT
ACALL	DELAY
MOV	A,#38H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#32H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#28H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#0EH
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#01
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#06H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#80H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'A'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'C' 
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'U'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'A'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'L'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#87H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'P'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0C0H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'S'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0C4H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'T'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'P'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#94H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'M'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'O'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'D'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'E'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#0D4H
ACALL	COMNWRT
ACALL	DELAY
MOV	A,#'J'
ACALL	DATAWRT
ACALL	DELAY
MOV	A,#'B'
ACALL	DATAWRT
ACALL	DELAY
RET

COMNWRT:
	MOV	R1,A
	ANL	A,#0F0H
	MOV	P2,A
	CLR	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R1
	ANL	A,#0FH
	RL	A
	RL	A
	RL	A
	RL	A
	MOV	P2,A
	CLR	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	RET
	
DATAWRT:
	MOV	R1,A
	ANL	A,#0F0H
	MOV	P2,A
	SETB	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	MOV	A,R1
	ANL	A,#0FH
	RL	A
	RL	A
	RL	A
	RL	A
	MOV	P2,A
	SETB	P3.7
	SETB	P3.6
	ACALL	DELAY
	CLR	P3.6
	RET	
	
DELAY:
	MOV	R5,#9
H3:	MOV	R4,#242
H2:	MOV	R3,#255
H1:	DJNZ	R3,H1
	DJNZ	R4,H2
	DJNZ	R5,H3
	RET
	
	END



]


List of 22 messages in thread
TopicAuthorDate
How to display data from a ADC0808 to a LCD            01/01/70 00:00      
   Comments, please            01/01/70 00:00      
      Comments            01/01/70 00:00      
         Code Fragments            01/01/70 00:00      
            Commenst added, reply to hal            01/01/70 00:00      
               comments            01/01/70 00:00      
                  comments            01/01/70 00:00      
                     Program flow            01/01/70 00:00      
                        comments            01/01/70 00:00      
                           Clarification & Suggestions            01/01/70 00:00      
                              GREAT HELP            01/01/70 00:00      
                                 Data Display loop            01/01/70 00:00      
                                    Worked sorta            01/01/70 00:00      
                                       The output            01/01/70 00:00      
                                          I looked at it wrong            01/01/70 00:00      
                                             Works            01/01/70 00:00      
                                                Great news!            01/01/70 00:00      
                                                   Thank you            01/01/70 00:00      
                                                      You're Welcome            01/01/70 00:00      
                                                      A couple of questions            01/01/70 00:00      
                                                         Answers and questions            01/01/70 00:00      
                                                            Thanks            01/01/70 00:00      

Back to Subject List