Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[51] problem in using adc0808 with lm35 and 8051

Status
Not open for further replies.

raghavkmr

Junior Member level 2
Junior Member level 2
Joined
Nov 26, 2013
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
194
i am using following code to see output in lcd of temperature , i dont understand why output is wrong on lcd on proteus i m giving vref = 2.56V

Code:
#include<reg51.h>

sfr adcdata = 0x90;		              //assigning adc data to port 1
sfr ldata = 0x80 ;			  //assigning lcd data to port 0
sbit rs=P2^7;		              // assining control pins to port2.5,6,7
sbit rw=P2^6;	
sbit en=P2^5;

// channel selection bits of adc
sbit addr_c=P3^2;			
sbit addr_b=P3^3;
sbit addr_a=P3^4;
 // control pins of adc
sbit ale=P3^5;		             //address latch enble pin   
sbit eoc=P3^6;		            // end of converssion pin
sbit sc=P3^7;		            //select chip pin
sbit oe=P3^1;
sbit wave = P2^4;
	 	void delay(unsigned int k);
	 	void cmd(unsigned char  y);		          //lcd command function	
		void lcddata(unsigned char  y);	 
		void lcdinit(void);	
		unsigned char z;

	 unsigned char convertanddisplay(unsigned char value)
{
    unsigned char x,d1,d2,d3;
   d1=value%10;
   value=value/10;
   d2=value%10;
   value=value/10 ;
   d3=value%10	   ;
   lcddata(d3+0x30) ;
   lcddata(d2+0x30)	 ;
   lcddata(d1+0x30)	  ;
	cmd(0x01);	                       //move data d1 to lcd
   z=d1*100+d2*10+d3;
	delay(1) ;
   return(z);
} 
void timer0(void) interrupt 1
{
wave= ~wave ;
}

void main()
{
  unsigned char value;

TMOD =0x02;
TH0=-1;
IE=0x82;
TR0=1 ;

adcdata=0xff;
eoc =1 ;
ale = 0;
oe=0 ;
lcdinit();
sc=0 ;
while(1)
 {
 	addr_c=0;
	addr_b=0;
	addr_a=1;
	delay(1);
	ale=1;
	delay(1);
	sc=1;
	delay(1);
	ale=0;
	sc=0;
	while(eoc==1);
	while(eoc==0);
	oe=1;
	//delay(1);
	value=adcdata;
	z=	convertanddisplay(value);
	oe=0;		  

	 }
}

void delay(unsigned int k)
{
unsigned int i,j;
for(i=0;i<k;i++)
for(j=0;j<1200;j++);
}

void cmd(unsigned char ch)
  {
	ldata = ch;
	rs = 0;
	rw = 0;
	en = 1;
	delay(1);
	en = 0;
	return;
  }

  void lcddata(unsigned char cm)
  {
	ldata = cm;
	rs = 1;
	rw = 0;
	en = 1;
	delay(1);
	en=0;
	return;
  }
  void lcdinit()	                             //lcd initialize
{
cmd(0x38);                            // 2 lines and 5x7 matrix
cmd(0x0e);                            //display on, cursor blinking
cmd(0x01);                           //clear display screen
cmd(0x06);                           //increment cursor
cmd(0x80);  
}
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top