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.

### About the circuit.

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

### About the program.

The programme first instructs the ADC to generate a digital output that corresponds to the input voltage. P1.0 scans this digital output and loads it into the accumulator. The accumulator value is then divided by 10 to remove the last digit. Let’s say the input voltage is 4 volts. The ADC’s corresponding digital output will be 204D (D stands for decimal) in this case. The value left in the accumulator after the division by 10 is 20D. This 20D is then multiplied by 2D to yield 40D. The program’s next goal is to operate the 40D and display a 4.0 readout on the screen. For this, the 40D is split by 10D once again.This results in a value of 4 in the accumulator and a value of 0 in the B register. The programme then uses the lookup table to obtain the digit drive pattern for 4, places it on Port 0, and activates Q1. 10000000B is loaded to P0 after a 1 ms delay, which accounts for the dot. Q1 is disabled after another 1ms delay, the content in B (ie 0) is shifted to A, the correct digit drive pattern for 0 is obtained using the lookup table, the pattern is placed on Port 0 and Q2 is active. Q2 is disengaged after another 1ms delay, and the cycle is repeated.

Check Also
Close

Close
Close