Design of temperature measurement system based on single chip microcomputer and PC serial communication

Publisher:清新时光Latest update time:2011-10-11 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Temperature is one of the main controlled parameters in industrial control. Temperature detection and control are often used in daily life and industrial and agricultural production. Therefore, it is of great significance to study the temperature measurement method and device. Traditional methods mostly use thermal resistors and thermocouples as temperature sensing elements. The output of this analog temperature sensor is an analog signal. It must be converted to a digital signal through the A/D conversion link before it can be interfaced with a microprocessor such as a single-chip microcomputer. This makes the hardware circuit structure more complex, has poor anti-interference, troublesome wiring, and high cost.

In response to the above problems, this design proposes a temperature measurement system based on the digital temperature sensor DS18B20[1-2] of Dallas Semiconductor and the AT89S52 single-chip microcomputer of ATMEL. The system can be connected to the PC system through the serial port for real-time display. The system is easy to install and has high reliability. It is suitable for on-site temperature measurement in harsh environments.

1 System Configuration

The temperature measurement system consists of a microcontroller, temperature acquisition, serial communication, LCD display and host computer display, as shown in Figure 1.

Figure 1 System composition

Figure 1 System composition

The data collection process is as follows: the single-chip microcomputer AT89S52 obtains the temperature value collected by the temperature sensor DS18B20, transmits it to the LCD1602 for display after processing, and uploads it to the host computer through serial communication for display by the host computer.

1.1 DS18B20 Digital Temperature Sensor

The DS18B20 temperature sensor is an improved intelligent temperature sensor launched by DALLAS Semiconductor Corporation of the United States. Compared with traditional temperature measuring elements such as thermistors, it can directly read the measured temperature and can read 9-12 digit temperature values ​​through simple programming according to actual requirements. The performance characteristics of DS18B20 are as follows:

① It has a wider adaptability voltage range (3.0-5.5 V) and can be powered by the data line in parasitic power mode;

② Unique single-line interface mode. Only one line is needed to achieve two-way communication when connected to a microprocessor;

③DS18B20 supports multi-point networking function;

④DS18B20 does not require any peripheral components during use. All sensor elements and conversion circuits are integrated into an integrated circuit shaped like a transistor;

⑤Temperature range: -55℃~+125℃, accuracy is ±0.5℃ at -10~+85℃;

⑥The programmable resolution is 9 to 12 bits, and the corresponding resolutions are 0.5°C, 0.25°C, 0.125°C and 0.0625°C, which can achieve high-precision temperature measurement;

⑦ The conversion time is 93.75 ms (9 bits) and 750 ms (12 bits), which is sufficient for general real-time temperature measurement systems;

⑧The measurement result directly outputs the digital temperature signal, which is transmitted to the CPU via the Danbus serially. At the same time, the CRC check code can be transmitted, which has strong anti-interference and error correction capabilities;

⑨Negative pressure characteristics: When the power polarity is reversed, the chip will not burn out due to heat, but it cannot work normally.

1.2 RS_232 serial communication standard

RS_232C is the most widely used standard bus in asynchronous serial communication developed by the Electronics Industry Association (EIA) of the United States. This standard is applicable to communications with data transmission rates within the range of 0~20Kbps. It has become the interface standard between data terminal equipment DTE and computers and data communication equipment DCE. It is the most widely used serial interface in PC and communication industry. Its working level is stipulated as follows: for data (the level of logic "1" is lower than -3V; the level of logic "0" is higher than +3V). For control signals (the level of "signal valid" is higher than +3V, and the level of "signal invalid" is lower than -3V). In actual work, the level should be guaranteed to be ± (3~15) V. The functions of the 9 pins of its serial port have fixed definitions. In this design, only two data lines, RXD and TXD, are needed.

1.3 AT89S52

AT89S52 is a low-power, high-performance CMOS process 8-bit microcontroller with 8K in-system programmable Flash memory. It is fully compatible with 80C51 product instructions and pins. It can provide highly flexible and super-effective solutions for many embedded control application systems. AT89S52 also contains: 256 bytes of RAM, 32-bit I/O port lines, watchdog timer, 2 data pointers, three 16-bit timers/counters, a 6-vector 2-level interrupt structure, full-duplex serial port, on-chip crystal oscillator and clock circuit. In addition, AT89S52 can be reduced to 0 Hz static logic operation and supports 2 software-selectable power saving modes. In idle mode, the CPU stops working, allowing RAM, timer/counter, serial port, and interrupt to continue working. In power-down mode, the RAM content is saved, the oscillator is frozen, and all microcontroller operations stop until the next interrupt or hardware reset.

1.4 LCD1602 Display Module

The LCD display module has the advantages of small size, low power consumption, rich display content, ultra-thin and light, and is widely used in pocket instruments and low-power application systems. At present, the character LCD display module is the most commonly used information display in the design of single-chip applications. The LCD1602 LCD display module can display two lines, 16 characters per line. Its character generator ROM has a character library of numbers, English letters and some special symbols, but no Chinese characters. LCD1602 can be used to create 8 6×8 dot matrix custom character libraries. It uses a single +5V power supply, has a simple peripheral circuit configuration, is cheap, and has a high cost performance.

LCD1602 has two driving modes: parallel port driving and serial port driving. Parallel port driving must occupy a large number of valuable I/O interfaces of the microcontroller; while serial port driving must be based on the idle UART interface of the microcontroller. Its main functions are as follows: 40-channel dot matrix LCD driving, can be selected as row driving or column driving, input/output signal: output can generate 20×2 LCD driving waveforms; input accepts serial data and control signals sent by the controller, bias (V1∽V6), and displays the measured frequency signal readings through the microcontroller control.

2 Hardware System Design

2.1 Temperature acquisition circuit

When designing the circuit, in order for the DS18B20 to perform accurate temperature conversion, the I/0 line must be powered during the conversion. Since the operating current of the DS18B20 reaches 1 mA, it is not enough to rely solely on the 5K pull-up resistor to provide power. This problem becomes more acute when several DS18B20s are hung on the same I/0 line and want to perform temperature conversion at the same time. Considering that this system only performs single-point measurement, the method of connecting an external power supply from the VDD pin is adopted.

2.2 Main control circuit and reset circuit

AT89S52 has a variety of packaging forms. This system uses PDIP packaging for easy welding. The AT89S52 microcontroller has rich resources and provides a variety of solutions for solving the design of this system. This system occupies some resources of AT89S52I/0 port P1, P2, and P3.

2.3 Level conversion circuit

RS_232 uses positive and negative voltages to represent logic states, which is different from TTL's high and low levels. Therefore, in order to connect with the TTL devices of the computer interface or terminal, the level and logic relationship must be transformed between RS_232 and TTL circuits. This transformation can be achieved using discrete components or integrated circuit chips. Considering the bidirectional transmission of data, the system uses the MAX232 chip, which can complete the bidirectional level conversion from TTL to RS_232.

2.4 Display Circuit

LCD1602 is a common liquid crystal display, which is characterized by easy reading and writing, high display accuracy, less resource consumption compared with dynamic digital tube display, stable display data and strong anti-interference ability.

2.5 Hardware Configuration Circuit Diagram

The overall hardware circuit of the system includes four parts: temperature acquisition circuit, main controller circuit, level conversion circuit and display circuit. The circuit is shown in Figure 2.

Figure 2 System hardware circuit diagram

Figure 2 System hardware circuit diagram

3 Software System Design

3.1 Lower computer software design

The lower computer program design includes three parts: initialization of the microcontroller, access to DS18B20, and reading and writing to LCD1620. AT89S52 is the core part of the system, controlling the temperature conversion and reading the temperature value and converting it into decimal numbers and corresponding ASCII values ​​for display on 1602, and providing the PC with temperature values ​​through RS232. Its main workflow is: initializing internal components to meet environmental operating requirements, initializing DS18B20 and LCD1602; reading temperature values ​​and converting the collected data to 1602 for display; when encountering an interrupt, entering the interrupt service function to check whether the upper computer requests it to send data. Once the correct request is detected, the temperature value to be read is placed in the buffer in a certain format until the data is sent, and then returning to the interrupt point to continue executing the original function. The flow chart is shown in Figure 3 (a).

3.2 Host computer software design

In order to facilitate remote control, the collected temperature data can be transmitted to the computer in the control center through the RS_232 port for real-time monitoring. Using VB6.0[4] as the development platform, the software development and design can be completed efficiently and quickly.

There are two main methods to develop serial communication programs using Viusal Basic: ① Use the MSComm serial port control; ② Call the Window API function.

The method of using MSComm serial port control to achieve communication is more convenient, faster and less code-intensive than calling API dynamic link library functions, which can greatly improve programming efficiency and the stability of system design. This part of the software completes the design of the form, sets the interval of the Timer to 300ms, completes the addition of the MSComm control, sets its corresponding properties, analyzes and calculates the obtained data and displays it in the window. The flow chart is shown in Figure 3 (b).

Figure 3 Temperature measurement system program flow

Figure 3 Temperature measurement system program flow

4 Conclusion

Here the project completed the design and implementation of the temperature measurement system according to actual needs.

Including: overall architecture design, specific implementation of lower-level hardware and software, PC serial port upper-level software design, it has achieved the expected purpose. The system physical diagram is shown in Figure 4, and the front and back-end temperature displays are shown in Figure 5 (a) and Figure 5 (b).

The system makes full use of the advantages of DS18B20 such as miniaturization, low power consumption, high performance, and strong anti-interference ability, and transmits temperature data to the host computer through the serial port for unified management, which is conducive to the storage and query of temperature data and saves labor costs.

This system can be applied to many temperature measurement occasions. More advanced temperature measurement systems based on embedded systems and wireless sensor networks are also a hot topic of research. The next step will be to design a temperature control system based on feedback control.

Figure 4: Physical system

Figure 4: Physical system

Figure 5 Temperature measurement results display

Figure 5 Temperature measurement results display

Reference address:Design of temperature measurement system based on single chip microcomputer and PC serial communication

Previous article:Study on the interface of MGLS-12864 controlled by single chip microcomputer
Next article:Hardware Design of Zigbee Sensor Node Based on 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号