Design of two-way temperature controller based on 51 single chip microcomputer

Publisher:hylh2008Latest update time:2013-11-23 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  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.

Reference address:Design of two-way temperature controller based on 51 single chip microcomputer

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

PIC Getting Started 6, DS18B20 Temperature Measurement
The procedure is as follows: //PIC C DS18B20 temperature measurement, LCD display.c Time: 2008-8-20  //Suitable for 3ePIC experimental board //Thermometer written in C language, DS18B20 temperature measurement, LCD display, display to 0.1 degrees //USING 16F877 READ MAXIM DS18b20 AND DISPLAY ON LCD1602 */ #inclu
[Microcontroller]
ds18b20 temperature sensor application examples
/*  *******************************************************************************  * File name: main.c  * Description: Temperature sensor DS18B20 example  * Note: Control DS18B20 to measure temperature and display the temperature value on the LCD  ***************************************************************
[Microcontroller]
STM32 MCU (11) DS18B20 temperature sensor experiment
This program mainly realizes the acquisition of DS18B20 temperature sensor data and transmits the temperature data to the computer using serial communication. Note: When using the Puzhong Technology Development Board for testing, you need to unplug the Boot1 socket because the PA15 pin is used. From the development bo
[Microcontroller]
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号