Design of Simple Digital Voltage Meter Based on Single Chip Microcomputer

Publisher:温馨如家Latest update time:2019-05-14 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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 

Write the picture description here

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. 

  • Write the picture description here
    Write the picture description here

Write the picture description here

Write the picture description here

Write the picture description here

Write the picture description here

The simulation diagram is as follows: 

Write the picture description here

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: 

Write the picture description here 
Write the picture description here

Reference address:Design of Simple Digital Voltage Meter Based on Single Chip Microcomputer

Previous article:51 single chip microcomputer completes clock display
Next article:ESP8266 WIFI module learning journey (1) - USB serial port connection of the module

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号