Analog to digital converter. This project is about a simple analog to digital converter based on the ADC0804 IC. ADC0804 is an 8-bit ADC with adjustable step size. It is very easy ti interface it to microcontrollers. In face am ADC circuit like this one is very essential for designing systems based on microcontrollers like 8051 which does not have a built in ADC.
About the circuit. Resistor R2 and capacitor C2 are associated with the clock circuit of the ADC. Preset resistor R3 is used for adjusting the Vref/2 voltage of the ADC. The step size of the ADC depends on the voltage we give at the Vref/2 pin of the ADC. The table given below shows different Vref/2 values and corresponding step sizes.
Input voltage is applied across Vin+ and Vin- pins of the ADC. Capacitor C1 is used to by-pass any noise or fluctuation present in the input voltage. If this capacitor is not used, the ADC output will not be stable for fastly varying inputs. Digital output is available across D0 to D7 pins of the ADC.
Control signals are given to CS, RD, RW and INTR pins of the ADC. To make a conversion by the ADC, CS is made 0 and a low to high transition is given to WR pin. The INT pin will become zero if the conversion is finished. The CS is made 0 and a high to low transition is given to WR pin for reading the data from the ADC. Photo graph of the ADC board connected with an 8051 based voltmeter circuit is shown below.
Program. The code for the voltmeter is given below.
ORG 00H RS EQU P2.7 RW EQU P2.6 E EQU P2.5 MOV DPTR,#LUT MOV P1,#11111111B MOV P0,#00000000B MOV P3,#00000000B MOV P2,#00000000B
MAIN: CLR P3.7 SETB P3.6 CLR P3.5 SETB P3.5 WAIT: JB P3.4,WAIT CLR P3.7 CLR P3.6 MOV A,P1 MOV B,#10D DIV AB MOV R3,B MOV B,#10D DIV AB MOV R2,B MOV R1,A ACALL DINT ACALL VOLT ACALL TEXT SJMP MAIN
VOLT: MOV A,R3 ACALL ASCII ACALL DISPLAY MOV A,R2 ACALL ASCII ACALL DISPLAY MOV A,R1 ACALL ASCII ACALL DISPLAY RET
TEXT:MOV A,#" " ACALL DISPLAY MOV A,#"V" ACALL DISPLAY MOV A,#"o" ACALL DISPLAY MOV A,#"l" ACALL DISPLAY MOV A,#"t" ACALL DISPLAY MOV A,#"s" ACALL DISPLAY RET
DINT:MOV A,#0FH ACALL CMD MOV A,#01H ACALL CMD MOV A,#06H ACALL CMD MOV A,#83H ACALL CMD MOV A,#3CH ACALL CMD RET
CMD: MOV P0,A CLR RS CLR RW SETB E CLR E ACALL DELAY RET
DISPLAY:MOV P0,A SETB RS CLR RW SETB E CLR E ACALL DELAY RET
DELAY: CLR E CLR RS SETB RW MOV P0,#0FFh SETB E MOV A,P0 JB ACC.7,DELAY CLR E CLR RW RET
ASCII: MOVC A,@A+DPTR RET
LUT: DB 48D DB 49D DB 50D DB 51D DB 52D DB 53D DB 54D DB 55D DB 56D DB 57D