1、摘要本文所描述的是作者领导由四个三一大学高年级学生组成的团队进行的一个跨学科工程项目的设计。该项目的目标是设计一个气室内温度控制系统。该系统的要求是:当实际气室的温度阶跃响应时,规定范围内的温度进入气室后,稳定时的温度误差和超调量必须少于一个绝对温度。本组学生开发设计是基于摩托罗拉MC68HC05系列单片机。该问题的教学价值也通过某些步骤的关键描述在本文说明。研究结果表明,解决该方案需要具有广泛的工程学科知识,包括相关电子、机械和控制系统工程的知识。1引言该设计项目来自一个实际应用问题,一个关于显微镜载玻片干燥剂温控器欧米茄CN-390温度控制器,而这个设计的目标是研发一个自定义的通用温度控制
2、系统取代欧米茄系统、一个以更低的成本实现相同功能的自定义控制器,就像欧米茄系统一样,并不需要能够全方位的处理各种问题。该载玻片干燥机的机械布局如图1-1所示。干燥机的主体是一个足够大的绝缘充气室,里面依次存放着薄纸包着的石蜡。为了使石蜡保持适当稳定性,载玻片气室的温度必须维持稳定。第二个气筒(电子围绕元件)设有一个电阻加热器、一个温度控制器以及一个安装在干燥机上的风扇,是为了把风吹过加热器,把热量带到载玻片气室。图1-1载玻片干燥机的机械布局自1996-97学年来,本文作者带领四位三一大学工程科学系的高年级学生开展此项目的研究。本文的目的说明了提出一些问题并详细阐述学生的一些解决方案,而且讨论
3、了这种类型的跨学科设计项目在教学方面应用的问题。这份学生报告曾经在1997年全国本科毕业生研讨会上提出过并讨论过。第2节给出该设计的更多详细情况,包括性能规格。第3节具体 学生的设计。第4节是论文的主体,讨论该设计在教学应用方面的实施问题。最后,第5节全文总结。2问题阐述该项目基本的思想是设计一个自定义温度控制系统来取代相关的欧米茄CN-390温度控制器。温度时通常保持在一个稳定的常数,但重要的是阶跃变化可以被“合理”的跟踪。因此主要要求如下:可以对空气室的温度进行设定,同时显示设定值和实际温度,以及在设定温度值情况下,可接受范围内的跟踪阶跃变化,稳态误差,超调量。表1精确的规格说明设定温度接
4、口设定温度显示室内温度显示范围精度准确度60-991C1C室内温度阶梯响应范围(稳定状态)精度(稳定状态)最大超调设定时间(到1)60-991C 1C120s尽管表1部分说明并不明确,但是它清楚的反映了人们对数字显示器在设定值和实际温度的要求和温度应该通过数值输入来设定(而不是,通过电位器设置)。3系统设计根据微控设计,数字温度显示和单点输入的要求可能是最合适的。图2-2为学生的设计框图。图2-2温度控制器硬件结构图摩托罗拉MC68HC705B16(简称6805),是系统的核心。它通过一个简单的4键小键盘对温度进行设定,同时使用两个显示驱动控制7段LED数码管来显示定值和气室温度的测量值。所有
5、这些,输入和输出信号与6805的并行口相连。气室的温度值使用预校准热敏电阻测量,并通过6805的数模转换输入。最后,6085的脉冲宽度调制(PWM)输出用来驱动一个继电器,以控制线性电阻加热器的闭合和断开。图2-3更详细的显示了6805的接口和电子器件。使用暴风3K041103型号四键键盘,通过PA0-PA3端口进行数据输入。其中一个重要的功能是进行模式切换。两种模式:固定模式和运行模式。在固定模式下,其他两个键用于设定温度,一个增加,一个减少,第四个按键暂无作用。LED显示屏由哈里斯半导体ICM7212进行驱动,通过PB0-PB6端口与芯片相连,作为输出。热敏电阻由电压分频器驱动,通过AN0
6、针脚(八个模拟输入端口中的一个)相连。最后,PLMA针脚(两个PWM输出端口中的一个)驱动加热继电器。图2-3单片机原理图图3单片机原理图是关于用软件实现温度控制算法、保持温度显示以及改变键盘输入响应,这将不会在本文详细讨论,因为这并不是本文的重点,也没有编译完成。软件部分还没有确定控制算法,但很可能是一个简单的比例控制,比PID算法简单。一些控制设计的问题将在第四节讨论。4设计过程虽然该项目的本质是建立一个恒温器,但它有许多很好的契机可以供教学借鉴。高级工程本科教育的知识只是能够让学生们具有解决问题的能力。然而,很多情况下,实际情况却和理论有些不同。不过,这些不是问题,参与这个项目的设计,将
7、获得很多设计方面的宝贵经验。本节的其余部分着眼于其他的几个方面:4.1节讨论系统的一些特征,简化系统热性能的数学模型,以及一些简单理论的证明。4.2节介绍确定实际控制算法。4.3节指出控制设计程序的一些不足,并通过模拟环境,指出怎样克服问题。4.4节给出单片机的一些设计相关概述,以及出现问题和值得借鉴之处。4.1数学模型集总元件热系统符合线性控制,适用于载玻片干燥机的问题。图4-1显示了二阶集总元件热量模型的载玻片干燥机。状态变量是温度,Ta是箱内空气的温度,Tb是箱子本身的温度。该系统输入功率等于q(t)的热量和环境温度T的和。ma,mb分别对应空气和箱子的质量。Ca和Cb则分别是其对应热量
8、。m1和m2分别是空气与箱子间以及箱子与外界间的传热系数。图4-1集总元件热模型由图4可以推出(线性)状态方程拉普拉斯变换(1)和(2)等式,并整理Ta(s)。有趣的是,可以推出一个开环的热系统方程。其中K是一个常数,D(s)是一个二阶的多项式。K,tz,以及系数D(s)和在(1)和(2)等式中出现的系数功能相近。当然,在(1)和(2)等式中各种参数在未知的情况下,不难证明D(s)与其他参数的值无关,具有两个零点。因此传递函数可以写成(我们假设环境温度为常数)此外,可以推出1/tp11/tz1/tp2,即,零点在两极之间。开环零极点如图4-2所示。图4-2Gaq(s)的零极点为了获取完整的热模
9、型,从(3)式中除去常数K和3个未知的时间常数。四个未知参数并不少,但由简单的实验表明,1/tp11/tz,1/tp2统基本上是一阶函数,且tz,tp2近似为0。因此,开环系可以写成:(下标p1已经被去掉了)过初始温度和热量值大范围内的设置,简单的开环阶跃响应实验结果表明,K0.14o/W,295S。4.2控制系统设计使用(4)式的一阶开环传递函数Gaq(s),并且假定加热器的输出函数q(t)为线性,图4-3是系统框图代表闭环系统。Td(s)是设定温度的函数,C(s)是传递函数,Q(s)是热量输出,单位是瓦特。图4-3简化的闭环系统框图鉴于这种简单情况,前面所指的线性控制设置,例如,根轨迹法设
10、计法可以使C(s)中符合要求的阶跃响应对应的上升时间、稳态误差和超调量符合表格1所示。当然,一个有足够增益的比例控制器就可以满足各种要求。超调量改变是不可能既增加增益又减少稳态误差和上升时间的。不幸的是,如果要获得足够增益,需要生产超过实际生产能力的大容量加热器。这是本系统的实际问题,将会致使上升时间不符合要求。这要求学生们如何利用这个经过仔细计算的简化模型,在整体性能上达到最佳控制。4.4模型仿真该设计的大部分性能和限制功能,应该可以使用图4-3简化模型来完成。但有一个数据对闭环系统其他方面的影响并非能够如此简单的仿真。其中最主要的是:量化误差的模拟和数模转换,测量温度和使用PWM控制加热器
11、。这两种都是非线性的、时变的。所以唯一切实可行的方法就是通过仿真(或实验)加以研究。图7Simulink仿真闭环系统框图显示了Simulink情况下的闭环系统框图,其中包括A/D转换和使用标准Simulink量化饱和块建立的饱和量化模型。建立PWM调制模型比较复杂,需要一个自定义的S函数来表示。图4-3仿真闭环系统框图这种仿真模型已经被证明在衡量不同的PWM基本参数对设计的影响以及适当参数的选择中特别有用。(即时间越长,PWM调制会产生更多温度误差。另一方面,时间越长,继电器抖动机率越小。)PWM调制方法往往很难让学生掌握,并且仿真模型允许研究测试运行和明显的影响。4.4单片机简单的闭环控制、
12、键盘输入和显示控制是经典单片机应用技术,这个设计项目包含上述三个方面。因此这是一个优秀的全面的单片机应用练习。此外,由于该项目是来源于现实,它不会是一个简单的输入输出设计就能完成的。相反,这个项目需要制定一个完整的嵌入式应用。这需要从大量的单片机型号中选取适当的芯片并学着使用一个相当复杂的开发环境。最后,必须设计和选取印刷电路板和单片机,以及外接元件。单片机选择从现有的实际经验来看,经常选用摩托罗拉公司的单片机。不过,芯片的选择不应该局限于此。研究表明,系统要求符合工作需求的单片机。这对学生很困难,因为他们缺乏良好的经验与判断能力,只能通过制造商的产品选择指南决定单片机的选择。部分问题是各种外
13、围设备(例如,应该使用哪种显示驱动程序?)连接方法的选择。摩托罗拉的相关应用研究2,3,4中的证明是非常有用的,基本阐述了可实用性的连接方法以及单片机和外围连接的组合方式。在最终要求的基础上,选择MC68HC705B16,其现有A/D输入和PWM输出以及24个数字I/O线。这样选择是有必要的,因为此项目需要一个A/D通道、一个PWM通道和11个I/O引脚(见图3)。该决定为了安全方面,因为选择一个完整的开发系统是有必要的,该项目预算中没有足够的资金再次购买元件。单片机应用开发外围设备的电路硬件、软件的开发、最终调试、单片机的自定的印刷电路板和外设都需要某种形式的发展环境。如同单片机本身,一个开
14、发环境的选择是令人困惑并需要一些教师的专业知识。摩托罗拉三级发展环境,包括从简单的评估板(在约100美元)到全面的实时在线仿真器(在大约7500元)。中间选项被选为本项目的MMEVS,其中包括:平台板(支持所有6805-family部分), 模拟器模块(具体到B系列部分),和 电缆头和目标适配器(简明包装)。总体而言,该系统的成本为900美元,并且在一定局限下,提供了在线仿真能力。它还配备了简单但足够的软件开发环境RAPID5。学生发现学习使用这类系统的挑战。但他们在现实世界的微控制器应用获得的经验大大超过了第一使用典型的简单评估板的经验。印刷电路板一个简单的(虽然布局绝对不平凡)印刷电路板是
15、这个工程提供的另一个现实学习的机会。图4-4显示最后的板布局与包轮廓(50%实际大小)。相对简单的电路使手工安置和路由实践方面更实际,它有可能提供更好的结果比一个这样的应用程的自动性。学生因此接触到基本印刷电路布局问题和基本的设计规则。本排版软件使用的是非常漂亮的包装印刷电路板,板制作是在内部电子技术员的帮助下完成的。图4-4单片机印刷版布局结论本文的目的是描述一个跨学科的本科工程设计项目:一个基于单片机的温度控制系统,包括设定点输入数字与设定值/实际温度显示。本文已描述了这样系统的一个设计,并且讨论了许多来自工程的问题。这些问题的解决通常需要入门课程要求的知识,尤其是在老师的建议和监督下,实
16、际上可以促进大学生发展。从教学方法观点看,问题的理想特征包括微控制器和外围设备的简单使用,有效地运用导论水平的物理系统建模和设计闭环控制。并需要相对简单的实验和模拟(详细的性能预测)。并可取的是一些技术相关方面的问题,包括热敏电阻和温度传感器(分别需要知识脉宽调制和校准技术)的实际使用、单片机选择和开发系统的使用以及并印制电路设计。鸣谢作者要感谢参与这个项目的学生,马克朗斯道夫,马特洛尔和戴维舒克曼,表现出辛勤工作、奉献和能力。这个工程和工程成功全赖他们。参考文献1朗斯道夫,M.拉尔,D.舒克曼,和P.莱因哈特.“显微镜载玻片干燥剂温控器”1997届全国大学生研究,(奥斯汀,德克萨斯州,四月1
17、997.海报介绍.2摩托罗拉公司,凤凰城,亚利桑那.温度测量和使用它的显示mc68hc05b4和mc14489,1990。摩托罗拉semiconductorapplicationnote an431.3摩托罗拉公司,凤凰城,亚利桑那.hc05单片机驱动技术使用mc68hc705j1a,1995.摩托罗拉半导体应用笔记an1238.4摩托罗拉公司,凤凰城,亚利桑那.hc05mcu键盘解码技术使用mc68hc705j1a,1995.摩托罗拉半导体应用笔记an1239.5摩托罗拉公司,凤凰城,亚利桑那.快速集成开发环境用户手册,1993.(快速是由宝洁微机系统,有限公司.)附录:翻译原文Temper
18、ature Control Using a Microcontroller:An Interdisciplinary Undergraduate Engineering Design ProjectJames S. McDonaldDepartment of Engineering ScienceTrinity UniversitySan Antonio, TX 78212AbstractThis paper describes an interdisciplinary design project which was done under the authors supervision by
19、 a group of four senior students in the Department of Engineering Science at Trinity University. The objective of the project was to develop a temperature control system for an air-filled chamber. The system was to allow entry of a desired chamber temperature in a prescribed range and to exhibit ove
20、rshoot and steady-state temperature error of less than 1 degree Kelvin in the actual chamber temperature step response. The details of the design developed by this group of students, based on a Motorola MC68HC05 family microcontroller, are described. The pedagogical value of the problem is also disc
21、ussed through a description of some of the key steps in the design process. It is shown that the solution requires broad knowledge drawn from several engineering disciplines including electrical, mechanical, and control systems engineering.1 IntroductionThe design project which is the subject of thi
22、s paper originated from a real-world application. A prototype of a microscope slide dryer had been developed around an OmegaTM model CN-390 temperature controller, and the objective was to develop a custom temperature control system to replace the Omega system. The motivation was that a custom contr
23、oller targeted specifically for the application should be able to achieve the same functionality at a much lower cost, as the Omega system is unnecessarily versatile and equipped to handle a wide variety of applications.The mechanical layout of the slide dryer prototype is shown in Figure 1. The mai
24、n element of the dryer is a large, insulated, air-filled chamber in which microscope slides, each with a tissue sample encased in paraffin, can be set on caddies. In order that the paraffin maintain the proper consistency, the temperature in the slide chamber must be maintained at a desired (constan
25、t) temperature. A second chamber (the electronics enclosure) houses a resistive heater and the temperature controller, and a fan mounted on the end of the dryer blows air across the heater, carrying heat into the slide chamber. This design project was carried out during academic year 199697 by four
26、students under the authors supervision as a Senior Design project in the Department of Engineering Science at Trinity University. The purpose of this paper isto describe the problem and the students solution in some detail, and to discuss some of the pedagogical opportunities offered by an interdisc
27、iplinary design project of this type. The students own report was presented at the 1997 National Conference on Undergraduate Research 1. Section 2 gives a more detailed statement of the problem, including performance specifications, and Section 3 describes the students design. Section 4 makes up the
28、 bulk of the paper, and discusses in some detail several aspects of the design process which offer unique pedagogical opportunities. Finally, Section 5 offers some conclusions.2 Problem StatementThe basic idea of the project is to replace the relevant parts of the functionality of an Omega CN-390 te
29、mperature controller using a custom-designed system. The application dictates that temperature settings are usually kept constant for long periods of time, but its nonetheless important that step changes be tracked in a “reasonable” manner. Thus the main requirements boil down toallowing a chamber t
30、emperature set-point to be entered,displaying both set-point and actual temperatures, andtracking step changes in set-point temperature with acceptable rise time, steady-state error, and overshoot.Although not explicitly a part of the specifications in Table 1, it was clear that the customer desired
31、 digital displays of set-point and actual temperatures, and that set-point temperature entry should be digital as well (as opposed to, say, through a potentiometer setting).3 System DesignThe requirements for digital temperature displays and setpoint entry alone are enough to dictate that a microcon
32、trollerbased design is likely the most appropriate. Figure 2 shows a block diagram of the students design. The microcontroller, a MotorolaMC68HC705B16 (6805 for short), is the heart of the system. It accepts inputs from a simple four-key keypad which allow specification of the set-point temperature,
33、 and it displays both set-point and measured chamber temperatures using two-digit seven-segment LED displays controlled by a display driver. All these inputs and outputs are accommodated by parallel ports on the 6805. Chamber temperature is sensed using a pre-calibrated thermistor and input via one
34、of the 6805s analog-to-digital inputs. Finally, a pulse-width modulation (PWM) output on the 6805 is used to drive a relay which switches line power to the resistive heater off and on.Figure 3 shows a more detailed schematic of the electronics and their interfacing to the 6805. The keypad, a Storm 3
35、K041103, has four keys which are interfaced to pins PA0 PA3 of Port A, configured as inputs. One key functions as a mode switch. Two modes are supported: set mode and run mode. In set mode two of the other keys are used to specify the set-point temperature: one increments it and one decrements. The
36、fourth key is unused at present. The LED displays are driven by a Harris Semiconductor ICM7212 display driver interfaced to pins PB0PB6 of Port B, configured as outputs. The temperature-sensing thermistor drives, through a voltage divider, pin AN0 (one of eight analog inputs). Finally, pin PLMA (one
37、 of two PWM outputs) drives the heater relay.Software on the 6805 implements the temperature control algorithm, maintains the temperature displays, and alters the set-point in response to keypad inputs. Because it is not complete at this writing, software will not be discussed in detail in this pape
38、r. The control algorithm in particular has not been determined, but it is likely to be a simple proportional controller and certainly not more complex than a PID. Some control design issues will be discussed in Section 4, however.4 The Design ProcessAlthough essentially the project is just to build
39、a thermostat, it presents many nice pedagogical opportunities. The knowledge and experience base of a senior engineering undergraduate are just enough to bring him or her to the brink of a solution to various aspects of the problem. Yet, in each case, realworld considerations complicate the situatio
40、n significantly.Fortunately these complications are not insurmountable, and the result is a very beneficial design experience. The remainder of this section looks at a few aspects of the problem which present the type of learning opportunity just described. Section 4.1 discusses some of the features
41、 of a simplified mathematical model of the thermal properties of the system and how it can be easily validated experimentally. Section 4.2 describes how realistic control algorithm designs can be arrived at using introductory concepts in control design. Section 4.3 points out some important deficien
42、cies of such a simplified modeling/control design process and how they can be overcome through simulation. Finally, Section 4.4 gives an overview of some of the microcontroller-related design issues which arise and learning opportunities offered.4.1 MathematicalModelLumped-element thermal systems ar
43、e described in almost any introductory linear control systems text, and just this sort of model is applicable to the slide dryer problem. Figure 4 shows a second-order lumped-element thermal model of the slide dryer. The state variables are the temperatures Ta of the air in the box and Tb of the box
44、 itself. The inputs to the system are the power output q(t) of the heater and the ambient temperature T. ma and mb are the masses of the air and the box, respectively, and Ca and Cb their specific heats. 1 and 2 are heat transfer coefficients from the air to the box and from the box to the external
45、world, respectively.Its not hard to show that the (linearized) state equationscorresponding to Figure 4 areTaking Laplace transforms of (1) and (2) and solving for Ta(s), which is the output of interest, gives the following open-loop model of the thermal system:where K is a constant and D(s) is a se
46、cond-order polynomial.K, tz, and the coefficients of D(s) are functions of the variousparameters appearing in (1) and (2).Of course the various parameters in (1) and (2) are completely unknown, but its not hard to show that, regardless of their values, D(s) has two real zeros. Therefore the main tra
47、nsfer function of interest (which is the one from Q(s), since well assume constant ambient temperature) can be writtenMoreover, its not too hard to show that 1=tp1 1=tz 1=tp2, i.e., that the zero lies between the two poles. Both of these are excellent exercises for the student, and the result is the
48、 openloop pole-zero diagram of Figure 5.Obtaining a complete thermal model, then, is reduced to identifying the constant K and the three unknown time constants in (3). Four unknown parameters is quite a few, but simple experiments show that 1=tp1 _ 1=tz;1=tp2 so that tz;tp2 _ 0 are good approximations. Thus the open-loop system is essentially first-order and can therefore be written (where the subscript p1 has be