Analog to Digital Conversion


Introduction

To be able to implement analog to digital conversion using the ADC0804LCN 8-bit A/D converter. You will design a circuit and program the chip so that when an analog signal is given as input, the equivalent digital voltage is displayed on an LCD display. Thus, in effect, your circuit should function like a simple voltmeter.

The ability to convert analog signals to digital and vice-versa is very important in signal processing. The objective of an A/D converter is to determine the output digital word corresponding to an analog input signal.

The Datasheet for ADC0804LCN shows the pinout and a typical application schematic. The A/D converter operates on the successive approximation principle. Analog switches are closed sequentially by successive-approximation logic until the analog differential input volatge[Vin(+) - Vin(-)] matches a voltage derived from a tapped resistor string across the reference voltage.

The normal operation proceeds as follows. On the high-to-low transition of the WR input, the internal SAR latches and the shift-register stages are reset, and the INTR output will be set high. As long as the CS input and WR input remain low, the A/D will remain in a reset state. Conversion will start from 1 to 8 clock periods after at least one of these inputs makes a low-to-high transition. After the requisite number of clock pulses to complete the conversion, the INTR pin will make a high-to-low transition. This can be used to interrupt a processor, or otherwise signal the availability of a new conversion. A RD operation(with CS low) will clear the INTR line high again. The device may be operated in the free-running mode by connecting INTR to the WR input with CS=0.

Since this is an 8-bit A/D converter, a voltage from 0-5V. O will be repersented as 0000 0000 (0 in decimal) and 5V is represented as 1111 1111 (256 in decimal). To convert a value X volts to decimal, use the following formula:

          X * 5.0
          -------
            256
   
To get a better resolution, and display the vlaue as a floating point number, you can multiply the numerator by a factor of 100, 1000 etc. and then print the voltage accordingly.

Assignment:

  1. Interface the ADC0804LCN to the 8051
  2. Vary the voltage to Vin(+)
  3. Output the digital value of the voltage on the LCD

Apparatus Required:

  1. ADC0804LCN
  2. 10k resistor
  3. 1k resistor
  4. 150 pF capacitor
  5. LCD
  6. 12 MHz crystal
  7. 5V power supply
  8. Philips PDS51 development board

Schematic:


Figure 1. Pinout



Figure 2. A/D Schematic


Program:

#include <reg51.h>
#include "io.h"


sbit READ = P3^2; /* Define these according to how you have connected the */
sbit WRITE = P3^3;/* RD, WR, and INTR pins                                */ 
sbit INTR = P3^4;


void main( void ) {

	unsigned char adVal;
	unsigned long volts;
	InitIO();

	READ = 1;
	WRITE = 1;
	INTR = 1;
	ClearScreen();

        while(1) {

               /* Make a low-to-high transition on the WR input */

               while( INTR == 1 );    /* wait until the INTR signal makes  */
                                      /* high-to-low transition indicating */
                                      /* completion of conversion          */

                         
                /* Read the voltage value from the port */              
                READ = 0;
                adVal = P1;
                READ = 1;

                /* Compute the digital value of the volatge read */

                /* Print the value of the voltage in decimal form */
	}
}

Procedure:

  1. Wire up the circuit as shown in the schematic.
  2. Edit, compile and run your program using PDS51.
  3. You need 2 voltage sources:
    • You need 5 volts to power the A2D chip, LCD, and eventually for the stand alone microcontroller.
    • The second voltage source will vary, this is the voltage source which you are measuring. NOTE: Do NOT turn input voltage higher than 5V or you may damage the ADC080X chip.
  4. Burn a chip and replace it with the emulator in your circuit.