Current location - Education and Training Encyclopedia - Graduation thesis - Thesis topic of temperature sensor
Thesis topic of temperature sensor
Temperature measurement system based on 5 1 single chip microcomputer

Abstract: Single-chip microcomputer is widely used in detection and control systems, and temperature is a quantity that the system often needs to measure, control and maintain. This paper introduces the design of AT89C205 1 single chip microcomputer temperature control system from both hardware and software, and gives the hardware schematic diagram and program block diagram.

Key words: single chip microcomputer AT89C2051; Temperature sensor ds18b20; Temperature; measure

introduce

Single chip microcomputer has been widely used in electronic products, and it is also used for temperature detection and temperature control in many electronic products. Therefore, this paper designs a temperature measurement system based on AT89C205 1 of atmel Company. This is a low-cost temperature detection circuit realized by using redundant I/O port of single chip microcomputer. This circuit is very simple and easy to realize, and it is suitable for almost all types of single chip microcomputer.

First, the system hardware design

The hardware structure of the system is shown in figure 1.

1. 1 data acquisition

The data acquisition circuit is shown in Figure 2. The temperature sensor DS 18B20 collects the real-time temperature of the controlled object and provides it as data input to the P3.2 port of AT89C205 1. In this design, the object we control is room temperature. Of course, as an improvement, we can separate the sensor from the circuit board and communicate with it through the data line, which is convenient for measuring various objects.

DS 18B20 is a single-wire digital temperature sensor produced by DALLAS Company, which has a 3-pin TO-92 small package. The temperature measuring range is -55℃ ~+ 125℃, and the 9-bit ~ 12-bit A/D conversion accuracy can be programmed, and the temperature measuring resolution can reach 0.0625℃. The measured temperature is output in serial with 16-bit digital quantity with extended sign, which supports the voltage range of 3v ~ 5.5v, making the system design more flexible and convenient. Its working power supply can be introduced at the far end or generated in parasitic power mode; A plurality of DS 18B20 can be connected in parallel into three or two wires, and the CPU can communicate with a plurality of DS 18B20 with only one port wire, which occupies less ports of the microprocessor and saves a lot of leads and logic circuits. The above characteristics make DS 18B20 very suitable for long-distance multi-point temperature detection system. The resolution setting and the alarm temperature set by the user are stored in EEPROM, which will still be saved after power failure. DS 18B20 gives more choices of voltage and characteristics, so we can build an economical temperature measurement system. As shown in Figure 2, the DQ pin of DS 18B20 is the digital signal input/output terminal; 1 pin GND is the power ground; Three-pin VDD is the input of external power supply.

AT89C205 1 (hereinafter referred to as 205 1) is an 805 1 compatible microcontroller, which is completely compatible with Intel's MCS-5 1. It has a 2K programmable flash memory and a data storage space of 128B bytes, which can directly drive the LED, just like 805655.

1.2 interface circuit

Fig. 2 The connection diagram of single chip microcomputer 205 1 and temperature sensor DS 18B20.

The interface circuit consists of ATMEL's 205 1 single chip microcomputer, ULN2003 Darlington chip, 451BCD decoder, serial EEPROM24C 16 (saving system parameters), MAX232, digital tube and peripheral circuits. Single chip microcomputer communicates in parallel from P 1.0 ~. Decoded by 45 1 1BCD decoder, the temperature of 10 bit and 10 bit are statically displayed by two * * cathode light-emitting diodes.

Serial EEPROM24C 16 is a standard I2C specification, which can be read and written with only two pins. Because the P 1 of MCU 205 1 is a bidirectional I/O port, we use P 1 as the output port in the design. As can be seen from fig. 2, P 1.7 is connected to pin 6 of 24C 16 as a serial clock output signal, and P 1.6 is connected to pin 5 of 24C 16 as a serial data output. P 1。 4 and P 1.5 are used as bit selection signals for two digital tubes. When P 1.4= 1, select the first digital tube (unit); When P 1.5= 1, select the second digital tube (ten digits). The output signals of p 1.0 ~ p 1.3 are connected to the decoder 45 1 1 as the display of the digital tube. In addition, because the P3 port of MCU 205 1 has special functions, P3.0(RXD) serial input port, P3. 1(TXD) serial output port, P3.2 (incoming) external interrupt 0, P3.3(INT 1) external interrupt/kloc-0. P3.2 and P3.3 are used as interrupt signal interfaces; P3.4 and P3.5 are used as external timing/counting input points. P3.7 is used as pulse output to control the switch of LED.

Because the LED digital tube with * * cathode is used in the circuit, a Darlington circuit ULN2003 is added to amplify the signal and generate enough current to drive the digital tube to display. Because 45 1 1 can only decode decimal BCD and can only be translated into 0 to 9, here we use 45 1 1 to decode and output the temperature we need.

Brief introduction of 1.3 alarm circuit

Fig. 3 Wiring diagram of seven-segment digital tube temperature display

The alarm circuit designed in this paper is relatively simple, which consists of a self-oscillating buzzer (as long as a voltage of more than 3V is applied at both ends of the buzzer, the buzzer will keep barking) and a light-emitting diode (as shown in Figure 3). In this design, the buzzer is controlled by ULN2003 current amplifier IC. When the required temperature reaches a certain upper or lower limit (in this paper, the upper limit temperature is 45℃ and the lower limit temperature is 5℃), the alarm circuit starts to work, and the main program design is as follows:

Main()// main function

{unsigned character I = 0;; & ltbr/>; Unsigned int m, n; & ltbr/>; while( 1)& lt; br/>; { I = read temperature(); //Reading temperature}

If (I>0&I<= 10) // If the temperature is between 0 and 10 degrees, directly assign a value to the seven-segment digital tube.

{ p 1 = design p 1[I]; }

Otherwise//If the temperature is greater than 10 degrees,

{ m = I % 10; //Assign a value to the first seven-segment digital tube first.