您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > Modbus串口通信功能设计
I摘要在机械、化工、纺织等行业,随着生产规模的不断扩大,以及对生产过程集中监控的迫切要求,现场总线技术应运而生,并成为了当今测控领域研究的热点之一。Modbus协议作为现场总线的一种,以其开发成本低,简单易用等诸多优点己被工业领域广泛接受。信号测量作为工业中重要的测量参数之一,本课题选择了信号测量作为测量的对象,并设计了基于Modbus协议的信号测量测控节点。本设计采用TC1047A传感器采集现场信号测量,由DSP320IF2407单片机进行AD转换和Modbus协议通讯。通讯的物理层采用RS485接口,并增加了光电隔离、抗雷击和短路保护等功能。最后实现了单个节点和PC机的Modbus协议通讯,并通过控制蜂鸣器和继电器来模拟工业现场控制。本文分别从硬件和软件上阐述了该信号测量测控节点的实现方法。关键词信号测量测控Modbus协议RS485DSP320IF2407IIABSTRACTWiththecontinuousexpansionofproductionscale,andtheurgentrequirementsincentralizedmonitoringoftheproductionprocessinmechanical,chemical,textileandotherindustries.Fieldbustechnologycameintobeing,andbecomeoneofhotresearchfieldofmeasurementandcontroltoday.Asoneoffieldbus,Modbusprotocolhavebeenwidelyacceptedbecauseoflowdevelopmentcost,easytouseandmanyotheradvantagesinindustry.Thetemperatureisoneoftheimportantparametersmeasuredinindustry,soithasbeenchosenameasurementoftheobject,temperaturemeasurementandcontrolnodeshasbeendesignedbasedonModbusprotocol.ThisdesignusesTC1047Asensortocollecton-sitetemperature,ADconversionandModbusprotocolcommunicationscanbedonebyDSP320IF2407microcontroller.ThephysicallayerofcommunicationadoptsRS485interface,andhaveopticalisolation,anti-lightningandshortcircuitprotectioninaddition.Finally,achievedtheModbusprotocolcommunicationbetweenasinglenodeandthePC,andsimulateindustrialcontrolbycontrollingthebuzzer,andrelay.Thispaperdescribestheimplementationoftemperaturecontrolnodefromhardwareandsoftware.KEYWORDSTemperatureMonitoringModbusprotocolRS485STC12C5A60目录中文摘要......................................................................Ⅰ英文摘要......................................................................Ⅱ1绪论........................................................................12设计方案...................................................................32.1方案概述..............................................................32.2方案论证..............................................................32.2.1通讯可靠性..........................................................42.2.2信号测量检测电路选择..............................................42.2.3系统电源稳定性......................................................53硬件电路设计..............................................................63.1最小系统电路.........................................................63.2信号测量检测电路....................................................63.3电源电路..............................................................73.4报警控制电路.........................................................93.5通讯电路.............................................................103.6显示电路.............................................................133.7硬件抗干扰的设计...................................................144MODBUS协议概述与应用.................................................164.1MODBUS协议概述.....................................................164.1.1总体描述...........................................................164.1.2MODBUS数据单元...................................................174.1.3MODBUS通信原理...................................................174.2M两种传输方式......................................................194.2.1ASCll模式.........................................................204.2.2RTU模式...........................................................204.3MODBUS消息帧.......................................................214.3.1ASCll帧...........................................................214.3.2RTU帧..............................................................214.3.3字符的连续传输....................................................224.5错误检测方法........................................................234.5.1LRC检测...........................................................244.5.2CRC检测...........................................................245软件设计..................................................................255.1AD采集程序设计.....................................................265.2串口中断处理程序设计..............................................275.3MODBUS协议程序设计................................................295.4CRC计算及校验程序设计............................................296总结.......................................................................33致谢...........................................................................34参考文献......................................................................34附录1.......................................................................36附录2.......................................................................3711绪论随着计算机技术和网络技术的发展,工业参数的数字采集促进了现场总线技术的发展,目前现场总线已经从当初的4-20mA电流信号升级为数字信号,发展成为全数字通讯,解决了现场信号远距离高速传送的问题,而且提高了抗干扰性能,增加了系统配置的灵活性,节省了硬件投资,是未来生产自动化和过程控制的发展方向。目前,较有影响的总线有:Modbus,CAN,LonWorks,Profibus等。采用RS485标准总线技术对现场数据进行采集、管理,相对于CAN,LonWorks,Profibus等现场总线系统而言,具有结构简易、成本低廉、硬软件支持丰富、安装方便,且与传统的DCS兼容,与现场仪表接口简单,系统实施容易等特点,因而RS485总线系统在一定时间内仍是中小控制系统的主要形式。信号测量测控模块作为一种重要的设备,在诸多工业生产过程中得到了广泛应用。自70年代以来,由于工业过程控制的需要,特别是微电子技术和计算机技术的迅猛发展,国外信号测量测控发展迅速,并在智能化、自适应等方面取得显著成果。在这方面,以口本、美国、德国、瑞典等国的技术领先,生产出了很多商品化的、性能优异的信号测量测控器及仪器仪表,并在各行业广泛应用。目前,国外信号测量测控系统及仪表正朝着高精度、智能化、小型化等方面快速发展。基于单片机的Modbus协议产品一般由单片机芯片为核心和外围辅助逻辑元器件组成,它
本文标题:Modbus串口通信功能设计
链接地址:https://www.777doc.com/doc-2888736 .html