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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
- 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
- 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
- Sandia Labs develops battery failure early warning technology to detect battery failures faster
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Looking for experts in Helmholtz coil magnetic field
- Do you know about the programmer and emulator of msp430?
- How to use the VGA_SYNC_N signal in the VGA of DE1-SOC?
- ATA-1000 Series Broadband Amplifier & ATA-2000 Series High Voltage Amplifier Series Comparison
- CCS Tips: Remove the prompt when burning DSP/BIOS
- SEED-DEC6416 is available for purchase, second-hand is also acceptable
- Calculation of stack usage in C2000 DSP
- IRLR024 Output Current
- Bidirectional thyristor circuit wiring problem
- "Goodbye 2019, Hello 2020" + The wind and clouds are free and happy