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
}
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- C6678 DSP program debugging problem
- [First batch of finalists] 2022 Digi-Key Innovation Design Competition
- Very urgent help, power supply people please help
- I searched Baidu for half an hour but couldn't find the answer. I used a search engine to find the answer in seconds.
- ESK32-360 Review] + LCD Test
- EEWORLD University Hall ---- Disassembling the front controller module of Tesla Model 3 VCFRONT
- How to use JTAG to program UCD90120A
- Vivado "Failed to generate and synthesize debug IPs." error solution
- Help
- Creating a Superior Smart Display Experience with DLP Pico Technology