Design of intelligent temperature detection system based on MSP430

Publisher:码农闲散人Latest update time:2013-04-13 Source: dzscKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1 Introduction

  With the increasing electrification and automation of equipment, real-time monitoring of equipment and environment is particularly important. The traditional temperature measuring device thermistor generally measures voltage, which needs to be converted into the corresponding temperature, which requires the support of other external hardware. Therefore, the hardware circuit is relatively complex and the design cost is relatively high. The intelligent temperature detection system uses an improved intelligent temperature sensor DS18B20. The digital temperature sensor is connected to the single-chip microcomputer through a single bus. The system structure is simple and has strong anti-interference ability. It is suitable for on-site temperature measurement in harsh environments. It can also be used in warehouse temperature measurement, high-rise air conditioning control and agricultural production process monitoring.

  2. Hardware composition of temperature detection system

  The temperature detection system consists of the main controller MSP430F149, the storage module CAT24WC64, the LCD module HTM1602A, the voice alarm module ISD1420, the matrix keyboard and a single bus connected to several temperature sensors DS18B20. The system hardware block diagram is shown in Figure 1. As can be seen from the figure, the multi-point temperature measurement circuit only occupies one ordinary IO port of the MSP430F149, and the system resource utilization rate is high.

Figure 1 Overall circuit diagram of system hardware

  2. 1 DS18B20

  2.1.1 Internal structure of DS18B20

  The internal structure of DS18B20 is shown in Figure 2. It mainly consists of four parts: photolithography ROM, temperature sensor, non-volatile temperature alarm trigger TH and TL configuration register. DS18B20 can have a variety of packaging forms. In the TO-92 package, as shown in Figure 2 (a), GND is the ground pin, DQ is the data input/output pin, and VDD is the optional external power supply pin, which is grounded in the parasitic power supply mode. The 64-bit serial number in the photolithography ROM is photolithography before leaving the factory, and it can be regarded as the address sequence code of the DS18B20. The arrangement of the 64-bit photolithography ROM is: the first 8 bits (28H) are the product type label, the next 48 bits are the serial number of the DS18B20 itself, and the last 8 bits are the cyclic redundancy check code of the previous 56 bits.

  The role of the photolithography ROM is to make each DS18B20 different, so that multiple DS18B20s can be connected to one bus.

Figure 2 DS18B20 overall structure diagram

  2.1.2 Working process of DS18B20

  The working sequence of accessing DS18B20 is usually: initialization, sending ROM operation command, sending RAM operation command. The initialization reset work makes the master device know that the sensor DS18B20 exists and is ready to work. By sending ROM commands, it can be known whether a specific DS18B20 exists and whether it exceeds the temperature warning value.

  There are 5 ROM operation commands, namely read ROM (33H), match ROM (55H), search ROM (FOH), skip ROM (CCH), and alarm search command (ECH). By sending RAM operation commands, you can set the power supply mode, start temperature conversion, and read and write the temporary storage area of ​​DS18B20. There are 6 functional commands, namely convert temperature (44H), read temporary storage area (BEH), write temporary storage area (4EH), copy temporary storage area (48H), re-adjust EEPROM (B8H), and read power supply mode (B4H). Each command has a different code. When transmitted on the bus, the device completes the corresponding operation according to the received command code. Therefore, the single-line communication function of DS18B20 is completed in time-sharing, and it has strict timing requirements. [page]

    2. 2 MSP430F149

  The main control chip of this design uses the 16-bit FLASH microcontroller MSP430F149 from Texas Instruments. It has the advantages of strong processing power, fast operation speed and low power consumption. Its operating voltage is 1.8V ~ 3.6V; the CPU runs an orthogonal reduced instruction set. There are many on-chip registers. The memory can realize a variety of operations.

  MSP430F149 has many interrupt sources and can be nested arbitrarily. When the system is in power-saving state, it only takes 6 microseconds to wake up with an interrupt request. It also has a wealth of peripheral devices. Its 16-bit timer TimerA has 4 working modes and can perform multiple capture/comparison functions at the same time; 48 independently programmable I/O ports; 2 serial communication interfaces ART0 and ART1; FLASH memory up to 60KB, and the number of erase and write times can reach 100,000 times. The ultra-low power consumption and good performance-price ratio of this chip make it very suitable for the field of industrial monitoring.

  2.3 Voice Alarm Module

  The system uses voice alarm to alarm when the temperature exceeds the limit. The voice alarm is controlled by the ISD1420 chip, which has a segmented recording and playback function, and each recording and playback time is 20 seconds. The pre-recorded temperature voice is judged by the MSP430 microcontroller to determine the measured temperature. When the measured value is higher or lower than the standard value, the corresponding recording is played, thereby realizing the temperature alarm function.

  2.4 Temperature display module

  The liquid crystal display module HTM 1602A is a 2-row 16-column character LCD module based on the S6A0069 chip. Its character display resolution is 5 × 8 (that is, each character is composed of a 5 × 8 dot matrix). The control program written based on S6A0069 can also be easily applied to most other character liquid crystal display modules. Therefore, the HTM 1602A module is selected to display the temperature measurement results of the system.

  2.5 Data Storage Module

  The system uses CAT24WC64 as the storage chip.

  CAT24WC64 is a 64k-bit serial CMOS EEPROM, which contains 8192 8-bit bytes and has a 32-byte write buffer. The device is operated through the I2C bus interface and has a special write protection function. The temperature measurement system uses CAT24WC64 to centrally record the registration information of all temperature sensors on the single bus, that is, to store the 64-bit photolithography ROM serial code of DS18B20 in address order. Each serial code occupies 8 bytes of space. The system management program will calculate the address serial number of the sensor registration code based on 8 bytes and feedback it to the user as the sensor identification number.

  2.6 Serial communication interface circuit design

  The temperature data collected by the MSP430F149 microcontroller is transmitted to the host computer. The communication interface of the MSP430 microcontroller is connected to the RS232 serial port to receive or send data and instructions. However, the TTL level of the microcontroller is incompatible with RS232, so MAX232 is used for level conversion. The interface circuit diagram is shown in Figure 3.

Figure 3 Serial interface circuit between MSP430F149 and PC

  MSP430 has two groups of communication interfaces, UTXD0, URXD0 and UTXD1, URXD1, the first group is used here. MSP430F149 microcontroller 3. 3V signal comes out of UTXD0 and is input to the T1 IN pin of MAX232, converted into a ±15V signal and sent to the 2nd pin (RXD) of the communication standard connector by T1OUT, ±15V signal comes out of the 3rd pin (TXD) of the communication standard connector and is input to the R1 IN pin of MAX232, converted into a ±15V signal and sent to the URXDO of the microcontroller by R10UT.

  3. Temperature Detection System Software Design

  The MSP430 series is a 16-bit microcontroller with technical features such as high integration, rich functions and low power consumption. It uses C language to complete program design, which greatly improves the efficiency of development and debugging. At the same time, the documentation generated by C language is easy to understand and convenient for porting.

  3.1 Lower computer programming

  The system program design includes the main program, reset subroutine, alarm and resolution setting subroutine, temperature conversion subroutine, temperature reading subroutine, temperature calculation and temperature display subroutine, etc. The access process of MSP430F149 to DS18B20 is: first initialize DS18B20, then perform ROM operation command, and finally operate the memory RAM. The program flow chart is shown in Figure 4. The following is a brief introduction to several main subroutines of the MSP430 series microcontroller C language.

Figure 4 Program flow chart

[page]

    3.1.1 Reset subroutine

  The main function of this program is to reset the DS18B20 to facilitate subsequent operations. Reset requires the main CPU to pull down the data line for 500 microseconds and then release it. After receiving the signal, the DS18B20 waits for about 16 to 60 microseconds and then sends a 60 to 240 microsecond low pulse. The main CPU receives this signal to indicate that the reset is successful.

  bit ResetDS18B20( )

  { unsigned char ;i

  bit flag;

  DS18B20= 0:

  for( i= 0; i< 200; i++ ) ; //keep low level for 500 microseconds

  DS18B20= 1:

  for( i= O; i< 30; i++ ) ; //wait 60 microseconds

  flag = DS18B20; //Get DS18B20 status

  for( i= 0; i< 100; i++ ) ; //wait 300 microseconds

  return flag; // flag = 0 reset successful, flag = 1, reset unsuccessful

  }

  3.1.2 Write a byte subroutine:

  The CPU pulls the data line from high level to low level to generate a write start signal; within 15 microseconds, the written bit is sent to the data line; DS18B20 receives the bit information 15 to 60 microseconds later; there must be more than 1 second of high level recovery before writing the next bit; the above process is repeated 8 times to complete the write operation of one byte.

  vo idWRDS18B20 (unsigned char data0)

  { unsigned char ,i ;j

  for ( j = 0; j < 8; j + + )

  {

  DS18B20= 0; // Pull high level to low level to generate write start signal

  for ( i = 0; i < 1; i + + ) ;

  DS18B20 = data0& 0x01; //Write one bit in 15 microseconds

  for( i= 0; i< 20; i++ ) ; //Wait for 60 microseconds, DS18B20 completes sampling

  DS18B20= 1; //High level recovery

  data0= data0> > 1; // right shift, prepare for the next bit}

  }

  3.1.3 Read a byte subroutine

  The CPU pulls the data line from a high level to a low level for more than 1 microsecond, and then to a high level to generate a read start signal; within 15 microseconds, the CPU reads one bit; the read cycle is 60 microseconds, and there must be a high level recovery of more than 1 microsecond before reading the next bit; the above process is repeated 8 times to complete the read operation of one byte.

  unsigned charRDDS18B20()

  { unsigned char ,i ,j data0= 0;

  bit temp;

  for ( j = 0; j < 8; j + + )

  {DS18B20= 0; //High level is pulled to low level for more than 1 microsecond

  for ( i = 0; i < l i + + ) ;

  DS18B20= 1; //Pull to high level again to generate read start signal

  for( i= 0; i< 1; i+ + );

  temp = DS18B20; //Read one bit within 15 microseconds

  for (i = 0; i < 20; i + +); // Wait for 60 microseconds

  data0= dataO >> 1; // prepare for the next bit

  if(temp==1)data0= dataO|0x80;

  else data0= data0& 0x7;f

  DS18B20= 1; //High level recovery

  for( i= O; i< 1; i+ + ); }

  return data0; }

  3.2 Host computer software programming

  The system uses MSCOMM control to realize data exchange between VC++ and single-chip microcomputer. It has the advantages of simple program implementation, program modularization, reliable operation, etc., and can meet the industrial control requirements in most cases.

  The main purpose of using the MSCOMM control is to handle serial port interactions through events. The MSCOMM event of the control is responsible for capturing or handling these communication events and communication errors.

  4 Conclusion

  The temperature measurement system uses the highly integrated and low-power MSP430F149 as the core microprocessor, and uses the sensor DS18B20 to measure, store and display the temperature. The experiment shows that when the range of the external temperature test is set at 0℃ ~ 50℃, the measurement error can be ensured to be no more than ±0.5℃, the temperature displayed on the test board is accurate to 0.0625℃, the AD conversion time is 750ms, and the transmission distance is 40m. In addition, other signals such as humidity, pressure, etc. can also be expanded on the basis of this system.

References:

[1]. MSP430F149 datasheet http://www.dzsc.com/datasheet/MSP430F149+_874114.html.
[2]. DS18B20 datasheet http://www.dzsc.com/datasheet/DS18B20_8175.html.
[3]. CAT24WC64 datasheet http://www.dzsc.com/datasheet/.html.
[4]. ISD1420 datasheet http://www.dzsc.com/datasheet/ISD1420_409804.html.
[5]. ROM datasheet http://www .dzsc.com/datasheet/ROM_1188413.html.
[6]. MSP430 datasheet http://www.dzsc.com/datasheet/MSP430_490166.html.
[7]. S6A0069 datasheet http://www.dzsc.com/datasheet/S6A0069+_1.html.
[8]. RS232 datasheet http://www.dzsc.com/datasheet/RS232_585128.html.
[9]. TTL datasheet http:// www.dzsc.com/datasheet/TTL_1174409.html.
[10]. MAX232 datasheet http://www.dzsc.com/datasheet/MAX232_7.html.

Keywords:MSP430 Reference address:Design of intelligent temperature detection system based on MSP430

Previous article:Design and implementation of wireless blood oxygen finger clip based on MSP430F149 and nRF905
Next article:Design of Distributed Greenhouse Monitoring System Based on ZigBee Technology

Latest Microcontroller Articles
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号