1、南京航空航天大学硕士学位论文基于LabVIEW的实时控制与仿真技术应用研究姓名:王欢申请学位级别:硕士专业:航空宇航推进理论与工程指导教师:张天宏20081201南京航空航天大学硕士学位论文 I 摘 要 LabVIEW 作为一种功能强大的虚拟仪器开发环境得到了越来越广泛的应用。本文以增强系统实时性及提高开发效率为目的,开展了基于 LabVIEW 的实时控制与仿真技术研究,并进行了实验验证。在实时仿真方面,提出了一种将 Matlab 和虚拟仪器结合起来开发实时仿真系统的方法。利用 Matlab/Simulink 的实时代码生成工具箱(Real-time Workshop,RTW)将 Simuli
2、nk 模型转化为 C 代码,再通过动态链接库(Dynamic Link Library,DLL)技术将 C 代码导入 LabVIEW 虚拟仪器实时平台,实现实时仿真系统的快速开发。经电机模型仿真实例验证,该方法既可以充分利用 Simulink 的建模优势,又可以发挥虚拟仪器技术在灵活的实时软硬件平台和丰富的人机界面设计方面的优点,相对于传统的基于 C 语言开发实时仿真系统,该方法具有方便快捷的特点。在实时控制方面,分析了 Windows 环境下实时控制的几种方法,重点研究了基于 RTX 的实时控制系统。构建了一种基于 RTX 和 LabVIEW 的实时控制系统,利用 RTX 扩展 Window
3、s实时性,利用 LabVIEW 开发人机界面,RTX 的实时任务和 LabVIEW 应用程序之间通过共享内存及 DLL 技术关联。串口通信、数据采集及 PID 控制实例验证了系统的实时性。最后分析了实时控制与仿真系统中的通信问题,介绍了 LabVIEW 的几种网络通信协议。设计了基于 TCP/IP 的主从式应用系统,并对其实时性进行了验证。结果表明,该网络通信方式可以满足局域网环境下系统的实时性和稳定性要求。研究表明,将 LabVIEW 引入实时控制与仿真领域是可行的,不仅可以实现系统实时性,还提高了开发效率。关键词:关键词:虚拟仪器,LabVIEW,实时仿真,实时控制,Matlab/Simu
4、link/RTW,RTX,网络通信 基于 LabVIEW 的实时控制与仿真技术应用研究 II Abstract As a powerful Virtual Instrument development environment,LabVIEW has been widely used in industry.In order to enhance real-time performance of the system and improve the development efficiency,the technology of real-time control and simulation
5、based on LabVIEW is studied,and verified by some tests.In the respect of real-time simulation,an effective method is proposed,which combines the Matlab/Simulink and Virtual Instrument for the development of real-time simulation system.The simulink blocks are converted into C code automatically by Re
6、al-time Workshop(RTW),which is a toolbox of Matlab,the C code is imported into LabVIEW virtual instrumental real-time platform by Dynamic Link Library(DLL).The real-time simulation system can be developed rapidly in LabVIEW.A motor example has verified that this method can combine the advantages of
7、Simulink modelisation and Virtual Instruments strongpoint of flexible real-time platforms and abundant resource of designing human-machine interface.Comparing with the conventional C-based method of developing the real-time simulation system,this method is convenient and rapid.In the respect of real
8、-time control,the methods of how the real-time control carry out in Windows are analyzed,and the real-time control based on RTX is mainly researched,a real-time control system based on LabVIEW and RTX is designed,which uses RTX to extend Windows real-time performance,uses LabVIEW to design human-mac
9、hine interface,uses shared memory and DLL to associate the RTSS and LabVIEW application programme.The serial port communication,data sampling and PID control examples have verified that the system has a good real-time performance.Lastly,the network problems in real-time simulation and control are re
10、searched,and some LabVIEW communication protocols are introduced.A C/S application system based on TCP/IP protocols is designed,and the system performance of real-time has been tested.The result indicates that this communication mode is able to satisfy the system real-time performance and stability
11、in local area network(LAN).The research results illustrate that it is feasible to apply LabVIEW to real-time simulation and control field,it can not only realize the system real-time performance,but also improve the development efficiency.Keywords:Virtual Instrument,LabVIEW,real-time control,real-ti
12、me simulation,Matlab/Simulink/RTW,RTX,network 南京航空航天大学硕士学位论文 V 图表清单 图 2.1 LabVIEW 调用 Simulink 模型的用户界面.7 图 2.2 实时仿真系统开发流程.8 图 2.3 RTW 工作流程.11 图 2.4 RTW 系统目标文件配置截图.12 图 2.5 RTW 应用程序流程图.13 图 2.6 定时循环结构.15 图 2.7 CLF 节点位置.16 图 2.8 CompactRIO 实物图.17 图 2.9 电机实时仿真系统结构.18 图 2.10 CompactRIO 软件平台构架.19 图 2.11 F
13、PGA VI 程序框图.20 图 2.12 电机实时仿真系统主机程序流程图.21 图 2.13 主机 VI 实时仿真部分程序框图.22 图 2.14 Simulink 中二阶伺服电机模型.22 图 2.15 电机模型在 CompactRIO 上仿真.23 图 2.16 电机模型在 Simulink 中仿真.23 图 3.1Windows XP 系统体系结构图.26 图 3.2 RTX 架构.30 图 3.3 基于 RTX 的实时控制系统结构.31 图 3.4 基于 RTX 和 LabVIEW 的实时控制系统总体方案图.32 图 3.5 向 COM1 添加 RTX 驱动支持.33 图 3.6 R
14、TX 在 VC6.0 下截图.34 图 3.7 共享内存使用流程图.36 图 3.8 串口通信系统主程序流程图.38 图 3.9 串口发送数据实时任务程序流程图.39 图 3.10 CLOCK_1 定时发送效果图.40 图 3.11 CLOCK_2 定时发送效果图.40 图 3.12 CLOCK_3 定时发送效果图.40 图 3.13 Windows 普通定时器定时发送效果图.41 图 3.14 PCI-1712 数据采集程序流程图.42 图 3.15 PCI-1712 数据采集实时任务程序流程图.43 图 3.16 PCI-1712 数据采集显示效果.44 图 3.17 PID 控制系统结构
15、图.45 图 3.18 二阶欠阻尼系统模拟电路.45 图 3.19 二阶欠阻尼系统辨识结果图.46 图 3.20 Kp=3.5 时系统响应效果图.47 图 3.21 Kp=3.2,Ki=0.02 时系统响应效果图.47 图 3.22 Kp=3.2,Ki=0.03,Kd=6 时系统响应效果图.48 基于 LabVIEW 的实时控制与仿真技术应用研究 VI 图 3.23 Kp=2.2,Ki=0.045,Kd=19 时系统响应效果图.48 图 4.1 TCP/IP 侦听 VI.54 图 4.2 双机 TCP 通信流程图.55 表 3.1 RTSS 与 Win32 的线程优先级对照表.31 表 3.2
16、 RTX 三种定时机制的定时精度.35 表 4.1 各种网络通信方式的用途和区别.52 表 4.2 TCP/IP 主从式分布式系统网络性能测试数据 1.56 表 4.3 TCP/IP 主从式分布式系统网络性能测试数据 2.57 承诺书 本人声明所呈交的硕士学位论文是本人在导师指导下进行的研究工作及取得的研究成果。除了文中特别加以标注和致谢的地方外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含为获得南京航空航天大学或其他教育机构的学位或证书而使用过的材料。本人授权南京航空航天大学可以将学位论文的全部或部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存、汇编学位论文。(保密的学位论文在解密后适用本承诺书)作者签名:日 期:南京航空航天大学硕士学位论文 1 第一章 绪论 1.1 研究背景及意义 近年来,实时系统在航空、航天和军事等领域得到了广泛应用 1,实时控制与仿真技术也得到了前所未有的关注。在实时仿真方面,怎样快速建立高置信度和逼真度的模型是仿真技术发展的一个重要研究课题。在实时控制方面,如何能够更及时地响应外部事件是控制技术研究的关键。控制系统的数字仿真根
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1