Design of greenhouse temperature monitoring system based on AT89C52

Publisher:月光男孩Latest update time:2015-06-25 Source: 21icKeywords:AT89C52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The greenhouse requires the temperature to be kept within a certain range, which is the best environment temperature for the growth of plants and animals. Therefore, the environment temperature for the growth of plants and animals must be monitored and controlled to make it suitable for the growth of plants and animals to improve the yield and quality. This design is to conduct a comprehensive analysis of the temperature control requirements of the greenhouse, and after comprehensively considering the system accuracy and economy, design a temperature automatic control system based on a single chip microcomputer. This system can realize automatic monitoring of the temperature of the greenhouse, and can input control instructions such as set temperature through buttons, and keep the greenhouse temperature within the set value range to complete the work of the monitoring system.

1 System Overall Plan

This system is composed of AT89C52 single-chip microcomputer as the main controller, plus peripheral temperature acquisition module, keyboard module, display circuit module, heating module and cooling module. The system structure block diagram is shown in Figure 1. The temperature acquisition module first collects the temperature value, and sends it to the AT89C52 single-chip microcomputer for processing after A/D conversion. The processed temperature value is displayed on the display. In addition, the ideal temperature value required for the growth of plants and animals is set by the keyboard and sent to the single-chip microcomputer. The single-chip microcomputer uses the PID algorithm to compare the set temperature value with the collected temperature value and then sends a control signal to the relay. The relay drives the fan to cool down or the heater to heat up until it is consistent with the set temperature value and stops working.

Design of greenhouse temperature monitoring system based on AT89C52

2 System Hardware Design

2.1 Temperature acquisition module

At present, temperature acquisition devices often use thermocouples. Because the output of thermocouples is analog voltage, and the output voltage is very small, only a few millivolts, it must be amplified to about 5 volts for A/D conversion, and then sent to the microcontroller for processing. The advantage of this solution is that the measurement temperature range is large, from -100℃ to thousands of degrees Celsius, and the accuracy is high, but the system hardware is complex and the anti-interference ability is low. Digital temperature sensors make up for the shortcomings of thermocouples. DS18B20 is a single-bus digital temperature sensor. It does not require other external circuits. The direct output is digital. Only one line is needed to write information to DS18B20 or read information from DS18B20. The connection circuit between DS18B20 and microcontroller is shown in Figure 2. Therefore, using DS18B20 can make the system structure simpler and enhance the anti-interference ability. The temperature measurement range of DS18B20 is from -55 to +125℃, the increment value is 0.5℃, and the temperature can be converted into digital within 1 s.

Design of greenhouse temperature monitoring system based on AT89C52

After DS18B20 receives the temperature conversion start command from the microcontroller, DS18B20 starts the conversion. The converted temperature value is stored in bytes 0 and 1 of the temporary memory in the form of a 16-bit signed binary complement. The microcontroller reads the data through the single bus interface, with the low bit first and the high bit last. The temperature value format is shown in Table 1, where "S" is the sign bit. When the first 5 bits of the high byte S=0, it represents a positive number. The low 3 bits of the high byte and the binary bits of the low byte are directly converted into decimal to obtain the corresponding temperature value; when the first 5 bits of the high byte S=1, it represents a negative number. The low 3 bits of the high byte and the binary bits of the low byte represent the complement of a negative number. The complement must be converted into the original code first, and then the decimal value is calculated to obtain the corresponding temperature value.

Design of greenhouse temperature monitoring system based on AT89C52

2.2 Relay circuit module

Since this system needs to control the heating of the heater or the cooling of the electric fan, the power is relatively large, so it is necessary to use a power circuit. If a thyristor is used for control, a very high control accuracy can be achieved, but an optical coupling isolation device is required, and the circuit is slightly complicated. Relay control can easily pass higher voltages and currents, and no external optical coupling is required, and the circuit is simple and reliable. Therefore, this design uses relays to control the fan and heater, and its circuit is shown in Figure 3.

Design of greenhouse temperature monitoring system based on AT89C52

When the measured temperature is lower or higher than the lower or upper limit of the set temperature, the microcontroller outputs a high-level signal, the NPN transistor 9014 is turned on, and the relay drives the heater to start heating or the electric fan to start cooling. In order to prevent the relay from operating frequently, the temperature is measured accurately to two decimal places in the program, and only integers are used when setting the temperature. A diode is connected in parallel in the opposite direction next to the relay coil. The diode protects the transistor and prevents the transistor from breaking down.

2.3 Keyboard and Display Module

This system needs 4 LED digital tubes to display the tens, ones and two decimal places of the temperature respectively. When the temperature is set by pressing the button, the LED digital tube stops displaying the current temperature and displays the set temperature value. After setting, it continues to display the current collected temperature value. Dynamic display combined digital tubes only require a small number of pins. Taking the 4-bit combined digital tube as an example, 8+4=12 pins are required. If each digital tube needs a separate pin, at least 4*9=36 pins are required. The reduction in the number of pins makes the PCB board wiring simpler. Therefore, when multiple digital tubes are needed, dynamic display combined type is generally used. This design uses a four-bit common anode digital tube. The PO port of the microcontroller controls the segments a--dp of the digital tube. P2.4--P2.7 is connected to the COM end of the digital tube through four 9012 PNP transistors.

The temperature setting is realized by pressing the buttons, and the upper and lower limits of the temperature are modified by pressing the buttons. The buttons adopt an independent keyboard, which is connected to the P1.1, P1.2 and P1.3 pins of the single-chip computer through pull-up resistors. Its connection with the single-chip computer is shown in Figure 4. Press the control key once, and then press the up or down key once to increase or decrease the set temperature value by 1. Press the control key again to complete the setting.

Design of greenhouse temperature monitoring system based on AT89C52

3 System Software Design

The software of this system is designed in assembly language. The main program is initialized first, and then the temperature reading, temperature processing, display, keyboard and relay control subroutines are called cyclically to realize the temperature control function. [page]

3.1 Main program flow chart

The main program flow chart is shown in Figure 5.

Design of greenhouse temperature monitoring system based on AT89C52

3.2 Reading temperature module subroutine

The operation of DS18B20 must be carried out strictly in accordance with the protocol specified in the DS18B20 working process. DS18B20 should follow the following working protocol: DS18B20 reset -> execute ROM command -> execute function command -> data processing. The subroutine flow chart for reading temperature is shown in Figure 6.

Design of greenhouse temperature monitoring system based on AT89C52

3.3 Data processing subroutine

Since the 16-bit data converted by DS18B20 is not the actual temperature value, data processing is required. The upper 5 bits of the high byte of the temperature are used to indicate the positive or negative temperature, and the lower 3 bits and the low byte of the high byte are used to store the temperature value. The lower 4 bits of the low byte are used to store the decimal places of the temperature. Since 1/24=0.062 5, the temperature accuracy of DS18B20 is 0.062 5 ℃. Multiplying the lower 4 bits of the low byte by 0.062 5 may result in multiple decimal places. This design requires the temperature value to retain two decimal places, so rounding is adopted to obtain the real two decimal places. The specific algorithm is that the program first determines whether the temperature value is negative. If it is, the DS18B20 stores the complement value of the temperature, and its original code needs to be calculated first. The processed temperature is stored in the RAM of the microcontroller, and then the hexadecimal code in the RAM is converted into BCD code. The data processing subroutine flow chart is shown in Figure 7.
 

Design of greenhouse temperature monitoring system based on AT89C52

3.4 Keyboard Scanning Subroutine

The keys use three keys, representing the control key, plus 1 key and minus 1 key respectively. The keyboard subroutine flow chart is shown in Figure 8.

Design of greenhouse temperature monitoring system based on AT89C52

4 System Debugging

This design has produced physical hardware. The system uses modular welding and debugging to prevent all welding debugging difficulties. If it fails once, it will be troublesome to find the error. After step-by-step debugging, joint debugging is finally carried out. Due to limited conditions, indoor temperature is used for testing in this design. If the set temperature is higher than the current temperature value, the heater simulation light will light up, but the indoor temperature will not change so quickly. Body temperature is used to achieve a rapid increase in temperature. When the set value is reached, the heater light goes out. This shows that the system has high control accuracy.

5 Conclusion

The temperature controller can monitor the temperature of the greenhouse in real time with an error of less than 0.1℃. It can set the ideal temperature for crop growth. According to the difference between the current temperature and the set temperature, the heater or fan will automatically start until the set temperature is reached and stop working. After improvement, the system can be widely used in temperature control in breeding greenhouses and other places to ensure the ideal growth temperature of crops and increase yields.

Keywords:AT89C52 Reference address:Design of greenhouse temperature monitoring system based on AT89C52

Previous article:Design of ultrasonic voice ranging cane based on single chip microcomputer
Next article:Weather temperature alarm system based on 51 single chip microcomputer

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号