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.

Problem Processing the adc value in 8051

Status
Not open for further replies.

thannara123

Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,580
Helped
122
Reputation
244
Reaction score
114
Trophy points
1,353
Location
India
Activity points
10,377
ADC is working output is shown in bar LED . and the data is given to the Port - P1.
And again the Port 1 vaule is given to the Port 3 ( just for testing )
nothing showing ..
please help me ?

Code:
#include <REGX51.H>

#include "lcd.h"
#include "adc.h"


void main(){  unsigned char a = 0;
P2 =0x00;
P0 =0x00;
P1 = 0xff;
P3 = 0x00;
lcd_init();
lcd_cmd(0x80);
lcd_data(54);     // just send "1" to lcd to display ;
string("t");
lcd_cmd(0xc0);
conv(); //Start conversion
read(); //Read ADC
  P3 = P1;
lcd_data(a);
while(1);
}
Proteus file attached .
View attachment hh.bmp
 

Attachments

  • adc.rar
    32.9 KB · Views: 62
Last edited:

Re: ADC is working but cant processes the adc value in 8051

sir ignore that
// a = 48 + P1;
yes P1 the adc data port connected .
is and assigned to P3 = P1;

If i give ADC input as 5 volt the all LED blinks ,that means the adc output are correct , but the data is not came at the 8051 P1 port . why so
how to make a port as input
P1 = 0xff ?

what is the wrong with me ?

I think the voltage from the ADC is too low ?
when I give an extra 5 volt to some of the port of the P1 ,gives the value to P3 ( ie working )
how can i rectify ?
please help me ?
 
Last edited:

Re: ADC is working but cant processes the adc value in 8051

yes I uploaded the proteus file ?
I dont connected Vref/2 . step size considered as 19.53 (just for testing )
 

Re: ADC is working but cant processes the adc value in 8051

But i can get the correct value from adc ?
 

Re: ADC is working but cant processes the adc value in 8051

INTR is used in conv() or read(). Post full code.

Put

Code C - [expand]
1
conv() and read()

and also lcd display functions inside while(1) loop. According to your code you are reading adc once and displaying once. After that if adc value changes you are not updating.
 

Re: ADC is working but cant processes the adc value in 8051

Code:
#define cs P0_0 
#define rd P0_1
#define wr P0_2 
#define intr P0_3

void conv(); //Start of conversion function
void read(); //Read ADC function

unsigned char adc_val;
  
void conv() {
cs = 0; //Make CS low
wr = 0; //Make WR low
wr = 1; //Make WR high
cs = 1; //Make CS high
while (intr); //Wait for INTR to go low
}

void read() {
cs = 0; //Make CS low
rd = 1; //Make RD low
 adc_val = P1;
rd = 0; //Make RD high
cs = 1; //Make CS high
}
 

Re: ADC is working but cant processes the adc value in 8051

Now gets the value at pin P1 and can be assigned in P3
P3 = P1;

But it shows only in 1 MHZ frequency .
anybody help me ?
 

Re: ADC is working but cant processes the adc value in 8051

Yes .i tried with diffrent crystal code as a debug ...
 

Re: ADC is working but cant processes the adc value in 8051

I have already uploaded ..
 

Attachments

  • proteus + code.zip
    58 KB · Views: 54

Re: ADC is working but cant processes the adc value in 8051

Thanks but what was the problem sir ?:sad:
 

Re: ADC is working but cant processes the adc value in 8051

The problem was you cannot connect LED to P1 and also ADC0804 o/p because ADC o/p pins will be o/p but P1 pins will be inputs.
 
I want to change that ADC value to volt how to rewrite program ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top