Low Voltage Circuit

Voltmeter using 8051

This article shows how to make a basic 0-5V voltmeter with the 8051. Although the sensitivity of this digital voltmeter is just 200mV, it is intended to demonstrate how an ADC and seven segment display may be interfaced to an 8051 to receive a digital readout of the input voltage. Soon, a 31/2-digit high-end voltmeter will be available. The ADC used in this project is ADC0804, and the controller is AT89S51. Look over these projects before attempting this one. Interfacing an ADC to an 8051 and Interfacing a seven-segment display to an 8051 will provide you with a thorough understanding of the fundamentals.

Circuit diagram.

The ADC’s Vref/2 (pin9) is left open in this design, which implies the input voltage range is 0 to 5V and the step size is 5/255 = 19.6mV. Dout = Vin/Step size is the equation for the ADC0804’s digital output. For a 1V input voltage, the digital output will be 1/19.6mV = 51, which is the binary equivalent of 51, which is 00110011. The ADC’s digital output is connected to the microcontroller’s pin P1.0. The P3.7, P3.6, P3.5, and P3.4 pins of the microcontroller provide control signals for the ADC, namely CS, RD, WR, and INTR. The microcontroller’s Port0 is connected to a two-digit multiplexed seven-segment display.P3.2 and P3.1 of the microcontroller provide control signals for the display driver transistors Q1 and Q2. A debouncing reset circuitry is formed of push button switch S1, capacitor C2, and resistor R10.

Program.

ORG 00H
MOV P1,#11111111B
MOV P0,#00000000B
MOV P3,#00000000B
MOV DPTR,#LABEL
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 B,#2D
MUL AB
MOV B,#10D
DIV AB
SETB P3.2
ACALL DISPLAY
MOV P0,A
ACALL DELAY
MOV P0,#10000000B
ACALL DELAY
MOV A,B
CLR P3.2
SETB P3.1
ACALL DISPLAY
MOV P0,A
ACALL DELAY
CLR P3.1
SJMP MAIN
DELAY: MOV R3,#02H
DEL1: MOV R2,#0FAH
DEL2: DJNZ R2,DEL2
DJNZ R3,DEL1
RET
DISPLAY: MOVC A,@A+DPTR
RET
LABEL: DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH
END