您当前的位置:首页 > 发表论文>论文发表

温度检测报警论文

2023-03-13 14:00 来源:学术参考网 作者:未知

温度检测报警论文

用DS18B20做的电子温度计,非常简单。

#include <reg51.h>
#include\"AscLed.h\"
#include <intrins.h>
#include <stdio.h>
//********************************************************
#define Seck (500/TK) //1秒中的主程序的系数
#define OffLed (Seck*5*60) //自动关机的时间5分钟!
//********************************************************
#if (FHz==0)
#define NOP_2uS_nop_()
#else
#define NOP_2uS_nop_();_nop_()
#endif
//**************************************
#define SkipK 0xcc //跳过命令
#define ConvertK 0x44 //转化命令
#define RdDs18b20K 0xbe //读温度命令
//*******************************************
extern LedOut(void);
//*************************************************
sbit PNP1=P3^4;
sbit PNP2=P3^5;
sbit BEEP=P3^2;
//***********************************
#defineDQ PNP2 //原来的PNP2 BEEP
//***********************************
static unsigned char Power=0;
//************************************
union{
unsigned char Temp[2]; //单字节温度
unsigned int Tt; //2字节温度
}T;
//***********************************************
typedef struct{
unsigned char Flag; //正数标志 0;1==》负数
unsigned char WenDu; //温度整数
unsigned int WenDuDot; //温度小数放大了10000

}WENDU;
//***********************************************
WENDU WenDu;
unsigned char LedBuf[3];
//----------------------------------
//功能:10us 级别延时
// n=1===> 6Mhz=14uS 12MHz=7uS
//----------------------------------
void Delay10us(unsigned char n){

do{
#if (FHz==1)
NOP_2uS;NOP_2uS;
#endif
}while(--n);
}
//-----------------------------------
//功能:写18B20
//-----------------------------------
void Write_18B20(unsigned char n){
unsigned char i;
for(i=0;i<8;i++){
DQ=0;
Delay10us(1);//延时13us 左右
DQ=n & 0x01;
n=n>>1;
Delay10us(5);//延时50us 以上
DQ=1;
}
}
//------------------------------------
//功能:读取18B20
//------------------------------------
unsigned char Read_18B20(void){
unsigned char i;
unsigned char temp;
for(i=0;i<8;i++){
temp=temp>>1;
DQ=0;
NOP_2uS;//延时1us
DQ=1;
NOP_2uS;NOP_2uS;//延时5us
if(DQ==0){
temp=temp&0x7F;
}else{
temp=temp|0x80;
}
Delay10us(5);//延时40us
DQ=1;
}
return temp;
}
//-----------------------------------
void Init (void){
DQ=0;
Delay10us(45);//延时500us
DQ=1;
Delay10us(9);//延时90us
if(DQ){ //0001 1111b=1f
Power =0; //失败0
}else{
Power++;
DQ=1;
}
}
//----------------------------------
void Skip(void){
Write_18B20(SkipK);
Power++;
}
//----------------------------------
void Convert (void){
Write_18B20(ConvertK);
Power++;
}
//______________________________________
void Get_Ds18b20L (void){
T.Temp[1]=Read_18B20(); //读低位
Power++;
}
//______________________________________
void Get_Ds18b20H (void){
T.Temp[0]=Read_18B20(); //读高位
Power++;
}
//------------------------------------
//规范化成浮点数
// sssss111;11110000
// sssss111;1111(0.5,0.25,0.125,0.0625)
//------------------------------------
void ReadTemp (void){
unsigned char i;
unsigned intF1=0;
char j=1;
code int Code_F[]={6250,1250,2500,5000};

WenDu.Flag=0;

if (T.Temp[0] >0x80){ //负温度
T.Tt =~T.Tt+1; //取反+1=源吗 +符号S
WenDu.Flag=-1;
}
T.Tt <<= 4; //左移4位
WenDu.WenDu=T.Temp[0]; // 温度整数
//**************************************************
T.Temp[1]>>=4;
//---------------------------
for (i=0;i<4;i++){ //计算小数位
F1 +=(T.Temp[1] & 0x01)*Code_F;
T.Temp[1]>>=1;
}
WenDu.WenDuDot=F1; //温度的小数
Power=0;
}
//----------------------------------
void Delay1S (void){
static unsigned int i=0;

if (++i==Seck) {i=0ower++;}
}
//----------------------------------
void ReadDo (void){
Write_18B20(RdDs18b20K);
Power++;
}
/**********************************
函数指针定义
***********************************/
code void (code *SubTemp[])()={
Init,Skip,Convert,Delay1S,Init,Skip,ReadDo,Get_Ds18b20L,
Get_Ds18b20H,ReadTemp
};
//**************************************
void GetTemp(void){
(*SubTemp[Power])();
}
//---------------------------------------------------
//将温度显示,小数点放大了10000.
void GetBcd(void){
LedBuf[0]=WenDu.WenDu / 10;
LedBuf[1]=WenDu.WenDu % 10 +DotK;
LedBuf[2]=(WenDu.WenDuDot/1000);

if(LedBuf[0]==0)LedBuf[0]=Black;

if(WenDu.Flag==0) return;
if(LedBuf[0] !=Black){
LedBuf[2]=LedBuf[1];
LedBuf[1]=LedBuf[0];
LedBuf[0]=Led_Pol; //'-'
}else{
LedBuf[0]=Led_Pol; //'-'
}
}
/*
//---------------------------------------------------
void JbDelay (void){
static long i;
if (++i>=OffLed){
P1=0xff;
P2=0xff;
PCON=0x02;
}
}
*/
/*****************************************************
主程序开始
1:2002_10_1 设计,采用DS18B20测量
2:采用函数数组读取DS18B20.LED数码管显示正常!
3:改变FHz可以用6,12MHz工作!
******************************************************/
code unsigned char Stop[3] _at_ 0x3b;
void main (void){
P1=0xff;
WenDu.WenDu=0;
while (1){
GetTemp();
GetBcd();
// JbDelay();
LedOut();
}
}
复制代码
20091012_8b1ef92155560c13b5807ZmoDVSacjwD[1].jpg (12 KB)

2009-10-21 23:21 上传
下载次数:0

求一篇关于温度检测及上下限报警的论文 最好是翻译成英文的。

  

  

  Testing the "System on a Chip"
  Much has been written about the concept of a "system on a chip," the ever-increasing integration of logic and analog functions on one silicon die or chip. This paradigm is about to change. The results of work by universities, national labs, and companies such as Motorola, Inc., are paving the way for a true system on a chip, or SOC. These new SOCs will not only analyze data, but will measure, analyze, and react to their environment.

  The integration of power and analog elements with a CMOS microcontroller unit (MCU) has been possible for several years. Products have been introduced such as an integrated 68HC05 motor controller with integral power devices in an H-bridge configuration (1990). In 1993, a product called a System Chip MCU was introduced that provided a Society of Automotive Engineers J1850 interface, including the physical layer. This chip could withstand 40 V, based on the combination of power and analog capability with the MCU. However, the system input was not included in previous monolithic designs.

  What is the most recent development that promises to truly enable a system on a chip? It is the ability to combine CMOS and MEMS (microelectromechanical systems) structures into one process flow. Photo 1 illustrates a 68HC05 microcontroller with a 100 kPa pressure sensor integrated onto a single silicon die. A likely application is a side air bag sensor.

  A pressure sensor, inside the door panel of a car, could detect the change in pressure when the panel crumples under an impact. The ability to program the onchip microcontroller will enable the auto manufacturer to embed the control algorithm inside the chip. To complete an entire system, only a mechanism for actuating the air bag need be added. This actuation capability could be yet another step in the continuous integration of silicon and electronics/electromechanical systems. This platform provides a first step in the integration of electronics with electromechanical structures and at the same time raises several issues that must be resolved before a low-cost, high-quality product can be mass produced. One of these issues is that of testability.

  Typical logic circuits have many years of accumulated test data that can be used as a foundation for building the next generation of product. With sensors, however, very little previous technology can be reused. The reasons are the relative infancy of sensor technology and the uniqueness of each type of sensor. For example, the technology used to measure pressure (a thin diaphragm with integral strain gauge) is much different from that used for measuring acceleration (a proof mass forming a moving capacitor). The testing technology is different as well. Pressure measurements require a pressure source to be connected to the sensor; acceleration or shock detection requires shaking the device at some known frequency and force.

  System Configuration
  To develop a proof-of-concept vehicle (see Figure 1), a 100 kPa pressure sensor was integrated onto Motorola's standard 8-bit 68HC05 microcontroller core along with the associated analog circuitry [1]. To this basic core was added analog circuitry for signal conditioning, a voltage and current regulator, and 10-bit A/D and 8-bit D/A converters. A temperature sensor was also incorporated into the design for compensation purposes.
  The pressure transducer is temperature dependent and has an inherent nonlinearity. To increase the accuracy of the system, a calibration or conditioning algorithm must be programmed into the microcontroller.

  The pressure transducer's output is conditioned by a variable gain and input offset amplifier that is controlled by the program stored in the MCU. The A/D converter is used to read the temperature sensor's and the pressure transducer's outputs. The band gap voltage regulator supplies a constant voltage for the pressure sensor, amplifier, and A/D converter. The band gap current regulator provides a constant current source for the temperature sensor.

  Calibration Method
  The MCU calibrates and compensates the pressure sensor's nonlinearity and temperature drift. To provide the maximum accuracy, an A/D input resolution of 10 bits was chosen and the calculation resolution was set at 16 bits, fixed point. To calibrate span and offset and compensate the nonlinearity of the sensor output, calibration software performs a second-order polynomial correction of sensor output described as:
  Vout = c0 + c1Vp + c2Vp2 (1)
  Cp = (c0, c1, c2 ) (2)

  where:

  Vout = calibrated output
  Vp = uncompensated pressure sensor output

  To compensate the temperature dependency of Cp, calibration software is used to calculate Cp using a second-order polynomial fitting equation to temperature:

  c0 = c00 + c01Vt + c02 Vt2 (3)
  c1 = c10 + c11Vt + c12 Vt2 (4)
  c2 = c20 + c21Vt + c22Vt2 (5)
  (6)

  where:

  Vt = temperature sensor output

  The Cts are read during the calibration procedure and stored in EPROM. The MCU calculates Cp from the temperature sensor output, Vt, and Ct. Cp is then used to calculate the calibrated pressure sensor output using the pressure transducer's output, Vp.

  Calibration Procedure
  The calibration system first adjusts the gain and offset of the amplifier to use the full A/D range. Then the characteristics of the uncompensated pressure sensor output are examined over several temperature points. At each temperature, a second-order polynomial described in Equation 1 is obtained by least square fitting and the coefficient set, Cp, is determined. After completing the calculation of Cp over all temperature points, Ct is determined by the least square fitting of Equations 3, 4, and 5 to determine Cp over the temperature points. At present, at least three separate temperature sampling points are required to complete the fitting calculation.

  Figure 2. The uncompensated output of the sensor-based system on a chip is plotted at four different temperatures.

  Characteristics
  Figure 2 shows the uncompensated sensor output characteristics over various temperatures after adjusting gain and offset. Based on these data, the coefficients for calibration were calculated and written into the onchip EPROM by the calibration system. The compensation value was rounded off to 8 bits. Figure 3 shows the calibrated and compensated output of the integrated MCU. Figure 4 shows the error from expected values. Since 1 bit is 0.4% error, the result indicates the error is within 0.4% of full-scale output.

  Figure 3. Compensated output of the system on a chip is improved through testing and calibration at three temperatures.

  Test Issues
  Several issues are raised by this initial work, including the different types of testing required, unique test equipment, and the need for multipass testing. To make a low-cost integrated solution possible, these concerns must be addressed.

  The integration of a physical measurement function onto the already complex mixed-mode analog-digital chip raises the need for an additional type of testing. The physical medium being tested must be applied to the device and the response must be measured. Measuring the response to a physical stimulus is not a
  Figure 4. Bit error in the compensated output is within 1 bit at both 30°C and 85°C

  standard test for the semiconductor industry, especially under multiple temperatures. Standard equipment can test the digital and analog portions of the chip, but the application of a physical stimulus and the procedure of heating and cooling the device under test rapidly and accurately drive the need for a modified and unique tester. These testers are one of a kind and are not available as a standard. The tester therefore represents a large part of the final unit's cost.

  Not only are the testers expensive, but the throughput is limited. This raises the cost of each part because of the increased depreciation costs allocated to each device. The cost is further increased by the need for multipass testing. Remember that each part is first tested, using at least three different temperatures, to determine the transducer's output characteristics over temperature. Then these values are used to derive the compensation algorithm, which is loaded into the onchip EPROM. To complete the cycle, the device is once again tested over temperature to prove accuracy. Hence, not only is a special tester required, but it becomes a bottleneck since it must be used twice to complete each device—once to measure the characteristics and a second time to verify the result.

  Future Directions
  Finding ways to reduce the cost of testing is one of the keys to making a low-cost integrated sensor and MCU a reality. Ideas that could prove promising include:
  Thoroughly characterizing the design
  Limiting the operating temperature
  Limiting the accuracy
  Programming the MCU to take data during testing
  Loading the test and compensation algorithm into the MCU before testing
  Since this is a first proof-of-concept device, further characterization could provide a way to limit the number of temperatures required for compensations. Limiting the operating temperature range could also reduce the number of temperatures required for compensation testing. Data shown in Figure 3 indicate a 5% accuracy from 5°C to 25°C. Another potential cost reduction step would be to use the MCU's programmability for data logging during test. By storing the compensation program in the onchip EPROM prior to test, and then logging the uncompensated output into the EPROM during test, it might be possible to develop an algorithm for a one-pass test over temperature.

  Without a breakthrough in lowering the cost of testing this new integrated sensor and MCU, the system designer may be limited to the continued use of the present day solution—separate MCU and sensor.
  ----------
  All the DS18B20 sensors, used for the multipoint test temperature, are connected with MCU on one of IO bus, and temperature data are collected by turns. If the system has a large amount of sensors, the time of MCU used in processing the temperature data is obviously prolonged, so the cycle of alternate test gets longer. In this paper, a new method that DS18B20 are rationally grouped is presented, and some measures are taken in software; as a result, the speed of alternate test advances distinctly.
  ---------

基于单片机温度测量与控制 毕业论文

  摘要
  本设计的温度测量计加热控制系统以AT89S52单片机为核心部件,外加温度采集电路、键盘显示电路、加热控制电路和越限报警等电路。采用单总线型数字式的温度传感器DSI8B20,及行列式键盘和动态显示的方式,以容易控制的固态继电器作加热控制的开关器件。本作品既可以对当前温度进行实时显示又可以对温度进行控制,以使达到用户需要的温度,并使其恒定再这一温度。人性化的行列式键盘设计使设置温度简单快速,两位整数一位小数的显示方式具有更高的显示精度。建立在模糊控制理论控制上的控制算法,是控制精度完全能满足一般社会生产的要求。通过对系统软件和硬件设计的合理规划,发挥单片机自身集成众多系统及功能单元的优势,再不减少功能的前提下有效的降低了硬件的成本,系统操控更简便。
  实验证明该温控系统能达到0.2℃的静态误差,0.45℃的控制精度,以及只有0.83%的超调量,因本设计具有很高的可靠性和稳定性。

  关键词:单片机 恒温控制 模糊控制
  引言
  温度是工业控制中主要的被控参数之一,特别是在冶金、化工、建材、食品、机械、石油等工业中,具有举足重轻的作用。随着电子技术和微型计算机的迅速发展,微机测量和控制技术得到了迅速的发展和广泛的应用。 采用单片机来对温度进行控制,不仅具有控制方便、组态简单和灵活性大等优点,而且可以大幅度提高被控温度的技术指标,从而能够大大提高产品的质量和数量。MSP430系列单片机具有处理能强、运行速度快、功耗低等优点,应用在温度测量与控制方面,控制简单方便,测量范围广,精度较高。

  温度传感器将温度信息变换为模拟电压信号后,将电压信号放大到单片机可以处理的范围内,经过低通滤波,滤掉干扰信号送入单片机。在单片机中对信号进行采样,为进一步提高测量精度,采样后对信号再进行数字滤波。单片机将检测到的温度信息与设定值进行比较,如果不相符,数字调节程序根据给定值与测得值的差值按PID控制算法设计控制量,触发程序根据控制量控制执行单元。如果检测值高于设定值,则启动制冷系统,降低环境温度;如果检测值低于设定值,则启动加热系统,提高环境温度,达到控制温度的目的。

  图形点阵式液晶可显示用户自定义的任意符号和图形,并可卷动显示,它作为便携式单片机系统人机交互界面的重要组成部分被广泛应用于实时检测和显示的仪器仪表中。支持汉字显示的图形点阵液晶在现代单片机应用系统中是一种十分常用的显示设备,汉字BP机、手机上的显示屏就是图形点阵液晶。它与行列式小键盘组成了现代单片机应用系统中最常用的人机交互界面。

  本文设计了一种基于MSP430单片机的温度测量和控制装置,能对环境温度进行测量,并能根据温度给定值给出调节量,控制执行机构,实现调节环境温度的目的。

  ━、硬件设计
  1:MSP430系列单片机简介及选型
  单片机即微控制器,自其开发以来,取得了飞速的发展。单片机控制系统在工业、交通、医疗等领域的应用越来越广泛,在单片机未开发之前,电子产品只能由复杂的模拟电路来实现,不仅体积大,成本高,长期使用后元件老化,控制精度大大降低,单片机开发以后,控制系统变为智能化了,只需要在单片机外围接一点简单的接口电路,核心部分只是由人为的写入程序来完成。这样产品体积变小了,成本也降低了,长期使用也不会担心精度达不到了。特别是嵌入式技术的发展,必将为单片机的发展提供更广阔的发展空间,近年来,由于超低功耗技术的开发,又出现了低功耗单片机,如MSP430系列、ZK系列等,其中的MSP430系列单片机是美国德州仪器(TI)的一种16位超低功耗单片机,该单片机

相关文章
学术参考网 · 手机版
https://m.lw881.com/
首页