Design of Multifunctional Temperature Controller Based on 51 Single Chip Microcomputer

Publisher:yunhuiLatest update time:2011-10-06 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

0 Overview

In some industrial production processes, such as constant temperature furnaces, warehouse storage, flower planting, small greenhouses, etc., there are strict requirements on temperature, which needs to be detected and controlled. The traditional temperature measurement method is to amplify the analog signal output by the temperature sensor and send it to the remote A/D converter, and finally the microcontroller analyzes and processes the data after A/D conversion. The disadvantage of this method is that the analog signal is lost during the transmission process and is easily interfered by the outside world, resulting in low temperature measurement accuracy.

In this paper, the STC89C52RC single-chip microcomputer is used as the control core, and the single-bus digital temperature sensor DS18820, which is the latest product launched by Dallas Company in the United States, is used to measure the temperature. The temperature is controlled after processing by the single-chip microcomputer and displayed on LCDl602. The upper and lower limits of the temperature can also be set by buttons to realize functions such as temperature over-limit alarm.

1 System composition and working principle

The structure of the multifunctional temperature control system is shown in Figure 1. The system consists of six parts: control core part, temperature data acquisition part, heating device control part, LCD display part, key input part and alarm prompt part. The single chip starts the temperature acquisition circuit to complete a temperature conversion, then reads the converted digital quantity and converts it into the current temperature to be presented in the display module, and compares the current temperature with the constant temperature value set by the key input circuit to achieve temperature control. The upper and lower limits of the temperature can also be set by keys to realize the over-temperature or low-temperature alarm prompt function. The design goal of this system is to achieve a temperature control accuracy of 0.1°C.

1.1 Alarm circuit

The alarm circuit uses a buzzer as a sounding device. When the temperature is higher than the set upper limit or lower than the lower limit, a square wave with a period of 1s and a duty cycle of 50% is sent to the buzzer. The alarm time can last for 1 minute or wait for a button to release the alarm. This is achieved by software control.

1.2 Button circuit

Using a 2×3 small keyboard, there are two ways to identify the keyboard: row scanning method and row inversion method. Both methods should pay attention to eliminating the jitter of the keys. The row scanning method is used in this article and made into a subroutine, and the export parameter is the key value of the key. Define key K1 to set TH, K2 to set TL, K3 to increase TH or TL, K4 to decrease TH or TL, and K5 to confirm the value of TH or TL.

1.3 Temperature detection circuit

The temperature detection circuit uses the intelligent temperature sensor DS18820, which only needs 3 wires to connect to the microcontroller, reducing the external hardware circuit. The main performance characteristics of DS18820 are as follows:

(1) The temperature measurement range is -55 to 125°C, and the maximum resolution can reach 0.0625°C;
(2) The power supply voltage range is 3.0 to 5.5V;
(3) Power supply mode: parasitic power supply and external power supply;
(4) There are two package types: 3-pin TO-92 package and 8-pin SOIC package;
(5) Programmable temperature conversion resolution, the resolution is 9 to 12 bits (including 1 sign bit), the specific number of bits is determined by the configuration register, the format of the configuration register is shown in Table 1.


Among them, R1R0 is used to set the resolution. The definition of resolution is shown in Table 2.


As can be seen from Table 2, the higher the resolution is set, the longer the temperature conversion takes, so the appropriate resolution should be selected according to the needs of the actual application. In this article, 12-bit resolution is selected and the temperature is detected every 1 second. The temperature data value format of 12-bit resolution is as follows:

When S=0, it means the measured temperature is a positive value, and when S=1, it means the measured temperature is a negative value.

1.3.1 DS18820 Memory Structure

The memory of DS18820 includes high-speed temporary RAM and non-volatile electrically erasable EEPROM. The contents of the high-speed temporary RAM are 9 bytes from low byte to high byte: temperature LSB, temperature MSB, high temperature limit byte TH, low temperature limit byte TL, configuration register, reserved, reserved, reserved, and the last byte is the CRC code of the first 8 bytes. EEPROM is used to store TH and TL.

1.3.2 Temperature data processing method

The two-byte binary value temperature read from DS18820 must be converted into a decimal value before its ASCII code can be sent to LCD1602 for display. With a 12-bit resolution, the temperature is stepped by 0.0625. Since the two-byte temperature is represented by a two's complement code, first determine whether the highest bit of the read temperature is 0 or 1, that is, determine whether it is a positive temperature or a negative temperature, then calculate its two's complement code to convert it into a positive temperature, and then combine the lower 4 bits of the high byte and the upper 4 bits of the low byte into a byte. The remainder obtained by dividing the binary value of this byte by 10 is the unit, tens, and hundreds of the temperature value. If the temperature value read is a negative number, when displaying it, just display a negative sign in front of the temperature number. For the decimal part of the temperature, just multiply the lower 4 bits of the low byte by 0.0625, and then take the one digit after the decimal point of the product.

1.3.3 DS18820 control steps

(1) First, reset the DS18820. The single-chip microcomputer pulls the data line DQ to a low level for 480-960 μs, and then pulls DQ high for 15-60 μs so that the single-chip microcomputer can detect the low-level response sent by the DS18820. Then check DQ. If DQ is still high, the reset operation fails and can be reset again in a loop. If DQ is low, the reset operation is successful.

(2) ROM operation commands of DS18820. After DS18820 is reset, the host can send device ROM operation commands such as read ROM [33H], match ROM [55H], skip ROM [0CCH], alarm search [4EH], etc. In the case of a single-point bus, the skip ROM [0CCH] operation command can be sent to save time. In addition, there is an alarm function in the text. After the temperature conversion, an alarm search command needs to be sent. This command will compare the most recently measured temperature value T with TH or TL in the high-speed RAM. If T>TH or T

(3) DS18820 memory operation commands, such as start temperature conversion command [44H], write command [4EH] (after writing this command, the alarm upper limit TH, alarm lower limit TL and configuration register bytes must be written immediately), read the contents of the temporary register RAM command [0BEH] (reading will start from the first byte and end at the 9th byte. If only part of the bytes are needed, the host can send a reset command at the appropriate time to terminate the reading) and copy command [48H] (save the 2nd, 3rd and 4th bytes of the temporary register RAM to the EEROM of the DS18820), etc.

(4) Bus read and write timing of ROM or RAM operation of DS18820. For read timing, first pull DQ low and delay within 1-15μs (the delay time cannot be too long), then pull DQ high and delay for several μs before reading the value of DQ. After reading one bit, it takes more than 45 μs to read the next bit; for write timing, first pull DQ low for 10-15μs, then write data to the bus and delay for more than 50μs, and finally pull DQ high for more than 1μs before writing the next bit.

1.4 LCD display module

The one used is SMCl602A produced by Changsha Sunman Electronics Co., Ltd.

1.4.1 Main technical parameters

The chip has an operating voltage of 4.5 to 5.5 V and can display two lines, 16 characters per line, with a character size of 2.95 × 4.35 mm.

1.4.2 Interface signal description

In addition to the voltage, backlight pins and 8 I/O pins, the main control pins include the data/command selection RS pin. When the pin is at a high level, it indicates that the I/O pin contains data; when the pin is at a low level, it indicates that the I/O pin contains commands; the read/write selection pin and the enable pin E (the operation of SMC1602A is only effective when the pin is at a high level).

1.4.3 Instruction Description

(1) Initialization settings
a. Display mode setting. Instruction code: 00111000b, used to set 16×2 display, 5×7 dot matrix.
b. Display on/off and cursor setting. Binary instruction code: 00000DCB, in which the D bit is used to control the display on or off, the C bit is used to control the display cursor, and the B bit controls whether the cursor flashes. Binary instruction code: 000001NS, in which the N bit controls the address pointer and cursor to add or subtract 1 after reading or writing a data, and the S bit controls the movement of the character.
c. Data pointer setting. Instruction code: 80H+address code (0-27H, 40H-67H) is used to set the data pointer.
(2) Other settings. For example, instruction code 01H: the display is cleared and the data pointer is cleared.

1.4.4 LCDl602 initialization steps

(1) Delay 15ms, write command 38H (do not detect busy signal);
(2) Delay 5ms, write command 38H (do not detect busy signal). The above process is executed twice. In the following process, the busy signal needs to be detected before each writing of instructions and reading/writing of data;
(3) Write command 38H: display mode setting;
(4) Write command 08H: turn off the display;
(5) Write command 01H: clear the screen and reset the data pointer;
(6) Write command 06H: characters do not move, the cursor and pointer increase by 1;
(7) Write command 0FH: display is turned on, and the cursor flashes.

1.5 Constant temperature control module

A 6V solid-state relay is selected as the switching device. By controlling the timing of its off and on, the working time of the heating device is controlled to achieve the constant temperature maintenance function of the sample.

2 System Hardware Circuit Design

The main circuit diagram of the system is shown in Figure 2. The circuit that uses the USB port to provide 5V power supply, the circuit that uses the RS232 serial port to burn the program through P3.0 and P3.1, and the constant temperature maintenance circuit controlled by the relay are not drawn in the schematic diagram.

3 System software design

The overall flow chart of the system is shown in Figure 3. The system program mainly consists of the main program and LCDl602 initialization subroutine and read-write timing subroutine, DSl8820 reset and read-write timing subroutine, keyboard scanning subroutine, temperature data processing subroutine, etc.

4 Program editing and debugging

The programming language can be assembly language or C51 language. This article uses assembly language, uses Keil C software to create a new project, then creates a new file to input the source program and saves it in .asm format, and adds the source file to the newly created project, then compiles and links to generate a hexadecimal file (.HEX), and finally uses the burning software stc-isp-v3.9l to burn the hexadecimal file into the Flash of the microcontroller through the RS232 serial port to run the program.

5 Conclusion

The multifunctional temperature controller designed in this paper has small size, low power consumption and high reliability. Experiments show that the temperature control accuracy has reached the design target of 0.1℃.

Reference address:Design of Multifunctional Temperature Controller Based on 51 Single Chip Microcomputer

Previous article:Electronic piano design based on TA89C2051
Next article:Design of dimming controller 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号