A Single Chip Microcomputer Design for Real-time Temperature Control

Publisher:温暖的拥抱Latest update time:2016-11-08 Source: ofweek Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  Compared with the traditional system, the circuit structure is simple, the temperature measurement accuracy is high, the temperature control error is small, and the technical indicators can be achieved under different time constants. The article also gives a method to use the serial port debugging wizard to display the output of the PID controller and the temperature sampling value on the PC to facilitate temperature monitoring.

  0 Preface

  At present, water temperature control is widely used in many fields such as food, medicine, chemical industry, and home appliances. The quality of water temperature control directly affects the quality of the product. Therefore, water temperature control is of great significance. The task and requirement of this design is that 1 L of water is heated by a 1 kW electric furnace. The water temperature can be set manually within a certain range and can be automatically adjusted when the ambient temperature drops to keep the set temperature basically unchanged. Main performance indicators: The temperature setting range is 25.0~100 ℃, the minimum resolution is 0.1 ℃, the static error of temperature control is less than or equal to 0.1 ℃, the SMC1602A LCD module is used to display the actual water temperature and the three main parameters Kc, Ti, and Td in the PID control algorithm. The output of the PID controller and the temperature sampling value are displayed on the PC using the serial port debugging wizard.

  1 System Solution

  This design is based on the STC89C52 microcontroller and uses the temperature sensor DS18B20, RS232 standard interface and PID control algorithm to control the temperature.

  The water temperature control system is a typical detection and control application system, which requires the system to complete the whole process from water temperature detection, signal processing, input, operation, to output control of electric furnace heating power to achieve water temperature control. This design realizes the intelligent control of water temperature and provides a complete human-computer interaction interface and PC and single-chip communication interface. The system consists of PC and single-chip communication module, temperature detection and display module, PID control algorithm and other modules. Its feature is that it uses PC and single-chip communication. The system block diagram is shown in Figure 1.

A Single Chip Microcomputer Design for Real-time Temperature Control

  2 Hardware Circuit Design

  The overall design of this circuit includes four parts: host control part (STC89C52), temperature sampling and display circuit, temperature control circuit, and PC and microcontroller communication circuit.

  2.1 Host control part

  The host control part is the core of the circuit. The system is controlled by the single-chip microcomputer 89C52. The single-chip microcomputer 89C52 has an internal program memory of 8 KB units and a data memory of 512 B. Therefore, the system does not need to expand the external program memory and data memory, which can greatly reduce the complexity of the system hardware part.

  2.2 Temperature sampling and display circuit

  The signal acquisition and display circuit of the system mainly consists of two parts: temperature sensor DS18B20 and SMC1602A liquid crystal display module.

  DS18B20 uses a unique single-line interface. When connected to a microprocessor, only one line is needed to achieve two-way communication between the microprocessor and DS18B20. The temperature measurement range is -55~+125℃, the inherent temperature measurement resolution is 0.5℃, the working power supply is 3~5 V/DC, and no peripheral components are required during use. The measurement results are transmitted serially in 9~12 bit digital quantity mode. It is suitable for temperature measurement of various medium industrial pipelines of DN15~25, DN40~DN250 and equipment in narrow spaces.

  SMC1602 LCD has been widely used in pocket instruments and low-power application systems for its advantages of low power consumption, small size, and flexible use. LCDs can usually be divided into two categories, one is dot matrix type and the other is character type. Dot matrix LCDs usually have a large area and can display graphics; while general character LCDs have only two lines and a small area, and can only display characters and some very simple graphics. They are simple, easy to control and low cost. At present, most of the character LCDs on the market are based on the HD44780 LCD chip, so the control principle is exactly the same. The control program written for HD44780 can be easily applied to most of the character LCDs on the market. Character LCDs usually have 14 pin lines (there are also many LCDs with 16 pin lines on the market. The extra 2 lines are the power line VCC (pin 15) and the ground line GND.

  2.3 Temperature Control Circuit

  This part of the circuit is mainly composed of photocouplers, transistors and relays.

  The withstand voltage of the photocoupler is 400 V. Its output stage controls the on and off of the normally open contacts of the relay after amplifying the power through the transistor, thereby ultimately achieving the purpose of controlling the electric furnace. The 100 Ω resistor and the 0.01 μF capacitor form a bidirectional thyristor protection circuit.

  2.4 Communication circuit between PC and MCU

  In order to make the system have a better human-computer exchange interface, we designed the microcomputer control interface through Visual Basic language in the system design. The communication between the system and the microcomputer greatly improves the performance of the system in all aspects.

  Since the serial port of the microcontroller 89C52 is TTL level, and the PC is RS232 level, the system uses the MAX232 level conversion chip to perform level conversion.

  Because the system is designed with communication function, that is, the communication between the main system (89C52) and the PC, it is more obvious when observing the output of the PID controller, which greatly reduces the difficulty of parameter setting. In addition, the sampling value of the system can be seen through the visualization window.
 

  3 Software Design

  The software design of this system mainly includes three parts: software design of PC and single-chip microcomputer communication module, software design of temperature sampling and display circuit module, and software design of temperature control module.

  3.1 Main program flow chart

  The main program flow is shown in Figure 2. The program mainly completes the following tasks:

  (1) Initialization: Set the initial values ​​of each parameter, set the serial port, timer and LCD display module.

  (2) Communication between PC and MCU: This part of the program mainly completes the mutual transmission of data between PC and MCU, which is mainly completed through the half-duplex serial port of 89C52 MCU, thereby completing the connection with the microcomputer control interface RS232 and the control of communication.

  (3) Temperature acquisition and display: mainly completes the acquisition of temperature signals and processes the converted digital quantities, and then uses a character liquid crystal display module to display the real-time temperature.

A Single Chip Microcomputer Design for Real-time Temperature Control

  3.2 PID Control Algorithm

  The PID algorithm is the decisive factor in the performance of this temperature control system. Its general formula and analog control law expression are as follows:

A Single Chip Microcomputer Design for Real-time Temperature Control

  In the formula, u(t) is the output of the controller; e(t) is the deviation, that is, the difference between the set value and the feedback value; Kc is the controller's amplification factor, that is, the proportional gain; Ti is the controller's integral constant; Td is the controller's differential time constant. The principle of the PID algorithm is to adjust the three parameters of Kc, Ti, and Td to make the system stable.

  Since the general PID formula is not easy to process with a single-chip microcomputer, an incremental PID algorithm is used in the design. Convert formula (1) into:

A Single Chip Microcomputer Design for Real-time Temperature Control

  u(k) in equation (3) is the on-time of the output PWM wave. Its control algorithm is shown in Figure 3.

A Single Chip Microcomputer Design for Real-time Temperature Control

  4 Test methods and test results

  4.1 Test Method

  Put 1 L of clean water in the electric stove, connect the electric stove to the control system, power on the system, and the system enters the ready-to-work state. Set the temperature to 35.3 ℃, 40.2 ℃, 45 ℃, 60 ℃, 74.0 ℃, and 81 ℃ respectively, observe the set temperature and actual temperature, and record the data. Fill in Table 1, observe the dynamic situation of water temperature changes, and record the time when the temperature stabilizes, and fill in Table 2.

  4.2 Test Results

  The data comparison of the set temperature and the measured temperature is listed in Table 1. Table 2 lists the relationship between temperature stability and time. The set temperature in Table 2 is 50℃, and the measured temperature is recorded every 30 seconds.

A Single Chip Microcomputer Design for Real-time Temperature Control

  5 Conclusion

  From the data in Table 1, it can be seen that the error of the system is basically stable at ±0.3 ℃, so it can well meet the design requirements of the system. From the data obtained in Table 2, it can be seen that the system has basically reached stability after running for 5 minutes, indicating that the system can well control the temperature to reach the ideal value, providing a reference for tasks that require precise temperature control. At the same time, the system realizes the communication between the PC and the single-chip microcomputer, and displays the control parameters and control results on the PC, which is convenient for monitoring and realizes temperature control and intelligent monitoring.

Reference address:A Single Chip Microcomputer Design for Real-time Temperature Control

Previous article:Design of two-way temperature controller based on 51 single chip microcomputer
Next article:Infrared sensor CO2 gas detection circuit design

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号