With the single-chip microcomputer as the core device, a simple DC digital voltmeter is constructed.
(1) Using 1 analog input, it can measure the DC voltage value between 0-5V.
(2) The voltage can be displayed using a 4-digit LED digital tube, which can display at least two decimal places.
The production of a simple digital voltmeter mainly involves knowledge of data (voltage) measurement, A/D conversion, and control display.
(1) A/D conversion is implemented using ADC0808 and 0809.
(2) The voltage display uses a 4-digit LED digital tube.
(3) MCU selected is AT89C51
Preliminary system design
The A/D converter is a device that realizes the conversion from analog quantity to digital quantity. According to the conversion principle, it can be divided into four types: counting A/D converter, dual-integral A/D converter, successive approximation A/D converter and parallel A/D converter.
The most commonly used A/D converters at present are dual-integral A/D converters and successive approximation A/D converters. The main advantages of the former are high conversion accuracy, good anti-interference performance, and low price, but the conversion speed is slow and is generally used in occasions where speed requirements are not high. The latter is a faster and more accurate converter with a conversion time of approximately a few microseconds to hundreds of microseconds.
ADC0809 is an 8-bit 8-channel successive approximation AD converter.
The simulation diagram is as follows:
The specific implementation of the code is as follows:
#include #include sbit OE=P1^0; // output enable control bit sbit EOC=P1^1; //Conversion end status signal sbit ST=P1^2; //Conversion start signal sbit CLK=P1^3; // Clock signal sbit C3=P1^4; // sbit C2=P1^5; // sbit C1=P1^6; // unsigned int temp; unsigned char show[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90}; // 0-9 void delay(int n) { int i,j; for(i=0;i for(j=0;j<200;j++); } } void display() // Digital tube display { P3=0X80; P0=show[temp/1000]&0X7F; delay(5); P3=0X40; P0=show[temp/100%10]; delay(5); P3=0X20; P0=show[temp%100/10]; delay(5); P3=0X10; P0=show[temp%10]; delay(5); } unsigned int ADC0809() { unsigned int dat; ST=0; ST=1; _nop_(); ST=0; _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); EOC=1; while(EOC==0); OE=1; P2=0XFF; //Set P2 port as input port dat=P2; OE=0; return dat; } void main() { ET0=1; EA=1; TMOD=0X00; //Set the timer working mode to 0 //11111111 11110 TH0=0XFF; TL0=0X0; TR0=1; CLK=1; ST=0; OE=0; C1=0;C2=0;C3=0; while(1) { temp=ADC0809()*19.53125; //19.53125=5/256*1000 5/256 is the precision. Multiply by 1000 for the convenience of digital display. display(); } } void inex_T0() interrupt 1 { TH0=0XFF; TL0=0X0; CLK=!CLK; } Note: The collected data needs to be converted into data that can be reasonably output on the digital tube, so everyone needs to pay attention. Effect simulation diagram:
Previous article:51 single chip microcomputer completes clock display
Next article:ESP8266 WIFI module learning journey (1) - USB serial port connection of the module
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- GaN tube selection
- I downloaded a source code from the Internet. I don't know what software it was developed with. The file type is shown in the picture. Please help me take a look.
- How to choose MOS tube for low power motor
- 3D Printer Project—STM32F750 Startup Program (Part 2)
- Looking for a chip that can increase 12V to 12.6V/3A
- 【NUCLEO-F746ZG Motor】Based on SDK5.4.5-Project Build
- HDL Language Quick Guide
- How to select external clock for TMS320 series
- (Bonus 10) GD32L233 Review - SPI Driver DS1302
- O-RAN Testing Tool - Terminal Emulator UEE, Do You Know It?