ADC Interfacing 0804 (with 8051)
Download here the datasheet download
The easiest way to do analog to digital conversion is to use an IC such as the ADC0804 that does the work for you. The analog voltage is applied to pin 6 and the result is available at pins 11 through 18. We will connect pin 1 and 2 (Chip Select and Read) to ground so that the chip is always enabled. (If you wanted to use more than one ADC you could use this pin to control which chip is currently enabled).
Connect pin 7 (Vin - ) to ground. The ADC0804 includes an internal oscillator which requires an external capacitor and resistor to operate. Connect the 150 pF capacitor from pin 4 (CLOCK IN) to ground and the 10k ohm resistor from pin 4 to pin 19 (CLOCK R).
ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single channel IC, i.e., it can take only one analog signal as input. The digital outputs vary from 0 to a maximum of 255. The step size can be adjusted by setting the reference voltage at pin9. When this pin is not connected, the default reference voltage is the operating voltage, i.e., Vcc. The step size at 5V is 19.53mV (5V/255), i.e., for every 19.53mV rise in the analog input, the output varies by 1 unit. To set a particular voltage level as the reference value, this pin is connected to half the voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2), thereby reducing the step size to 15.62mV (4V/255).
Download here the datasheet download
The easiest way to do analog to digital conversion is to use an IC such as the ADC0804 that does the work for you. The analog voltage is applied to pin 6 and the result is available at pins 11 through 18. We will connect pin 1 and 2 (Chip Select and Read) to ground so that the chip is always enabled. (If you wanted to use more than one ADC you could use this pin to control which chip is currently enabled).
Connect pin 7 (Vin - ) to ground. The ADC0804 includes an internal oscillator which requires an external capacitor and resistor to operate. Connect the 150 pF capacitor from pin 4 (CLOCK IN) to ground and the 10k ohm resistor from pin 4 to pin 19 (CLOCK R).
For getting More information Look Here
Interfacing adc
Circuits
Code
Circuits
Code
#include <REGX51.H>
#define output P2
sbit wr = P1 ^ 1;
sbit rd = P1 ^ 0;
sbit intr = P1 ^ 2;
void delay(unsigned int msec)
{
int i, j;
for (i = 0; i < msec; i++)
for (j = 0; j < 1275; j++);
}
void adc()
{
rd = 1;
wr = 0;
delay(1);
wr = 1;
while (intr == 1);
rd = 0;
delay(1);
intr = 1;
}
void main()
{
while (1) {
adc();
{
delay(100);
}
}
}
#define output P2
sbit wr = P1 ^ 1;
sbit rd = P1 ^ 0;
sbit intr = P1 ^ 2;
void delay(unsigned int msec)
{
int i, j;
for (i = 0; i < msec; i++)
for (j = 0; j < 1275; j++);
}
void adc()
{
rd = 1;
wr = 0;
delay(1);
wr = 1;
while (intr == 1);
rd = 0;
delay(1);
intr = 1;
}
void main()
{
while (1) {
adc();
{
delay(100);
}
}
}