简易水温控制系统_第1页
简易水温控制系统_第2页
简易水温控制系统_第3页
简易水温控制系统_第4页
简易水温控制系统_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

一个简易水温控制系统的设计一个简易水温控制系统的设计 控制算法设计控制算法设计 摘摘 要要 在工农业生产和日常生活中 对温度的检测与控制始终有着非常重要的实际意义和广 泛的实际应用 为了加深计算机控制理论的理解 故设计一个温度控制系统 该系统主 要由温度信号采集与转换模块 主机控制模块 温度控制模块 液晶显示模块四部分组 成 控制算法为 PID 算法 系统可实现稳态误差小于 1 最大超调小于 1 并且调节 时间较短 恒定效果好 温度控制系统的对象存在滞后 它对阶跃信号的响应会推迟一 些时间 对自动控制产生不利的影响 因此对温度准确的测量和有效的控制是此类工业 控制系统中的重要指标 温度是一个重要的物理量 也是工业生产过程中的主要工艺参 数之一 物体的许多性质和特性都与温度有关 很多重要的过程只有在一定温度范围内 才能有效的进行 因此 对温度的精确测量和可靠控制 在工业生产和科学研究中就具 有很重要的意义 本文阐述了过程控制系统的概念 介绍了一个基于数字传感器 DS18B20 和单片机 STC89C52 的简单温度控制系统 以电热水壶为被控对象 通过实验的方法建立 温度控制系统的数学模型 采用了 PID 算法进行系统的设计 达到了比较好的控制目的 该系统可通过液晶显示器 LCD1602 显示数据或字符 通过按键设定参数 通过 DS18B20 测温 实现电热杯水温控制 通过 PL2303 下载端口 实现单机和上位机的通讯 实验表 明该系统能够实现对温度的控制 具有一定的控制精度 该系统测温电路简单 连接方 便 可用于简单温度控制的场合 关键词关键词 单片机 温度传感器 液晶显示器 PID 算法 A Ab bs st tr ra ac ct t InIn industrialindustrial andand agriculturalagricultural productionproduction andand dailydaily life life thethe testingtesting andand controlcontrol ofof temperaturetemperature hashas alwaysalways hadhad veryvery importantimportant practicalpractical significancesignificance andand extensiveextensive practicalpractical application application InIn orderorder toto deependeepen thethe understandingunderstanding ofof thethe computercomputer controlcontrol theory theory thethe designdesign ofof a a temperaturetemperature controlcontrol system system thethe systemsystem isis mainlymainly composedcomposed ofof temperaturetemperature signalsignal acquisitionacquisition andand conversionconversion module module hosthost controlcontrol module module temperaturetemperature controlcontrol module module liquidliquid crystalcrystal displaydisplay modulemodule fourfour parts parts thethe controlcontrol algorithmalgorithm forfor PIDPID algorithm algorithm SystemSystem cancan realizerealize thethe steadysteady statestate errorerror isis lessless thanthan 1 1 thethe maximummaximum overshootovershoot lessless thanthan 1 1 andand thethe adjustmentadjustment timetime isis shorter shorter constantconstant effecteffect isis good good LaggedLagged temperaturetemperature controlcontrol systemsystem ofof thethe object object itsits responseresponse toto thethe stepstep signalsignal willwill delaydelay somesome time time produceproduce adverseadverse effecteffect toto thethe automaticautomatic control control soso effectiveeffective forfor accurateaccurate temperaturetemperature measurementmeasurement andand controlcontrol isis anan importantimportant indicatorindicator inin thethe industrialindustrial controlcontrol system system TemperatureTemperature isis anan importantimportant physicalphysical quantities quantities itit isis alsoalso oneone ofof thethe mainmain processprocess parametersparameters inin industrialindustrial productionproduction process process manymany propertiesproperties ofof objectsobjects andand featuresfeatures areare relatedrelated toto temperature temperature a a lotlot ofof importantimportant processprocess cancan onlyonly bebe effectiveeffective inin a a certaincertain temperaturetemperature range range thus thus accurateaccurate measurementmeasurement andand reliablereliable controlcontrol ofof temperature temperature inin thethe industrialindustrial productionproduction andand scientificscientific researchresearch hashas thethe veryvery vitalvital significance significance ThisThis paperpaper expoundsexpounds thethe conceptconcept ofof processprocess controlcontrol system system introducedintroduced a a digitaldigital sensorsensor DS18B20DS18B20 andand singlesingle chipchip microcomputermicrocomputer basedbased STC89C52STC89C52 simplesimple temperaturetemperature controlcontrol system system electricelectric kettlekettle forfor controlledcontrolled object object andand throughthrough thethe experimentexperiment thethe methodmethod toto establishestablish thethe mathematicalmathematical modelmodel ofof temperaturetemperature controlcontrol system system usingusing PIDPID algorithmalgorithm toto thethe designdesign ofof thethe system system toto achieveachieve thethe betterbetter control control ThroughThrough DS18B20 DS18B20 thethe temperaturetemperature controlcontrol ofof thethe electricelectric heatheat cupcup isis achieved achieved ThroughThrough thethe PL2303PL2303 downloaddownload port port thethe communicationcommunication betweenbetween thethe singlesingle machinemachine andand thethe aboveabove machinemachine isis achieved achieved TheThe experimentexperiment showsshows thatthat thethe systemsystem cancan controlcontrol thethe temperature temperature andand hashas certaincertain controlcontrol accuracy accuracy TheThe systemsystem isis simplesimple andand easyeasy toto connect connect whichwhich cancan bebe usedused forfor simplesimple temperaturetemperature control control KeyKey wordswords single chip microcomputer the temperature sensor Liquid crystal display PID algorithm 目录 一一 设计任务与要求设计任务与要求 4 1 基本要求基本要求 4 二二 方案论证方案论证 4 三三 系统设计系统设计 5 1 硬件设计硬件设计 5 2 软件设计软件设计 10 1 算法 算法 10 2 控制系统模型分析 控制系统模型分析 11 仿真结果图仿真结果图 12 四 实验结果四 实验结果 12 五 结论五 结论 13 六 心得体会六 心得体会 13 附录附录 14 参参 考考 文文 献献 24 给定值给定值 一一 设计任务与要求设计任务与要求 1 基本要求基本要求 1L 水由 1kW 的电路加热 要求水温可以在一定范围内由人工设定 并能在环境温度 变化时实现自动调整 以保持在设定的温度 2 主要性能指标 1 温度设定范围 10 100 最小分辨率为 1 2 控制精度 温度控制的稳态误差 0 2 3 能够实时显示当前水温 4 具有通信能力 可通过 RS 232 串口输出当前温度值至上位机 5 采用适当的控制方法 当设定温度或环境温度突变时减小系统的 调节时间和超 调量 二二 方案论证方案论证 由于水温控制系统的控制对象具有热储存能力大 惯性也较大的特点 水在容器内 的流动或热量传递都存在一定的阻力 因而可以将被控对象归于具有纯滞后的一阶惯性 环节 该系统可以采用以下几种控制方案 1 输出开关量控制 对于惯性较大的过程可简单地采用输出开关量控制的方法 这种方法通过比较给定 值与被控参数来控制输出的状态 通过控制加热回路的晶闸管的导通或关断来控制加热 时间 控制过程简单易行 但容易引起反馈回路产生振荡 因此这种控制方案一般在大 惯性系统对控制精度和动态特性要求不高的情况下采用 2 PID 控制 设计 PID 控制算法 常规 PID 微分先行 PID 中间反馈 PID 等 对给定值与被控参 数的偏差进行 PID 运算 输出控制量来控制加热回路 三三 系统设计系统设计 1 硬件设计硬件设计 控制系统框图 控制器控制器电炉电炉驱动电路驱动电路 温度传感器温度传感器 D A A D 水温水温 图图 3 13 1 水温控制系统结构图 系统硬件总体设计框图 4x4 键盘键盘 AT89C51 驱动电路驱动电路电炉电炉D A温度传感器温度传感器A D 图3 2 水温控制系统硬件总体设计框图 单元电路设计 单片机最小系统 XTAL2 18 XTAL1 19 ALE 30 EA 31 PSEN 29 RST 9 P0 0 AD0 39 P0 1 AD1 38 P0 2 AD2 37 P0 3 AD3 36 P0 4 AD4 35 P0 5 AD5 34 P0 6 AD6 33 P0 7 AD7 32 P1 0 1 P1 1 2 P1 2 3 P1 3 4 P1 4 5 P1 5 6 P1 6 7 P1 7 8 P3 0 RXD 10 P3 1 TXD 11 P3 2 INT0 12 P3 3 INT1 13 P3 4 T0 14 P3 7 RD 17 P3 6 WR 16 P3 5 T1 15 P2 7 A15 28 P2 0 A8 21 P2 1 A9 22 P2 2 A10 23 P2 3 A11 24 P2 4 A12 25 P2 5 A13 26 P2 6 A14 27 U1 AT89C51 C1 22PF C2 22PF X1 12MHz R1 10k C3 10uF 温度传感器信号调理及 A D 转换电路 LCD1602 液晶显示器液晶显示器 VOUT 2 V 1 GND 3 U1 AD581 15v 10V R1 33k VR1 5k 3 2 6 74 1 8 U2 OP07 15V RV1 20K R2 30k 15V 2 1MSB 21 ADD B 24 ADD A 25 ADD C 23 VREF 12 VREF 16 IN3 1 IN4 2 IN5 3 IN6 4 IN7 5 START 6 2 5 8 EOC 7 OUTPUT ENABLE 9 CLOCK 10 VCC 11 2 2 20 GND 13 2 7 14 2 6 15 2 8LSB 17 2 4 18 2 3 19 IN2 28 IN1 27 IN0 26 ALE 22 U3 ADC0809 R3 81k VR2 5K P1 0 P1 1 P1 2 P1 3 P3 0 P3 1 P3 2 P3 3 P3 4 P3 5 P3 6 P3 7 P1 4 P1 5 P1 6 P1 7 键盘接口电路 2 3 4 5 6 7 8 9 1 RP2 RESPACK 8 P2 7 CDEF P2 6 89AB P2 5 4567 P2 4 0123 P2 3 P2 2 P2 1 P2 0 LCD1602 液晶显示电路 RS RW EN D7 14 D6 13 D5 12 D4 11 D3 10 D2 9 D1 8 D0 7 E 6 RW 5 RS 4 VSS 1 VDD 2 VEE 3 LCD1 LM016L 2 3 4 5 6 7 8 9 1 RP1 220 RV1 10K P0 0 P0 1 P0 2 P0 3 P0 4 P0 5 P0 6 P0 7 驱动电路 12 U1 A 7407 1 2 6 4 U2 MOC3021 R1 250 R2 27 Q1 MMBTA93 RL1 RTE24005F D1 DIODE R3 10k 220v 串口通信电路 U1 MAX232E C1 C1 C2 C2 T1IN T2IN R1OUT R2OUT GND R2IN R1IN T2OUT T1OUT V V VCCJ2 DSUB9F C1 1uF VCC 5V C2 1uF C3 1uF VCC 5V 图图 3 33 3 水温控制系统主程序流程水温控制系统主程序流程 Y 开始开始 系统初始化系统初始化 是否有键入是否有键入 输入键值 程序跳输入键值 程序跳 转到相应子程序转到相应子程序 选择控制算选择控制算 法子程序法子程序 设定温度子设定温度子 程序程序 运行子程序运行子程序通信子程序通信子程序 N 图图 3 43 4 水温控制系统水温控制系统运行子程序流程图运行子程序流程图 2 软件设计软件设计 1 算法 算法 一个受控系统的被控过程一般是一个衰减振荡的过渡过程 该过程可用曲线描述如 下 Y 开始开始 系统初始化系统初始化 是否有键入是否有键入 输入键值 程序跳输入键值 程序跳 转到相应子程序转到相应子程序 选择控制算选择控制算 法子程序法子程序 设定温度子设定温度子 程序程序 运行子程序运行子程序通信子程序通信子程序 N 图 3 5 衰减振荡曲线 PID 控制系统原理框图如下图所示 R S C S 图 3 6 PID 控制系统原理框图 系统由 PID 控制器和被控对象组成 PID 控制器是一种线性控制器 它根据给定值 r t 与实际输出值 c t 构成控制偏差 e t r t c t 将偏差的比例 P 积分 I 和微分 D 通过线性组合构成控制量 对被控对象进 行控制 故称PID控制器 PID 控制算法设计 其控制规律表达式为 3 1 t D I P dt tde Tdtte T teKtu 0 1 由上式可得 PID 控制器的传递函数为 3 2 sTK sT K KsD DP I P P 1 其中 Kp为比例增益 Ti为积分时间 Td为微分时间 2 控制系统模型分析 控制系统模型分析 建立微分方程 M C dT dt W0 k t M C T s T0 将上式经拉普拉斯变换得 在假设室温为 0 的条件下 将上式经拉普拉斯变换推导出被控对象 即水温 的数学模 型为 G s T s K s W0 MC s MC W0 MC s 1 3 3 各项参数为 W0 900 瓦 M 1 5 kg C 4200 J kg C 0 001 所以 G s 0 14 1000s 1 PID 控制器的传递函数为 1 1 1 G s T T sT sT ks i d d i p 图 3 1 1 衰减震荡曲线 GC S 电热杯 采用试凑法进行参数整定 控制器的参数按先比例 再积分 后微分的顺序进行 步骤 如下 令 PID 调节器的 Ti Td 0 使其成为纯比例调节器 比例度按经验数据设置 整定纯比例控制系统的比例度 加入积分作用 在加积分作用之前 应将比例度加大 为原来的 1 2 倍 将积分时间 IT 由大到小调整 加入微分作用 这时可将比例度调到 原来的数值或者更小一些 再将微分时间由小到达调整 直到过渡过程曲线达到满意为 止 通过试凑法得到 PID 参数为 Kp 20000 Ti 30000 Td 5000 MATLAB 仿真结果 图 3 7 PID 控制框图 图 3 8 仿真结果图 四 实验结果四 实验结果 实验中烧水高度为 6 3cm 设定温度为 83 度 PID 参数调节结果是 P 70 I 4 D 0 超调量为 3 5 上升时间为 626s 稳态误差 2 扰动加水 0 5 cm 加水后温度降落 9 87 恢复时间 200S 电热水杯温度上升曲线如下图 五 结论五 结论 本系统以 AT89C51 单片机为控制核心 利用 DS18B20 采集温度并配合 PID 控制算 法提高了水温的控制精度 使用 PID 控制算法和移相触发可控硅调节方式实施自动控制 系统 具有控制参数精度高 反映速度快和稳定性好的特点 六 心得体会六 心得体会 在拿到一个课题时首先要做的事就是对课题的任务 要求和条件进行仔细的分析和 研究 找出关键问题 根据关键问题提出实现的原理和方法 并画出原理框图 提出原理方案是一个关系到设计全局的问题 应广泛收集与查阅有关资料 广开思 路 利用已有的各种理论知识 提出尽可能多的方案 以便做出更合理的选择 所提出 的方案中 对关键部分的可行性 一般应通过实验加以确认 根据整个课题的技术要求 明确该功能框对单元电路的技术要求 必要时应详细拟定单元电路的性能指标 然后进 行单元电路结构形式的选择或设计 但满足功能的单元电路可能不止一个 因此必须进 行分析比较 择优选择 我通过实验课的综合练习 课程设计的实际操作 将课堂理论学习贯穿其中 全面 系统的把单片机课程的知识联系在一起 做到融会贯通 使我真正感受到理论应用于实 践的乐趣 这次设计是一次锻炼的好机会 使我在学习和巩固新 老知识的同时 训练 了自己综合运用知识的能力 分析解决问题的能力 同时也提高了自己的工程实践能力 在设计过程中 我与同学们一同学习 一同讨论 大家集思广益 发扬了团队协作精神 在课程设计过程中 我发现了自己的不足 今后应加强学习 并且加强理论与实践的相 结合 把所学的知识应用于实际当中 附录 temp c include STC12C5A60S2 h include include void Delay1us unsigned int y for y y 0 y nop nop unsigned char Ds18b20Init unsigned int i DSPORT 0 Delay1us 600 DSPORT 1 i 0 while DSPORT i if i 5000 return 0 return 1 void Ds18b20WriteByte unsigned char dat unsigned int j for j 0 j 1 unsigned char Ds18b20ReadByte unsigned char byte bi unsigned int j for j 8 j 0 j DSPORT 0 Delay1us 1 DSPORT 1 Delay1us 6 bi DSPORT byte byte 1 bi 7 Delay1us 48 return byte void Ds18b20ChangTemp Ds18b20Init Delay1ms 1 Ds18b20WriteByte 0 xcc Ds18b20WriteByte 0 x44 Delay1ms 100 void Ds18b20ReadTempCom Ds18b20Init Delay1ms 10 Ds18b20WriteByte 0 xcc Ds18b20WriteByte 0 xbe int Ds18b20ReadTemp int temp 0 unsigned char tmh tml Ds18b20ChangTemp Ds18b20ReadTempCom tml Ds18b20ReadByte tmh Ds18b20ReadByte temp tmh temp 8 temp tml return temp Main c include STC12C5A60S2 h include include include void Delay1ms unsigned int y for y y 0 y unsigned char i j nop nop i 12 j 168 do while j while i float Temp Change int temp unsigned char datas 0 0 0 0 0 0 0 0 float tp if temp 0 temp temp 1 temp temp tp temp temp tp 0 0625 100 0 5 else tp temp temp tp 0 0625 100 0 5 tp tp 0 0625 100 0 5 DisplayWD 2 8 temp return tp void main LcdInit Ds18b20Init DisplayChar 0 1 Delay1ms 1 DisplayChar 1 1 zhaoyang Delay1ms 1 DisplayChar 0 5 JD Delay1ms 1 DisplayChar 1 5 WD Delay1ms 1 while 1 Delay1ms 1 LCD dis data4 1 8 Ds18b20ReadTemp Delay1ms 1 Temp Change Ds18b20ReadTemp kd c include STC12C5A60S2 h include include void LcdWriteCom uchar CMD uchar Attribc if Attribc WaitForEnable LCD1602 RS 0 LCD1602 RW 0 nop LCD1602 DATAPINS CMD nop LCD1602 E 1 nop nop LCD1602 E 0 void LcdWriteData uchar dataW WaitForEnable LCD1602 RS 1 LCD1602 RW 0 nop LCD1602 DATAPINS dataW nop LCD1602 E 1 nop nop LCD1602 E 0 void LcdInit LcdWriteCom 0 x32 1 LcdWriteCom 0 x38 1 LcdWriteCom 0 x08 1 LcdWriteCom 0 x01 1 LcdWriteCom 0 x06 1 LcdWriteCom 0 x0c 1 Delay1ms 30 DisplayChar 0 0 Welcome To SUST Delay1ms 1 DisplayChar 1 0 ML 2016 12 27 Delay1ms 1000 LcdWriteCom 0 x01 1 Delay1ms 1 DisplayChar 0 0 Made In 2A314 Delay1ms 1 DisplayChar 1 0 ML 2016 12 27 Delay1ms 2000 LcdWriteCom 0 x01 1 Delay1ms 300 void WaitForEnable void LCD1602 DATAPINS 0 xff LCD1602 RS 0 LCD1602 RW 1 nop LCD1602 E 1 nop nop while LCD1602 DATAPINS LCD1602 E 0 void Delays uchar i while i void DisplayChar uchar Y uchar X uchar s Y X if Y X 0 xC0 else X 0 x80 while s 0 LcdWriteCom X 0 LcdWriteData s Delays 1 s void LCD dis data5 uchar x uchar y uint data5 uchar pos i 0 str 6 switch x 2 case 1 pos 0 x80 y break case 0 pos 0 xc0 y break LcdWriteCom pos 0 str 0 data5 10000 10 0 x30 str 1 data5 1000 10 0 x30 str 2 data5 100 10 0 x30 str 3 data5 10 10 0 x30 str 4 data5 10 0 x30 str 5 0 while

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论