Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Adc 0808

Status
Not open for further replies.
Hi all,

After so much time i am using ADC0808 again in one of the tasks...


The algorithm i am following is this:

• Select an analog channel by provide bits to A, B, C.
• Activate ALE with a low-to-high pulse.
• Activate SC with a high-to-low pulse (start conversion) The conversion is begun on the falling edge of the start conversion pulse. you can use circuit like

• Monitor EOC Pin .After conversion this pin goes high.
• Activate OE with a high-to-low pulse to read data out of the ADC chip.

Please suggest why the output from ADC is not received...

Regards,

Simran..
 
Last edited:
C Program...

Hi,

This is the code i designed from that algorithm...

Code:
#include<reg51.h>

sbit A0 		   = P0^0;
sbit A1			   = P0^1;
sbit A2 		   = P0^2;
sbit ADC_ALE		= P0^3;
sbit ADC_OE 		= P0^4;
sbit ADC_EOC 		= P0^5;
sbit ADC_START 	       = P0^7;

void msdelay(unsigned int);

void main(void)

{

while(1)
{

P0 = 0x00; // making all the bits of ports as 0

A0 = 1;
A1 = 1;
A2 = 1;	// Selecting input channel 7 by putting A1 , A2 and A3 = 1

ADC_ALE = 0;

msdelay(50);

ADC_ALE =1;		// this address of analog channel is latched with rising edge of ALE

msdelay(50);

ADC_START = 1;

msdelay(50);

ADC_START = 0;  // falling edge of ADC_START atarts the conversion of ADC


msdelay(50);	

	if(ADC_EOC = 1)
	{

	ADC_OE = 1;

	msdelay(50);

	ADC_OE = 0;

	msdelay(50);
	}

}
}





//----------------------------- Delay Routine ---------------------


void msdelay(unsigned int i)
{

unsigned int j,k;

 for(j=1; j<=i;j++)
 {
 	for(k=1;k<=1275;k++)
 	{
 	}
 	
 }

}
 
If anyone...

Hi,

If anyone has algorithm for ADC 0808 interfacing with a micro controller ...

please tell...

Or,

Please check my upper algorithm...

Regards,

Simran..
 
Your code looks fine, however, you don't appear to have the data lines connected to your processor. When you set OE high, the converted value appears on D0-D7 and you need to connect them to a port and read them.

Mike.
 
Well...

Pommie said:
Your code looks fine, however, you don't appear to have the data lines connected to your processor. When you set OE high, the converted value appears on D0-D7 and you need to connect them to a port and read them.

Mike.

Actually i interfaced the output of ADC with the LED's ...

Regards,

Simran..:)
 
I don't think the outputs from the ADC0808 are able to directly drive LEDs.

Mike.
 
Yes...

Hi,

Yes they can...

because i used uln2803 between ADC and LED's...

Problem i find is with Code i feel...

Please check the algorithm...

Regards,

Simran..:)
 
You are not waiting for the conversion to complete.

Try,
Code:
void main(void){
    while(1){    
        P0 = 0x00;         // making all the bits of ports as 0    
        A0 = 1;
        A1 = 1;
        A2 = 1;	           // Selecting input channel 7 by putting A1 , A2 and A3 = 1    
        ADC_ALE = 0;    
        msdelay(50);    
        ADC_ALE =1;        // this address of analog channel is latched with rising edge of ALE    
        msdelay(50);    
        ADC_START = 1;    
        msdelay(50);    
        ADC_START = 0;      // falling edge of ADC_START atarts the conversion of ADC    
        msdelay(50);	
        while(ADC_EOC!=1);  //wait for conversion to end    
        ADC_OE = 1;
        msdelay(500);       //allow time for LEDs to be viewed.
        ADC_OE = 0;
    }
}

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top