Single -chip machine dry goods, the design and production of simple digital voltage meter (C language version)

0 Comments

The use of the voltage meter is very wide. The traditional analog voltage meter has a slow response, the reading is troublesome and the error is large. Now it has been widely used in digital voltage meters. This article introduces the design and production process of a simple digital voltage meter. Based on the entry -level 51 single -chip machine-

单片机干货,简易数字电压表的设计与制作(C语言版)

STC89C52RC

,by

Adc0831

For the data sampling of the voltage measurement voltage for the modulus, of course, there is also a display circuit, which is composed of a four -digital digital tube. The digital voltage meter can measure the DC voltage value between 0-5V.

The schematic diagram is generally divided into four parts. The upper left corner is the minimum system of the single -chip microcomputer. It is not necessary to repeat it. I believe that Ren He will be mentioned in the lower left corner. Power supply, those filtering capacitors can be saved without; in the upper right corner is the display circuit, a typical digital tube drive circuit, the following four triode pipes are selected, and the code pipe foot connecting the single -chip microcomputer P2 port; the lower right corner is the ADC0831 circuit , Connected to the single -chip microcomputer through CLK and SDO, a clock signal, a serial data. Maybe you need to say a few words, which is ADC0831.

Take care of the students who are not very good in English. The general meaning of the English characters on the picture is: ADC0831 single -way differential input dual -column direct packaging. The typical circuit is as follows,

ADC0831 has a total of eight feet. Needless to say, VREF is used as a reference voltage connection VCC. The simulation signal is entered in the form of different mobility. One of the lines can be directly grounded and the other line is input. The conversion digital signal is output by SDO serial, CLK provides timing. CS film selection. The hardware is still very simple. ADC0831 The communication with the single -chip microcomputer is based on the following timing map.

Read the time sequencing

Get a sequential map, first find the signal of the film. This is CS here. The selection signal is generally low -level and effective. When the CS is pulled, the chip starts to work. The program should be written strictly in accordance with the sequential map. Here you should set a low CLK before pulling down CS. That is, set the low CLK first, NOP for a while; then pull down the CS film, NOP for a while; then set the high CLK, NOP for a while, and then set the low CLK, NOP for a while, so that the first pulse of the CLK will be taken away from the first pulse of the CLK At this time, not to start reading the data at this time. The data is read from the second pulse signal of CLK to read one bit (BIT) and one bit. The function is as follows.

MSB and LSB are often seen in time -sequential maps, namely the abbreviations of Most Significant Bit and Least Significant Bit (minimum effective position). The timing map of ADC0831 first appears MSB, indicating that as the clock pulse reads the height of the byte.

ADC0831 The modulus readings read the result of an unsigned number of byte size (byte), and the range of this number is 0 ~ 255. The corresponding voltage signal range is 0 ~ 5V. Then there is a mapping function here, that is, the return value of ADC0831 is mailed to the corresponding voltage. This function is named Map ().

The following diagram can intuitively explain its conversion principle. The principle is very simple, that is, wait for the comparison:

The conversion relationship is T = ADV/51, so what does it mean to multiply 100? It is to expand 100 times, remove the decimal point, and facilitate the writing of the digital tube to display the function. Nuo, let’s talk about it below.

The display function is very simple. It can be completed according to the principle of dynamic display of the digital tube. Note that the function parameter is a U16 (UNSIGNED INT) integer number. This is why the MAP function needs to multiply 100 in the previous MAP function. The speed of the single -chip machine is much faster than the number of floating points. In the display function, you can light up the decimal in the correct position. code show as below:

The following is a delay function,

Delay function:

Main function:

Global definition:

单片机干货,简易数字电压表的设计与制作(C语言版)

Effect diagram of the work:

Equipment assembly drawing

Component list

name

Label

Nominal value

单片机干货,简易数字电压表的设计与制作(C语言版)

Encapsulate

quantity

resistance

R1, R2, R3, R4, R5, R6, R7, R8

200

Direct insertion

8

R9, R10, R11, R12, R20

1K

5

Triode

Q1, Q2, Q3, Q4

9012

4

单片机干货,简易数字电压表的设计与制作(C语言版)

Single -chip machine

U1

STC89C52

1

单片机干货,简易数字电压表的设计与制作(C语言版)

IC lock seat

单片机干货,简易数字电压表的设计与制作(C语言版)

Textqol

40 -pin

led

D3

单片机干货,简易数字电压表的设计与制作(C语言版)

Green φ5

capacitance

C1

22UF

C2

470uf

C3, C4, C5

0.1UF

3

C6, C7

30pf

2

Wiring terminal

P2

单片机干货,简易数字电压表的设计与制作(C语言版)

2 feet

USB terminal

P1

6 foot

单片机干货,简易数字电压表的设计与制作(C语言版)

Crystal

Y1

12MHz

IC

单片机干货,简易数字电压表的设计与制作(C语言版)

U2

IC socket

Eight feet

Digital Tube

单片机干货,简易数字电压表的设计与制作(C语言版)

U3

4 row (common yang)

diode

D1, D2

1N4148

button

Reset

4 feet

Adc0831

Adc0831

resistance

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

Direct insertion

单片机干货,简易数字电压表的设计与制作(C语言版)

Direct insertion

Direct insertion

1

1

1

1

1

1

单片机干货,简易数字电压表的设计与制作(C语言版)

1

1

1

1

1

1

单片机干货,简易数字电压表的设计与制作(C语言版)

capacitance

capacitance

capacitance