Single -chip machine dry goods, the design and production of simple digital voltage meter (C language version)
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-
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,
Effect diagram of the work:
Equipment assembly drawing
R1, R2, R3, R4, R5, R6, R7, R8
R9, R10, R11, R12, R20
Q1, Q2, Q3, Q4
Single -chip machine
IC lock seat
C3, C4, C5
4 row (common yang)