Anda di halaman 1dari 3

ADC

See chapter 13, first article, for the details of ADC0804 IC. Following are the pin configuration of ADC0804:

Testing ADC 0804 on Proteus doesnt need CLK IN and CLK R pin connections but applying that on hardware definitely will need capacitor and resistor at CLK pins as shown above.

Test Code for ADC 0804


Below is a simple circuit to test ADC 0804. Analog signal is fed to ADC using potentiometer. The digital output is fed to AT89C51 at Port 1 which sends it to Port 2 where LEDs are connected.

The potentiometer value can be changed using up and down arrows. Zoomed potentiometer is shown below.

Finally voltmeter is attached to show the present output voltage of the potentiometer. Vref/2 is not connected which means Vref/2=2.5 Volts or Vref=5 Volts. So the 8 bit digital data has 256 levels with each level equal to 5/256=0.01953125Volts.

Code:
ORG 0H R BIT P3.2 W BIT P3.3 INTR BIT P3.4 MOV P1,#0FFH SETB INTR BACK: ; Read Pin ; Write Pin ; Interrupt Pin ;make P1 = input

CLR W SETB W HERE: JB INTR,HERE CLR R SETB R MOV A,P1 MOV P2,A SJMP BACK

;Write = 0 ;Write = 1 L-to-H to start conversion ;wait for end of conversion ;conversion finished, enable Read ;make Read=1 for next round ;digital data stored in reg. A ;digital data sent to LEDs

END

Sample Check:
Suppose potentiometer output is 3.00 Volts. What should be the digital output? As each level is of 0.0195 Volts so 3.00 volts would be 3/0.01953125=153.8=153.6 level which will be quantized to 153rd level. So digital output should be binary conversion of 153. 153 converted to binary is: 10011001 You can verify it from Proteus scheme as shown below that voltmeter is showing 3.00 Volts and LEDs are showing 10011001.

How to use it in your Project


You already know how to display on LCD. ADC interfacing should be clear with this document. Now what you have to do is simply that you will connect sensors output at VIN+ pin and will select appropriate Vref/2 according to your sensors maximum output voltage. In programming ADC part is given in this document. You just need to make one method CONVERSION that will convert digital data to respect level value in decimal and corresponding ASCII characters. And then you need to create DISPLAY method that will display it at LCD. Every part has been explained to you in much detail, you just need to combine all this into a single application. But the interesting thing is that you have to do it using C language

BEST OF LUCK