桂花蒸

[Sun Yat-sen University Competition] Portable temperature measurement system

 
Overview
Team information: Take-off group: Chen Peng, Chen Wendong, Huang Yi Award information: Second prize in the electronic design competition at Sun Yat-sen University
**1. **Brief description of the task** ** Design and produce a portable temperature measurement system to achieve Low temperature reminder and high temperature alarm function. ** ** ** **Basic Requirements** ** ① Complete the temperature measurement system circuit design and board fabrication and debugging.  ②When the buzzer is higher than  30  degrees Celsius,  an audible alarm will sound within  1 second  . ③Upload the temperature information to the computer for real-time viewing.  ** **Play part** ** ①Add an  LCD  or  OLED  screen to display the temperature.  ②Add a button to modify the temperature alarm threshold.  ③ Feel free to  DIY  a shell to make the system stable and beautiful.
**2、******摘要与引言******** ****摘要****: 本设计是一种基于STC89C51单片机的便携式测温警报系统,通过单片机系统控制实现对温度的采集,显示,报警。由温度传感器DS18B20数字温度传感器实现对温度信号的采集,并将温度信号发送给单片机,判断是否达到报警温度。报警温度上下限可以通过按键手动调节。显示部分由一块LCD显示屏实现。此外,系统还加装了一块WiFi模块芯片,使其能够与个人计算机通信,实现遥控检测功能。该系统结构简单,测量精度高,量程宽,响应快,功耗低,适用于日常生活和生产中的温度检测报警。 关键词:单片机 传感器 温度检测报警 ****引言****: 随着现代社会科技进步和发展,人们的工农业生产和日常生活中,对于精准温度监测的需求越来越高,温度监测系统已经遍及了生活的各个方面,具有广泛的应用前景和重大的现实意义。单片机又称单片微控制器,是一种集成电路芯片,可以根据需要添加外部芯片,利用单片机的控制功能实现便携化和智能化。本文将围绕单片机系统介绍此便携式测温警报系统。 **3、**设计思路简述**** ****设计思路:******** (1)控制部分 从功能和通用性考虑,我们选择STC89C51芯片作为接口芯片使用,实现核心控制功能,此外,由于89C51单片机已经十分普及,所以其零售价也十分低廉,低成本,高效能。
(2)温度采集 在温度采集方面,我们抛弃了传统的热敏电阻利用电流随温度变化的特性来测试温度的方法,而采用了DS18B20温度传感器。与传统方式相比,该传感器可以直接将采集到的温度信号转为数字信号发送给单片机,省去了运用热敏电阻需要用到的转换电路,这种模块功能芯片化 的特点,符合了当今电子信息行业追求集成化,模块化,可移植性强的趋势,使得电路设计更加简洁,逻辑清晰。不仅如此,我们选择的这款温度传感器还具有体积小,抗干扰能力强,精度高,响应快的优点,由此可以看出其优越性。 (3)显示部分 显示模块主要由一块液晶点阵屏幕实现,主要完成额定报警温度和当前温度的显示。 (4)按键部分 按键控制模块通过一组按键实现上下限的修改。 (5)WIFI通信模块 围绕信息采集和控制部分主芯片,我们还增设了一个WIFI控制芯片,意图实现遥控监测功能。在WIFI模块芯片的选择上,我们考虑到低成本和实用性,选择了这款ESP8266WIFI模块,ESP8266强大的片上处理和存储能力,使其可通过GPIO口集成传感器及其他应用的特定设备,实现了最低前期的开发和运行中最少地占用系统资源。ESP8266高度片内集成,包括天线开关balun、电源管理转换器,因此仅需极少的外部电路,且包括前端模块在内的整个解决方案在设计时将所占PCB空间降到最低。 ****系统框图**** 该便携式测温警报系统的硬件结构如图所示。 ![QQ图片20200726232738.png]
**4、******模块功能说明******** ****控制部分STC89C51:**** 1.简介 STC系列单片机是美国STC公司推出的一种51内核COMS8位控制器。他是采用8051核的ISP(In System Programming)在系统可编程芯片,片内含有4K bytes Flash 存储器,兼容标准的MCS-51指令系统和80C51引脚结构。具有ISP特性,配合PC端的控制程序可以将用户的代码烧录进去,省去了购买编程器的步骤,适合学生学习与使用。 2.主要组成 (1)中央处理器单元CPU(8位) 用于数据处理、位操作(位测试、置位、复位) (2)片内4K程序存储器FLASH ROM 用于存放程序和初始数据 (3)内部存储器RAM 用于存放可读写数据 (4)定时器 3个16位 计数满时向CPU中断 (5)并行IO口 用于系统总线,拓展IO接口芯片 (6)串行IO口(UART) 用于串行通信 (7)中断源8个 可以变成控制 (8)外形封装 40脚PDIP、44脚PLCC和PQFP 3.引脚功能说明: l VCC:电源电压。 l GND:接地。 l P0口:P0口为一个8位漏级开路双向I/O口,每脚可吸收8TTL门电流。当P1口的管脚第一次写1时,被定义为高阻输入。P0能够用于外部程序数据存储器,它可以被定义为数据/地址的第八位。在FIASH编程时,P0 口作为原码输入口,当FIASH进行校验时,P0输出原码,此时P0外部必须被拉高。 l P1口:P1口是一个内部提供上拉电阻的8位双向I/O口,P1口缓冲器能接收输出4TTL门电流。P1口管脚写入1后,被内部上拉为高,可用作输入,P1口被外部下拉为低电平时,将输出电流,这是由于内部上拉的缘故。在FLASH编程和校验时,P1口作为第八位地址接收。与AT89C51不同的是,P1.0和P1.1还可作为定时/计数器2的外部计数输出和输入。 l P2口:P2口为一个内部上拉电阻的8位双向I/O口,P2口缓冲器可接收,输出4个TTL门电流,当P2口被写“1”时,其管脚被内部上拉电阻拉高,且作为输入。并因此作为输入时,P2口的管脚被外部拉低,将输出电流。这是由于内部上拉的缘故。P2口当用于外部程序存储器或16位地址外部数据存储器进行存取时,P2口输出地址的高八位。在给出地址“1”时,它利用内部上拉优势,当对外部八位地址数据存储器进行读写时,P2口输出其特殊功能寄存器的内容。P2口在FLASH编程和校验时接收高八位地址信号和控制信号。 l P3 port: The P3 port pins are 8 bidirectional I/O ports with internal pull-up resistors, which can receive and output 4 TTL gate currents. When "1" is written to P3 port, they are internally pulled up to high level and used as input. As an input, since the external pull-down is low, port P3 will output current (ILL) due to the pull-up. P3 port can also be used as some special function ports of STC89C51, as shown below: P3 port pin alternative function P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 /INT0 (external Interrupt 0) P3.3 /INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input) P3.6 /WR (external data memory write strobe) P3.7 /RD (external data memory read strobe) Port 3 receives some control signals for flash programming and programming verification at the same time. l RST: reset input. When the oscillator resets the device, the RST pin must be held high for two machine cycles. l EA'/VPP: When EA' remains low, the external program memory (address is 0000H-FFFFH) is used during this period, regardless of whether there is internal program memory. Note that in encryption mode 1, EA' is internally locked to RESET; when the EA' end remains high, the internal program memory is locked. During FLASH programming, this pin is also used to apply the 12V programming power (VPP). l XTAL1: The input of the oscillator inverting amplifier and the input of the internal clock working circuit. l XTAL2: The output terminal of the oscillator inverting amplifier. ****Display part:**** 1. Introduction LCD1602 liquid crystal display is a widely used character-type liquid crystal display module. It consists of a character-type liquid crystal display (LCD), main control and drive circuit HD44780 and its extended drive circuit HD44100, as well as a small number of resistors, capacitors and structural parts assembled on a PCB board. The advantages are small size, light weight and low power consumption. 2. Parameter (1) display capacity: 16×2 characters. (2) Chip working voltage: 4.5~5.5V. (3) Working current: 2.0mA (5.0V). (4) The optimal working voltage of the module: 5.0V. (5) Character size: 2.95mm×4.35mm (width×height) 3. Pin function description: l Pin 1: VSS is the ground power supply. l Pin 2: VDD is connected to the 5V positive power supply. l Pin 3: VL is the contrast adjustment terminal of the LCD. The contrast is the weakest when connected to the positive power supply and the highest when connected to ground. When the contrast is too high, a "ghost" phenomenon will occur. The contrast can be adjusted through a 10kQ potentiometer during use. . l Pin 4: RS is the register selection pin. When the level is high, the data register is selected, and when the level is low, the instruction register is selected. l Pin 5: R/W is the read/write signal line. When the level is high, the reading operation is performed, and when the level is low, the writing operation is performed. When RS and R/W are both low level, instructions or display addresses can be written; when RS is low level and R/W is high level, the busy signal can be read; when RS is high level, R/W is When low, data can be written. l Pin 6: The E terminal is the enable terminal. When the E terminal jumps from high level to low level, the LCD module executes the command. l Pins 7~14: D0~D7 are 8-bit bidirectional data lines. l Pin 15: Backlight positive. l Pin 16: Negative pole of backlight. 4. Instructions ! [QQ Picture 20200726233100.png] The read/write operations of the LCD1602 liquid crystal module, the operations of the display screen and the cursor are all implemented through instruction programming (where 1 is high level and 0 is low level), They are introduced separately as follows. (1) Command 1: Clear the screen. Instruction code 01H, the cursor is reset to address 00H. (2) Instruction 2: Cursor reset. The cursor is reset to address 00H. (3) Command 3: Input mode setting. Among them, I/D represents the moving direction of the cursor, high level moves right, low level moves left; S represents whether all the text on the display screen moves left or right, high level means valid, and low level means invalid. (4) Command 4: Display switch control. Among them, D is used to control the on and off of the overall display. High level indicates that the display is on, and low level indicates that the display is off. C is used to control the on and off of the cursor. High level indicates that there is a cursor, and low level indicates that there is no cursor. ;B is used to control whether the cursor flashes, high level flashes, low level does not flash. (5) Instruction 5: Cursor or character shift control. Among them, S/C means moving the displayed text when the level is high, and moving the cursor when the level is low. (6) Command 6: Function setting command. Among them, DL means that it is a 4-bit bus at high level and 8-bit bus at low level; N means that it is a single line display at low level and double line display at high level; F means that it displays 5×7 points at low level. Matrix characters, 5×10 dot matrix characters are displayed when the level is high. (7) Instruction 7: Character generator RAM address setting. (8) Instruction 8: DDRAM address setting. (9) Instruction 9: Read busy signal and cursor address. Among them, BF is the busy flag. If it is high, it means busy. At this time, the module cannot receive commands or data. If it is low, it means it is not busy. (10) Instruction 10: Write data. (11) Instruction 11: Read data. ****Temperature sensor DS18B20: **** ** 1. Introduction DS18B20 temperature sensor is an improved intelligent temperature sensor launched by DALLAS Semiconductor Company in the United States. Compared with traditional thermistors, it can directly read By outputting the temperature, it can complete the collection and conversion of temperature signals. This sensor transmits the collected temperature to the microcontroller through the data pin. 2. Performance characteristics (1) Unique single-wire interface method, DS18B20 only needs one port line when connecting to the microprocessor to achieve two-way communication between the microprocessor and DS18B20. (2) Temperature measurement range -55℃~+125℃, inherent temperature measurement error is 1℃. (3) Support multi-point networking function, multiple DS18B20 can be connected in parallel on the only three lines, up to 8 can be connected in parallel to achieve multi-point temperature measurement. If there are too many, the power supply voltage will be too low, resulting in signal Transmission instability. (4) Working power supply: 3.0~5.5V/DC (data line parasitic power can be used) (5) No external components are required during use (6) The measurement results are transmitted serially in a 9~12-digit digital format (7) The diameter of the stainless steel protective tube is Φ6 (8) Suitable for temperature measurement of DN15~25, DN40~DN250 various medium industrial pipelines and narrow space equipment (9) Standard installation threads M10X1, M12X1.5, G1/2" optional (10) PVC cable outlet directly or German ball junction box outlet, easy to connect with other electrical equipment. 3. Working principle of DS18B20 reading and writing timing and temperature measurement The principle is the same as that of DS1820, except that the number of digits of the temperature value obtained is different due to different resolutions, and the delay time during temperature conversion is reduced from 2s to 750ms. The oscillation rate of the high temperature coefficient crystal oscillator changes significantly as the temperature changes, and the resulting The signal is used as the pulse input of counter 2. Counter 1 and the temperature register are preset at a base value corresponding to -55°C. Counter 1 subtracts the pulse signal generated by the low temperature coefficient crystal oscillator. When the preset value of counter 1 decreases When it reaches 0, the value of the temperature register will be increased by 1, the preset of counter 1 will be reloaded, and counter 1 will restart counting the pulse signals generated by the low temperature coefficient crystal oscillator. This cycle will stop when counter 2 counts to 0. The temperature register value is accumulated. At this time, the value in the temperature register is the measured temperature. The slope accumulator in the figure is used to compensate and correct the nonlinearity in the temperature measurement process, and its output is used to correct the preset value of counter 1. ! [QQ picture 20200726233144.png] 4. Control method (1) Control command Temperature conversion* * 44H Start DS18B20 for temperature conversion and read scratchpad * * BEH Read scratchpad 9-byte binary number Write scratchpad * * 4EH Write data to the TH and TL bytes of the temporary register. Copy the temporary register* * 48H Write the TH and TL bytes of the temporary register to the E2PROM and re-adjust the E2PROM * * B8H Write the TH and TL bytes in the E2PROM to the temporary register TH and TL bytes. Read the power supply mode* * B4H 启动DS18B20发送电源供电方式的信号给主CPU (2)初始化 在初始化序列期间,总线控制器拉低总线并保持480us(改延时可以在480~960us之间,但需要在480us以内释放总线)以发出一个复位脉冲,然后释放总线,进入接收状态(等待DS18B20应答)。总线释放后,单总线由上拉电阻拉到高电平。当DS18B20探测到I/O引脚上的上升沿后,等待15-60us,然后其以拉低总线60-240us的方式发出存在脉冲。至此,初始化时序完毕。 ![QQ图片20200726233227.png] (3)写时序 主机在写时隙向DS18B20写入数据,其中分为写”0”时隙,和写”1”时隙。总线主机使用写“1”时间隙向DS18B20写入逻辑1,使用写“0”时间隙向DS18B20写入逻辑0.所有的写时隙必须有最少60us的持续时间,相邻两个写时隙必须要有最少1us的恢复时间。 ![QQ图片20200726233245.png]  ![QQ图片20200726233259.png] (4)读时序 主机发起读时序时,DS18B20仅被用来传输数据给控制器。因此,总线控制器在发出读暂存器指令[0xBE]或读电源模式指令[0xB4]后必须立刻开始读时序,DS18B20可以提供请求信息。除此之外,总线控制器在发出发送温度转换指令[0x44] (或召回EEPROM指令[0xB8])之后读时序。 所有读时序必须最少60us,包括两个读周期间至少1us的恢复时间。当总线控制器把数据线从高电平拉到低电平时,读时序开始,数据线必须至少保持1us,然后总线被释放。DS18B20 通过拉高或拉低总线上来传输”1”或”0”。当传输逻辑”0”结束后,总线将被释放,通过上拉电阻回到上升沿状态。从DS18B20输出的数据在读时序的下降沿出现后15us 内有效。 ![QQ图片20200726233445.png]
****无线wifi模块ESP-8266-01S:******** 1. 简介 WT-01S WiFi 模块是由启明云端科技开发的、低功耗高性价比的嵌入式无线网络控制模块。可满足智能电网、楼宇自动化、安防、智能家居、远程医疗等物联网应用的需求。该模块核心处理器 ESP8266 在较小尺寸封装中集成了业界领先的 Tensilica L106 超低功耗 32 位微型 MCU,带有 16 位精简模式,主频⽀持 80 MHz 和 160 MHz,支持 RTOS,集成 Wi-Fi MAC/ BB/RF/PA/LNA,PCB 板载天线。 该模块支持标准的 IEEE802.11 b/g/n 协议,完整的 TCP/IP 协议栈。用户可以使用该模块为现有的设备添加联网功能,也可以构建独立的网络控制器。 2. 主要特性 ·采用 DIP-8 封装   ·PCB 板载天线 ·工作电压:3.3V ·工作环境温度:-20-85°C   ·CPU Tensilica L106 o RAM 50KB(可用) o 默认集成 Flash 8Mbit   ·系统 o 802.11 b/g/n o 内置 Tensilica L106 超低功耗 32 位微型 MCU,带有 16 位精简模式,主频支持 80 MHz 和 160 MHz,支持 RTOS o WIFI @2.4 GHz,支持 WEP/WPA-PSK/WPA2-PSK 安全模式 o 超小尺寸模组 24.7mm*14.4mm*11.0mm(±0.2mm) o 内置 10 bit 高精度 ADC o 内置 TCP/IP 协议栈 o 内置 TR 开关、balun、LNA、功率放大器和匹配网络 o 深度睡眠保持电流为 20uA o 串口速率最高可达 4Mbps o 待机状态消耗功率小于 1.0mW (DTIM3) o 支持 AT 远程升级及云端 OTA 升级 o 支持 STA/AP/STA+AP 工作模式 o 支持 2 个 GPIO o 支持 UART 3. RF特性 ![图片1.png] ![图片2.png] ![图片3.png]
**5、******系统整体设计******** ****(此处的原理图及PCB设计使用的是立创EDA,所使用电子元件均在立创商城购买)******** ****整体系统:******** ![图片4.png] ****1.显示模块******** ![图片5.png]
第1脚:接地 第2脚:VDD接5V电源正极 第4脚:寄存器选择,高电平时选择数据寄存器、低电平时选择指令寄存器 第5脚:读写信号线,高电平时选择读操作、低电平时选择写操作 第6脚:enable端 第7-14脚:数据端 屏幕显示内容: ![图片6.png]
包括: TEMP:当前温度 SETH:设定上限温度 SETL:设定下限温度
****2.报警提示模块******** ![图片7.png] 由两个LED报警提示和一个蜂鸣器组成,温度超过设定最高温度时D2亮,蜂鸣器报警;温度低于设定最低温度时D1亮,蜂鸣器报警。 ****3.供电模块**** ![图片8.png] Use four 1.5V batteries and a 7805 three-terminal voltage stabilizing integrated circuit as the power module, add two grounding capacitors to filter the AC component, and the out is about 5V. ![Picture 9.png] Considering that the working voltage of the LCD display and WIFI module is 5V, and the working voltage of the microcontroller is 3.3V, a 3.3V voltage stabilizing chip is connected in series to the output terminal OUT of the original power module, which can stabilize the 5V voltage of the battery power supply. to 3.3V. When the line is connected, the 5V working voltage module uses the OUT terminal for power supply, and the 3.3V working voltage module uses the VOUT terminal for power supply. ****4.WIFI module**** ![Picture 10.png] The working voltage of the ESP-01S chip is 5V, so it is powered by the IN terminal of the power supply. Communicates serially with the microcontroller and sends data to the PC. ****5. Temperature acquisition module**** ![Picture 11.png]
****6. Button module** ** ![Picture 12.png] Key function description: SET: Press once SET: Set Upper limit temperature Press SET twice: Set the lower limit temperature ADD: Add one to the set temperature value SUP: Subtract one from the set temperature value RETURN: Return to the temperature display interface **6, ******Simulation test**** * ** ****Temperature display function test: **** ** (1) Turn on the system switch and set the ambient temperature to 25°C ! [Picture 13.png] (2) Observe the LCD screen for 1s Then it responds to the temperature change and displays 20°C ! [Picture 14.png]
**** Manual change function test of upper and lower temperature limits: ****** ** (1) Set the default upper and lower temperature limits to 30°C, 20°C ![Picture 15.png] (2) Use the buttons to modify it so that the upper and lower limits are 35°C and 15°C ![Picture 16.png] ****Dangerous temperature alarm function test: ****** ** (1) Over the upper limit ! [Picture 17.png] Experimental results: ! [Picture 18.png] The high temperature alarm LED turns on and emits light, the buzzer P10 port forms a high potential, and the buzzer alarms (2) Beyond the lower limit ! [Picture 19.png] Experimental results: ! [Picture 20.png] The low temperature alarm LED is turned on and emits light, the buzzer P10 port forms a high potential, and the buzzer alarms. Simulation test results: The function is in line with expectations. **7. ******Physical test adjustment****** ** (1) The working voltage of each device is not uniform, and the same current source cannot be used. Solution: Add two voltage stabilizing chips l 7805 voltage stabilizing chip to stabilize the battery power supply voltage to 5V l SSP-1117 voltage stabilizing chip to stabilize the 5V voltage to 3.3V Different devices will use different power supply ports (5V / 3.3V) , each module has achieved normal operation . At the same time, in the voltage stabilizing chip module, we also configured a grounding capacitor to derive the AC component to make the system work more stable. (2) Abnormal LCD display. After voltage probe testing, it was found that the voltage of the LCD module was too high. Solution: Adjust the LCD module pull-up resistor. After adjustment, the LCD displays normally. (3) Circuit welding: Due to weak soldering of the circuit, the system could not work normally, and it was found after investigation. During the physical welding process, attention should be paid to checking for virtual soldering and pin short circuits caused by errors during the welding process. Especially when welding microcontrollers and integrated chips, due to their small pins and dense arrangement, they need to be operated very carefully and checked in time. (4) Microcontroller switching circuit. It was originally considered to place an LED light display in the switching circuit of the microcontroller and connect a resistor in series to divide the voltage to prevent the voltage at both ends of the LED from being too high and burning out the LED. However, after welding, it was found that the output voltage was lower than the operating voltage of the microcontroller due to the voltage reduction of the LED. After consideration, the LED and resistor of the switch circuit were deleted and replaced with wire connections. (5) Buzzer voltage adjustment During the test, it was found that the output voltage of the buzzer corresponding to the microcontroller pin was too low, resulting in an inconspicuous sound of the buzzer. After considering several solutions, the buzzer was adjusted. The way of voltage is so that the voltage of the buzzer will not be too low when the output voltage of the corresponding pin of the microcontroller is low level, and at the same time, the buzzer will respond normally when the pin outputs high level. The following is the component list: (The components used are all products from Lichuang Mall) ![Picture 21.png] **8. ******Summary and Reflection****** ** In this electronic In the design practice, we completed the design of a temperature monitoring system based on a single-chip microcomputer. We have a deeper understanding of the structure and functions of microcontrollers, learned and experienced the process of system experiments, and felt the infinite charm of electronic information technology. The portable temperature monitoring system we designed and implemented has a simple structure, is easy to transplant, and has certain practical value. At the same time, there are still many areas for improvement in this system, such as the maximum measured temperature of 99°C and the large remote monitoring distance limit. In future study and practice, we will continue to improve our own quality and improve product performance so that it can be better used in people's production and life.
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-30 06:53:47

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号