This paper proposes a design scheme of a two-way temperature controller based on a 51 single-chip microcomputer. The design scheme uses two DS18B20 temperature sensors to collect the temperature of two different places, and processes it through AT89C51. The measured temperature is displayed by a four-digit LED digital tube. The first two digits are the temperature of the first temperature sensor, and the last two digits are the temperature of the second temperature sensor. Three buttons are used to set the highest and lowest temperatures, and a buzzer and a motor are used to realize an alarm for over-high or under-temperature.
1. Introduction
At present, the problem of temperature controller is how to reduce cost, reduce power consumption, the accuracy of temperature measurement and the simultaneous display of multiple temperatures. This solution is designed to realize a two-way temperature controller based on C51 single-chip microcomputer, which minimizes cost and has high accuracy. It can display and control two-way temperature. It can start the electric fan to cool down when the temperature exceeds the set maximum temperature, and start the buzzer alarm when the temperature is lower than the set minimum temperature. The user can set the maximum and minimum temperatures.
2. System structure
The temperature controller system includes the following main parts: temperature sensor, alarm circuit, LED display circuit, keyboard control, 89C51 control part. As shown in the figure:
This system is designed to achieve: After starting the temperature controller, the green light comes on, and the first two digits on the four-digit LED digital display are the ambient temperature measured by temperature sensor 1, and the last two digits are the ambient temperature measured by temperature sensor 2.
3. Hardware structure
3.1 Temperature Sensor
This design uses DS18B20 as the temperature sensor. Compared with traditional thermistors, DS18B20 has the advantages of high accuracy, small measurement error, and convenient multi-point temperature measurement. Therefore, DS18B20 is used as the temperature sensor.
3.2 Alarm circuit
This design uses a buzzer and electric fan alarm circuit. The buzzer alarm circuit consists of a transistor and a buzzer. When the temperature is lower than the set minimum temperature, the buzzer alarms. The electric fan alarm circuit consists of a transistor and an electric fan. When the temperature is higher than the set maximum temperature, the electric fan alarms.
3.3 Display Circuit
This system uses LED digital display tubes, which have high brightness and high viewing angle. LCD has low viewing angle, low brightness and high price. Considering that this temperature sensor is mainly used in greenhouses and other environments with low brightness, LED is selected as the display from the perspective of economy and practicality.
3.4 Keyboard Control
This system uses 3 independent keys as the keyboard control circuit. Keyboards are generally divided into two types: independent and matrix keyboards. Independent keyboards have a simple structure, but occupy more resources; matrix keyboards have a more complex structure, but occupy fewer lines. Considering that the number of keys required for this design is not large, three independent keyboards are used to complete the temperature setting of two temperature sensors.
3.5 89C51 control part
This system uses AT89C51, 51 for small electronic products, and the hardware design circuit is shown in Figure 1.
4. Software Design
This system is implemented using assembly language coding, which has a faster processing time than programs coded in C language.
The main program includes system initialization, keyboard scanning selection subroutine, temperature comparison subroutine, temperature measurement subroutine, temperature calculation subroutine, and display subroutine. [page]
4.1 Main program module
In the main program, the data is initialized first, and then the keyboard scanning subroutine KEY_TEST, the temperature comparison subroutine COMPARE, the temperature acquisition subroutine GET_TEMP, the temperature display subroutine DIS_SET and DISPLAY are called, and then the temperature value of the second temperature sensor is judged and collected and displayed. The program is written as follows:
4.2 LED Display Module
LED display can be divided into two types: dynamic display and static display. Static display occupies more lines. In order to reduce hardware costs, this design uses a dynamic scanning display method to display the temperature values of two temperature sensors.
The DISPLAY and DISPLAY1 functions read the temperature of the first and second temperature sensors respectively and display the temperature of the two temperature sensors according to the data in the temporary storage unit. Programming idea: judge the different displays according to the SIGN sign, store the data obtained from the table in different units and display them on the LED.
4.3 Keyboard Control Module
The keyboard determines the highest or lowest temperature of the first or second temperature sensor by setting the SIGN flag. The programming idea is: initially set SIGN to 0, assign it to 1 when the first key is pressed, add one when it is pressed again, and then assign it to 0 again when it is pressed for the fifth time. Different settings are determined according to the value of SIGN.
4.4 Temperature Sensor Module
According to the temperature sensor DS18B20, there are three steps required to complete the temperature conversion. The program is: MOV A, #0CCH // Skip ROM MOV A, #44H // Perform temperature conversion MOV A, #0BEH // Read the contents of the temporary memory.
4.5 Alarm module
When the real-time temperature is higher than the set maximum temperature or lower than the set minimum temperature, the microcontroller will control the buzzer or the electric fan to work. The function to determine whether the current temperature is within the normal range is COMPARE. The high temperature part of the program is as follows:
5. Simulation test
Before we write a program to DS18B20, we must debug our own program. But we cannot see how the program runs. Therefore, we can use a simulator to simulate. Through the simulator, we can see the data sent by DS18B20, the temperature value read out, and the changes in the values used in the registers. The system connection diagram is shown below:
We can now display the temperature collected by DS18B20 on the PC and change a line after each temperature value is displayed. The experiment proves that the system is practical and has achieved the expected functions.
6. Summary
The temperature controller designed in this scheme uses AT89C51 single-chip microcomputer as the core, DS18B20 as the temperature sensor, and realizes the collection and display of two-way temperature through four-digit LED display and cyclic scanning. Then, the simulation test confirmed that the design scheme is economical and practical, and can measure the temperature of two places, which can meet the use in different environments such as greenhouses, indoor homes, industrial control, etc.
Previous article:Some Experiences in 51 Single Chip Microcomputer Development
Next article:Design of RF wireless sensor network node based on ZigBee and 51 core
Recommended ReadingLatest update time:2024-11-16 19:27
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Single-chip microcomputer technology and application - electronic circuit design, simulation and production (edited by Zhou Runjing)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
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
- EEWORLD University Hall----Start using UCD3138 digital power controller tool
- CircuitPython 5.3.0-rc.0 released
- TI DSP programming - TMS320C6416
- What is the reason for the inductance noise in the peripheral circuit of the lithium battery charging chip?
- CCS Error
- FPGA_100 Days Journey_USB2.0 Design
- Qorvo is such a strong company, it’s more than just RF!
- [GD32L233C-START Review] Getting to know the development board
- Packaging form and packaging process of RFID electronic tags
- Robot? Toy? Toy robot?