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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
James Brzycki
02/24/13 09:46
Read: 2640 times
Hammond
Us


 
#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      James Brzycki      02/24/13 09:46      
   Comments, please      Hal Albach      02/24/13 17:25      
      Comments      James Brzycki      02/24/13 17:56      
         Code Fragments      Hal Albach      02/24/13 21:01      
            Commenst added, reply to hal      James Brzycki      02/24/13 21:11      
               comments      Hal Albach      02/24/13 22:46      
                  comments      James Brzycki      02/25/13 06:33      
                     Program flow      Hal Albach      02/25/13 11:40      
                        comments      James Brzycki      02/25/13 21:45      
                           Clarification & Suggestions      Hal Albach      02/26/13 07:44      
                              GREAT HELP      James Brzycki      02/26/13 11:39      
                                 Data Display loop      Hal Albach      02/26/13 12:24      
                                    Worked sorta      James Brzycki      02/27/13 06:57      
                                       The output      Hal Albach      02/27/13 15:29      
                                          I looked at it wrong      James Brzycki      02/27/13 17:19      
                                             Works      James Brzycki      02/27/13 20:35      
                                                Great news!      Hal Albach      02/28/13 07:05      
                                                   Thank you      James Brzycki      02/28/13 07:15      
                                                      You're Welcome      Hal Albach      02/28/13 08:33      
                                                      A couple of questions      Hal Albach      02/28/13 11:06      
                                                         Answers and questions      James Brzycki      02/28/13 11:54      
                                                            Thanks      Hal Albach      02/28/13 12:36      

Back to Subject List