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.

ADC 0804 and 89c51 interfacing

Status
Not open for further replies.

manigr8

Newbie level 2
Newbie level 2
Joined
Jul 10, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
21
Hi, I'm facing problem interfacing ADC and 89c51. I'm giving an analog voltage to ADC 0804 from 0-5 volts and the output is connected to port 1 of 89c51. the port 2 of microcontroller is connected to 8 bit LCD. I want to callibrate, when i change the voltage from 0-5 the LCD displays from 0-100. Vref/2 is open, step size is 19.53mV. I've trid a lot but there is nothing on the Lcd except a cursor that shifts towads right three time. I would be very thankful if someone help me trace out the fault.




#include <reg51.h>
#define output P2
#define cmdport P3
#define input P1

sbit read = P3^5;
sbit write =P2^2;
sbit INTR =P2^7;
sbit rs= cmdport^0; //lcd instruction
sbit rw=cmdport^1;
sbit e = cmdport^6;
void delay(unsigned int);
void lcdcmd(unsigned int);
void lcd();
void lcddata(unsigned int);


void main ()
{
unsigned char temp,x,a,b,c,y;

INTR=1;
read=1;
write=1;

while (1)
{
lcd();

write=0;
write=1;
while(INTR==1);
read=1;

y=input;
temp=y/2.55;
x=temp/10;
a=temp%10;
b=x%10;
c=x/10;

lcddata(c);
lcddata(b);
lcddata(a);

read=0;

}
}


void lcd()
{

delay(10);
lcdcmd(0x38); //lcd command
delay(10);
lcdcmd(0x0E); //lcd command
delay(10);
lcdcmd(0x01);
delay(10);
lcdcmd(0x06);
delay(10);

}


// DELAY

void delay(unsigned int msec )
{
unsigned int i;
for (i=0; i<msec; i++)
{

TMOD=0x01;
TH0=0x00;
TL0=0x0f;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;

}
}

// LCD instructions

void lcdcmd(unsigned int item)
{
P2 = item;
rs=0;
rw=0;
e=1;
delay(1);
e=0;

}
// Display Value

void lcddata(unsigned char j)
{
rs=1;
rw=0;
P2 =j;
e=1;
delay(1);
e=0;
}
 


Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top