Simple temperature counting code tube display based on 51 single chip microcomputer

Publisher:CyberJoltLatest update time:2021-10-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Hardware Solution

This system uses 51 single-chip microcomputer to control the temperature sensor DS18B20 to detect and display the temperature in real time, which can realize rapid measurement of ambient temperature.


The hardware is based on a microcontroller, and consists of an external clock circuit, a reset circuit, a temperature measurement circuit, and an LED display circuit. As shown in the figure:

2. Design function

(1) The DS18B20 temperature sensor is used for temperature measurement, with a temperature range of -55~+125℃, an accuracy of 0.1℃ (displayed to one decimal place), and an error of ±0.5℃;

(2) Use 0.56-inch four-digit common anode digital tube to display the current temperature;

(3) There is a reset button.


3. Design Schematic

(1) The schematic diagram is mainly designed using AD software, as shown in the figure:

(2) The Protues simulation diagram is as follows:

(3) The PCB diagram is as follows:

4. Software Design

Main program source code


/*****Main function*****/

void main()

{

uc z; //Define variables for for loop

for(z=0;z<100;z++) //Loop 100 times to read the temperature and display the boot screen to prevent the boot screen from displaying 85

{

Disp_init(); //Startup initialization display

check_wendu(); //Read temperature

}

while(1) //Enter while loop

{

check_wendu(); //Read temperature

for(z=0;z<10;z++) //display 10 times

Disp_Temperature(); //Call display function

}

}

/*****Display temperature subroutine*****/

void Disp_Temperature() //Display temperature

{

if(qian==0)   //thousands digit equals 0

{

if(fuhao==1) // is negative temperature

P0=0x7f; //Display-

else   // is a positive temperature

P0=0xff;   //not displayed

P2=0xfd;   //Select the first position

Delay(10); //delay

P2 = 0xff; //Close bit selection

}

else if(qian!=0)   //thousands digit is not equal to 0

{

P0 =~led[qian];   //Display thousands of data

P2 = 0xfd;   //Open the first bit selection

Delay(10);   //delay

P2 = 0xff;   //Close bit selection

}

if((bai==0)&&(qian==0))//both the hundreds and thousands are 0

{

P0=0xff; //not displayed

P2=0xf7; //Open the second bit

Delay(10); //delay

P2=0xff; //Close bit selection

}

else if((bai==0)&&(qian!=0))//The thousandth digit is not equal to 0, the hundredth digit is equal to 0

{

P0=~led[bai]; //Normal display of hundreds digit data

P2=0xf7; //Open the second bit

Delay(10); //delay

P2=0xff; //Close bit selection

}

else if(bai!=0) //hundreds digit is not equal to 0

{

P0=~led[bai]; //display hundreds

P2=0xf7; //Open the second bit

Delay(10); //delay

P2=0xff; //Close bit selection

}

P0=~led_dian[shi]; //Display ten-digit data

P2=0xdf;   //Open the third bit

Delay(10);   //delay

P2=0xff;   //Close bit selection

P0=~led[ge];      //Display the unit data

P2=0x7f;   //Open the fourth bit

Delay(10);   //delay

P2=0xff; //Turn off the display

}

Reference address:Simple temperature counting code tube display based on 51 single chip microcomputer

Previous article:Design of Function Generator Based on 51 Single Chip Microcomputer
Next article:Voltage meter based on 51 single chip microcomputer - digital tube display

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号