![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) | |
| Hi all, After so much time i am using ADC0808 again in one of the tasks... The algorithm i am following is this: Quote:
Regards, Simran..
__________________ Simran.. 8051 Specialist.. Last edited by simrantogether; 28th January 2008 at 10:12 AM. | ||
| |
| | (permalink) |
| 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++)
{
}
}
}
__________________ Simran.. 8051 Specialist.. | |
| |
| | (permalink) |
| Hi, If anyone has algorithm for ADC 0808 interfacing with a micro controller ... please tell... Or, Please check my upper algorithm... Regards, Simran..
__________________ Simran.. 8051 Specialist.. | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) | |
| Quote:
Regards, Simran..
__________________ Simran.. 8051 Specialist.. | ||
| |
| | (permalink) |
| I don't think the outputs from the ADC0808 are able to directly drive LEDs. Mike. | |
| |
| | (permalink) |
| 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..
__________________ Simran.. 8051 Specialist.. | |
| |
| | (permalink) |
| 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;
}
} | |
| |
| | (permalink) | |
| Quote:
Thanks... Regards, Simran..
__________________ Simran.. 8051 Specialist.. | ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC12F675 ADC Circuit help. | MERV | Micro Controllers | 4 | 16th January 2008 09:06 PM |
| ADC troubles | andy257 | General Electronics Chat | 4 | 2nd December 2007 06:49 PM |
| Analog to Digital Converter (ADC) | simonmada | Electronic Projects Design/Ideas/Reviews | 15 | 15th November 2007 04:31 AM |
| HS1101 capacitive humidity sensor; need nearly linear voltage to feed to a 1-wire ADC | FirefighterBlu3 | Electronic Projects Design/Ideas/Reviews | 5 | 20th October 2007 12:06 AM |
| 16F877 Timer0 Interrupt Affecting ADC | sebana | Micro Controllers | 13 | 12th September 2007 10:43 AM |