›› 2015, Vol. 28 ›› Issue (2): 150-.

• 论文 • 上一篇    下一篇

基于LabWindows/CVI的Modbus通信实现

杨秋虎   

  1. (昆明船舶设备试验研究中心 第5研究室,云南 昆明 650051)
  • 出版日期:2015-02-15 发布日期:2015-02-16
  • 作者简介:杨秋虎(1985—),男,硕士,工程师。研究方向:嵌入式系统与虚拟仪器。E-mail:yangqiuhu@126.com

Design of Modbus Communication Based on LabWindows/CVI

YANG Qiuhu   

  1. (Fifth Research Laboratory,Kunming Shipbuilding Equipment Research Center,Kunming 650051,China)
  • Online:2015-02-15 Published:2015-02-16

摘要:

针对Modbus RTU在现场总线通信中的应用,以上位机作为通信主站点时,由于采用主/从式应答方式,所以实时通信与界面响应会发生冲突。文中采用LabWindows/CVI多线程技术,对实时性要求高的任务放入次线程中执行,并根据任务需求合理分配各线程的优先级,可有效地解决该问题。通过编写自动卷烟机的Modbus主站通信程序,经试验验证,文中方法能顺利完成与网络中多个从站通信,并且及时响应人机交互界面的操作。

关键词: Modbus RTU, 多线程, 数据保护

Abstract:

Modbus RTU has extensive application in field bus communication.When PC is working as a master,the real-time communication and the interface response of PC have a conflict because of the master/slave response mode adopted by Modbus.To solve the conflict,the multithreading technology of LabWindows/CVI is applied.Tasks with high real-time demanding are endowed with corresponding priority and arranged into sub-threads.The Modbus communication program of automatic cigarette-wrapping machine is composed by multithreading.The result of the experiment shows that the master has a fast response towards the manipulation through human-computer interaction and achieves the communication between master and slaves without conflict.

Key words: Modbus RTU;multithreading;data protection

中图分类号: 

  • TN915.04