基于单片机的电加热恒温箱控制器设计 摘 要:恒温箱作为一种重要的工具广泛地应用于医疗、工业生产和食品加工等领
域。在常规的环境参数中,由于温度受其它因素影响较大,且难以校准,温度也是最难准确测量的一个参数。因此,恒温箱的性能在很大程度上取决于对温度的控制性能。
本设计采用单片机对恒温箱的温度进行PID控制,使其温度稳定在某一个设定值上。并且具有键盘输入温度给定值、定时时间,LED数码管显示温度值/时间和定时报警的功能,实现了自动控制温度的目的。
基于P89V51RD2的恒温箱温度控制系统主要实现了温度采集、A/D转换、软件滤波、温度控制及定时等功能。
首先,介绍了恒温箱设计的课题背景及意义,并结合设计要求和实际情况选择了设计所涉及到的主要功能器件,同时重点介绍了P89V51RD2、ADC0809、Pt100的主要功能。
其次,阐述了系统的工作原理,完成了系统结构图的设计,把系统划分为5大模块并完成了各大模块的设计工作,同时附以系统硬件电路原理图。
最后,设计了系统的软件。系统软件是用C语言进行软件设计的,C语言具有指令简单,数据量小等特点。
关键词:恒温箱;温度控制;单片机;PID控制
The Design of Electricity Heating Incubator Control System
Based on the MCU
Abstract: Incubators as an important tool widely used in medical, industrial production
and food processing in areas such as.Temperature is affected by other factors in the conventional environmental parameters, and also difficult to proofreading ; therefore, the temperature is one of the most difficult to measure accurately parameters . So, The performance of the incubator to a large extent depends on the temperature control performance.
The design uses single chip microcomputer to control the oven temperature through the PID control,causing its temperature control into suppose in the definite value in some.And the system has the keyboard entry temperature and time given value , LED displays temperature/timing value and surmounting boundary of the time reports outside.It realizes temperature control automatically.
Based on P89V51RD2, the oven temperature control system main realizes temperature collection, A/D conversion, software filtering, PID control and timing functions.
First, the paper introduces the background of the subject. Combined with the design requirements and the actual situation of the design ,the main devices that related to subject are confirmed. At the same time the main functions of P89V51RD2, ADC0809, Pt100 is written down.
Secondly, it describes the principle of the system, and achieves the concrete structure photo of the design. The system is divided into five modules and every major module of the design is completed .The hardware circuit schematics of the system is attached at last.
Finally, the software of the system is designed. The system software is written by C language, it is because the programme runs faster, and saves storage space.
Key Words: incubator ; temperature control;single-chip microcontroller ;PID
control
目 录
1 概 述 ............................................................................................................................ 1 1.1 课题研究背景 ................................................................................................................. 1 1.2 课题研究意义 ................................................................................................................. 2 1.3 课题研究内容 ................................................................................................................. 2 2 总体设计方案 .................................................................................................................... 3 2.1 课题要求 ......................................................................................................................... 3 2.2 系统总体设计 ................................................................................................................. 3 2.3系统功能模块方案设计 .................................................................................................. 4 2.3.1单片机的选择 ............................................................................................................... 4 2.3.2显示电路的选择 ........................................................................................................... 5 2.3.3键盘电路的选择 ........................................................................................................... 6 2.3.4温度采集电路的选择 ................................................................................................... 6 2.3.5温度控制电路的选择 ................................................................................................... 9 2.4 控制方法的选择 ........................................................................................................... 10 2.5开发环境及编程语言的选择 ........................................................................................ 10 2.5.1硬件开发环境选择 ..................................................................................................... 10 2.5.2软件开发环境选择 ..................................................................................................... 12 2.5.3编程语言的选择 ......................................................................................................... 13 3系统的硬件设计 ............................................................................................................... 14 3.1 系统硬件功能分析 ....................................................................................................... 14 3.2系统硬件电路设计 ........................................................................................................ 14 3.2.1单片机最小系统的设计 ............................................................................................. 14 3.2.2温度检测电路的设计 ................................................................................................. 15 3.2.3四分频电路的设计 ..................................................................................................... 17 3.2.4显示接口电路的设计 ................................................................................................. 18 3.2.5 键盘电路的设计 ........................................................................................................ 19 3.2.6 温度控制电路的设计 ................................................................................................ 19 3.2.7 报警电路的设计 ........................................................................................................ 20 3.2.8抗干扰措施的设计 ..................................................................................................... 21 3.2.9 PCB图的绘制 ............................................................................................................ 21 4数字PID及其算法 .......................................................................................................... 22 4.1 PID算法的数字化 ........................................................................................................ 22 4.2 PID算法的程序设计 .................................................................................................... 23 4.2.1 位置型PID算法程序的设计 ................................................................................... 23 4.2.2 增量型PID算法的程序设计 ................................................................................... 24 5 系统的软件设计 .............................................................................................................. 26
5.1 系统软件功能分析 ....................................................................................................... 26 5.2 主程序的设计 ............................................................................................................... 26 5.3 子程序的设计 ............................................................................................................... 27 5.3.1 系统初始化模块的设计 ............................................................................................ 27 5.3.2 显示模块的设计 ........................................................................................................ 28 5.3.3温度采集模块的设计 ................................................................................................. 29 5.3.4键扫描模块的设计 ..................................................................................................... 31 5.3.5 温度控制模块的设计 ................................................................................................ 32 5.3.6报警模块的设计 ......................................................................................................... 33 5.4 软件设计小结 ............................................................................................................... 34 6结束语 ............................................................................................................................... 35 参考文献 .............................................................................................................................. 36 致 谢 .............................................................................................. 错误!未定义书签。 附 录 .............................................................................................................................. 37 附录1系统源程序清单 ...................................................................................................... 37 附录2电加热恒温箱控制器原理图 .................................................................................. 49 附录3电加热恒温箱控制器PCB图 ................................................................................ 50
基于单片机的电加热恒温箱控制器设计
1 概 述 1.1 课题研究背景
二十一世纪是科技高速发展的信息时代,电子技术、微型单片机技术的应用更是空前广泛,是随着超大规模集成电路技术的发展而诞生的。由于它具有体积小、功能强、性价比高等特点,所以广泛应用于电子仪表、家用电器、节能装置、军事装置、机器人、工业控制等诸多领域,使产品小型化、智能化,既提高了产品的功能和质量,又降低了成本,简化了设计。它迅猛发展到了各个领域,人们也越来越感到应用单片机技术的优越性,因而单片机也得到了广泛的应用。同时,它也在不断地完善和发展。
电加热恒温箱的温度是医疗、工业生产和食品加工等领域的关键,因此对温度的测量及控制始终占据着重要的地位。市场上常见的温度传感器以电压输出为主要形式,不同的传感器其非线性曲线也各不相同,缺乏一个产品应具备的通用性和互换性。温度传感器应用范围很广、使用数量很大,但是在常规的环境参数中,由于温度受其它因素影响较大,而且难以校准,因此,温度也是最难准确测量的一个参数。常规方法测量温度误差大、准确度低、测量滞后的时间长。
近年来,国内传感器正向着集成化、智能化、网络化和单片系统化的方向发展,为开发新一代温度测量系统创造了有利条件。
在电加热恒温箱控制器系统的设计中,由电阻式温度传感器测量温度值并转换成电压信号,由变送器转换成标准的电压信号,经A/D转换器进行模数转换并读入单片机,经单片机处理后的温度数值,一方面送LED数码管显示;另一方面与给定值进行比较,并判断是否超限,将发出报警信号,提醒人注意并采取相应措施;否则正常显示温度数值,然后根据偏差值进行控制计算。从而进行温度的调节,使其达到指定要求。实践证明,现在采用电阻丝加热,不仅有利于避免在常规测温方法中测量误差大、准确度低、测量滞后时间长等问题,而且在节约能源和改善环境方面本设计显示出一定的优越性。
恒温箱主要是用来控制温度,它为农业研究、生物技术、测试提供所需要的各种环境模拟条件,因此可广泛适用于药物、纺织、食物加工等无菌试验、稳定性检查以及工业产品的原料性能、产品包装、产品寿命等测试。
随着单片机的飞速发展,通过单片机对被控对象进行控制日益广泛,具有体积小、功能强、性价比高等特点,把单片机应用于温度控制系统中可以起到更好的控温作用,恒温箱是使用单片机进行温度控制的典型应用,采用单片机做主控单元,
1