没有合适的资源?快使用搜索试试~ 我知道了~
CompactRIO开发指南
5星 · 超过95%的资源 需积分: 9 19 下载量 152 浏览量
2010-05-13
07:49:33
上传
评论
收藏 17.37MB PDF 举报
温馨提示
试读
257页
非常有用的LV开发电子文档,学完后,结合LV的经验,可以顺利开发一个完整规范的CompactRIO工程.
资源推荐
资源详情
资源评论
CompactRIO Developers Guide
Recommended LabVIEW Architectures and Development Practices
for Machine Control Applications
This document provides an overview of recommended architectures and development practices when building machine
control applications using NI CompactRIO controllers and NI touch panel computers.
The examples and architectures are built using NI LabVIEW versions 8.6 and 2009.
December 2009
ii
CONTENTS
CHAPTER 1
Overview and Background .......................................................................................................1
Developers Guide Overview .........................................................................................................1
Terminology .....................................................................................................................................1
Machine Control Architecture Overview ...................................................................................2
Control SystemConfigurations .......................................................................................................2
Control System Architectural Block Diagrams .................................................................................3
Introduction to CompactRIO .........................................................................................................5
Real-Time Controller ........................................................................................................................5
Reconfigurable FPGA Chassis .........................................................................................................5
Industrial I/O Modules .....................................................................................................................6
CompactRIO Specifications ............................................................................................................6
CHAPTER 2
Basic Architecture for Control ..................................................................................................7
Basic Controller Architecture Background.................................................................................7
Initialization Routine ......................................................................................................................7
Control Routine .............................................................................................................................8
Shutdown Routine .......................................................................................................................9
Basic Controller Architecture Example in LabVIEW .................................................................9
State-Based Designs ....................................................................................................................14
State Machine Overview ...............................................................................................................14
Example Scenario of Developing with State Machines .................................................................14
State Machine Example in LabVIEW .............................................................................................15
Introduction to Statecharts ...........................................................................................................18
LabVIEW Statechart Module Tutorial ..........................................................................................20
Statechart Example in LabVIEW ..................................................................................................24
Step 1. Design the Caller VI ...........................................................................................................26
Step 2. Define the Inputs, Outputs, and Triggers ..........................................................................27
Step 3. Develop a Statechart Diagram ..........................................................................................27
Step 4. Place the Statechart in the Caller VI ..................................................................................27
iii
Getting Started – Modifying an Example ................................................................................30
Step 1. Modify the IO Library .......................................................................................................30
Step 2. Modify the Shutdown Routine ..........................................................................................31
Step 3. Modify Task 1 to Map the I/O ...........................................................................................31
Step 4. Modify/Rewrite the Statechart ..........................................................................................31
CHAPTER 3
Software Techniques for Scalable Systems .....................................................................32
Reusable Functions .......................................................................................................................32
Building Reusable Code in LabVIEW .........................................................................................32
Example of Building Reusable Code in LabVIEW ..........................................................................33
Other Reusable Code in LabVIEW ..............................................................................................35
IEC 61131 Function Blocks ...........................................................................................................35
Multiple Tasks (Multiple Loops) ..................................................................................................37
Setting Task Priority and Synchronizing Tasks ................................................................................37
Passing Data between Tasks .........................................................................................................38
Triggering Tasks .............................................................................................................................40
Command-Based Architecture for Multiloop Systems ..........................................................40
Shared Variables for Commands ..................................................................................................40
Numeric Commands .....................................................................................................................41
Example of Using Shared Variables to Trigger a Parallel Loop .......................................................42
Adding Data to the I/O Scan .......................................................................................................44
Add a Custom I/O Scan Task (Driver Loop) ....................................................................................44
Priority and Timing ........................................................................................................................44
Adding Entries to the Memory Table for Custom I/O ....................................................................45
Add the Custom I/O Scan Logic ....................................................................................................45
Programmatic I/O Access .............................................................................................................46
Reading and Writing I/O ................................................................................................................46
Configuring I/O .............................................................................................................................48
Discovering I/O in a Deployed System ......................................................................................48
Data Logging ..................................................................................................................................50
Onboard Real-Time Memory Data Logging to a TDMS File .................................................51
Initializing the File ..........................................................................................................................51
Writing the Data to File .................................................................................................................52
Reading the Data ..........................................................................................................................52
Dynamically Creating New Files ....................................................................................................53
iv
Onboard Real-Time Memory Data Logging to an ASCII File ................................................53
Initializing the File ..........................................................................................................................53
Writing the Data to File .................................................................................................................54
Reading and Formatting the Data ..................................................................................................54
Dynamically Creating New Files ....................................................................................................55
Integrating Data-Logging Code with Control Architecture ...................................................56
Retrieving the Logged Data ..........................................................................................................57
Errors and Faults ............................................................................................................................58
The Fault Engine ...........................................................................................................................58
Example Code with Fault-Handling Loop ......................................................................................59
Real-Time Watchdog ......................................................................................................................59
Example Code with Hardware Watchdog Enabled ........................................................................61
CHAPTER 4
Communications from the CompactRIO System ..................................................................... 62
Communications Overview .........................................................................................................62
Command or Message-Based Communication ............................................................................62
Process Data Communication .......................................................................................................63
Streaming/Buffered Communication .............................................................................................63
Communication Using Network-Published Shared Variables ............................................64
Network-Published Shared Variable Background ...................................................................64
Network Variable Nodes ................................................................................................................64
Shared Variable Engine ..................................................................................................................64
Publish-Subscribe Protocol (PSP) ..................................................................................................65
Network-Published Shared Variable Features ................................................................................65
Hosting and Monitoring Network-Published Shared Variables ......................................................68
Using Network-Published Variables to Share Process Data .................................................69
Using Network-Published Variables to Send Commands .....................................................71
Example of Command-Based Architecture Using Network-Published Shared Variables ............... 76
Advanced Command-Based Architectures ....................................................................................79
Important Considerations When Using Network Variables for Commands ...................................83
Raw Ethernet (TCP/UDP) .............................................................................................................84
Building Your Own Communications Protocol ........................................................................84
Example of a Custom Communications Protocol ...................................................................85
Simple Messaging (STM) Protocol – A LabVIEW Implementation ................................................85
Serial Communication from CompactRIO ..............................................................................88
RS232 Technical Introduction .......................................................................................................88
v
Serial Communications from LabVIEW .....................................................................................89
Instrument Driver Network ...........................................................................................................91
Example of Serial Communication from LabVIEW ........................................................................92
Communicating with PLCs and Other Industrial Networked Devices ...........................94
Industrial Communications Protocols .......................................................................................94
Modbus Communications .............................................................................................................95
Modbus Example ..........................................................................................................................97
EtherNet/IP ...................................................................................................................................98
OPC ....................................................................................................................................................98
Publishing Data from a CompactRIO System over OPC ...............................................................99
CHAPTER 5
Adding I/O to the CompactRIO System .......................................................................... 102
Adding I/O to CompactRIO ...................................................................................................... 102
Ethernet I/O .................................................................................................................................... 102
Step 1. Configure the Expansion System .................................................................................... 102
Step 2. Add the I/O into the Scan of the Main Controller ...........................................................104
Step 3. Copy the Data into the Memory Table ............................................................................ 104
Deterministic Ethernet I/O ..........................................................................................................105
Overview of the NI 9144 – Deterministic Ethernet Chassis ........................................................ 105
Step 1. Configure the Deterministic Expansion Chassis .............................................................106
Step 2. Add Deterministic I/O to the IO Scan ............................................................................107
Step 3. Add FPGA Intelligence to the Deterministic Expansion Chassis .................................... 108
Machine Vision/Inspection ..........................................................................................................111
Machine Vision System Architecture ............................................................................................111
Lighting and Optics ..................................................................................................................... 112
Software Options ........................................................................................................................ 113
Machine Vision/Control System Interface ................................................................................... 114
Machine Vision Using LabVIEW Real-Time ............................................................................ 114
Step 1. Add an NI Smart Camera to the LabVIEW Project .......................................................... 114
Step 2. Use LabVIEW to Program the NI Smart Camera ............................................................ 115
Step 3. Communicate with the CompactRIO System ................................................................ 116
Machine Vision Using Vision Builder AI................................................................................... 117
Step 1. Configure an NI Smart Camera with Vision Builder AI .................................................... 117
Step 2. Configure the Inspection ................................................................................................ 118
Step 3. Communicate with the CompactRIO System ................................................................ 119
Motion Control ..............................................................................................................................120
The Motion Controller .................................................................................................................121
LabVIEW NI SoftMotion and NI 951x Drive Interface Modules ..................................................121
剩余256页未读,继续阅读
资源评论
- Vincentcncn2012-06-14还不错,英文版的 ni的网站上应该也有吧,这么简单地找到也不错啊,要是能有更多的模块介绍就更好了
- ufo1582012-11-09网站上有中文版..
- forpeople2012-08-18好倒是好 可惜是英文版啊
changhej
- 粉丝: 1
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功