Vous êtes sur la page 1sur 58

Best Practices for Networking with NI LabVIEW

Developer Days 2009

Networking Basics
Application

Application

High-Level
Protocol

HTTP, FTP, NI-PSP

High-Level
Protocol

Transport

TCP, UDP

Transport

IP
Hardware

IP
Physical

Hardware

National Instruments
Customer Education

Todays Networking Topics


Data Transfer
Shared Variable
OPC
DSTP
Modbus
EPICS
CANopen
PROFIBUS
Ethernet/IP

LabVIEW
Intermediate II

Deterministic Data Transfer


Time-Triggered Variable
EtherCAT

Remote Procedure
Calls
VI Server
LabVIEW Web Services

Networked Object
Modules

Miscellaneous
Custom Protocols with DLLs
Remote Panels

ActiveX
.NET

Low Level
TCP

UDP

Bluetooth

Serial

IrDA

Benefits of Using Low-Level Networking


Custom communications design
Standards compliance
Target specific
Quality performance

Benefits of Using High-Level Networking


Simplifies the development process
Developers can easily understand code
Do not have to reinvent the wheel
Provides preexisting solutions to common problems

Reliability
Many have been used for years they are tried and true
Includes large development community and resources
online
5

Getting Started: How Do I Choose?


Identify the most important aspect of your application:

Clean, easy-to-read code


Performance requirements
Scalability
Standards compliance
Accessibility

Select a template based on potential to improve

Caution
Ways you can needlessly complicate your life:
Adapt a protocol for one purpose to suit another
Select an unnecessarily complex API

National Instruments
Customer Education

LabVIEW
Intermediate II

User Datagram Protocol (UDP)


Core protocol
Connectionless

Low Level UDP


Advantages
Asynchronous
Connectionless
Very high performance
Multicasting support

Disadvantages
Delivery not guaranteed
Requires a nontrivial amount of coding
Data must be flattened to string

Low Level UDP


How does it work?
Sender specifies destination IP and port or service
Receiver opens specified port and polls for data

10

UDP Demo

11

Low Level UDP


Use cases

Streaming time-valued data


Multicast applications
Fast transfers
Custom network protocols
LabVIEW to third-party communication
WAN communication

12

Requires Minimal Programming


High-Speed Data Streaming
Low Latency
High Scalability
Compatible with Thin Web Clients
Standard IT Friendly Protocols
Method Invocation
13

National Instruments
Customer Education

LabVIEW
Intermediate II

Transmission Control Protocol (TCP)


Core protocol
Connection-based

Low Level TCP


Advantages
Reliable
Standard networking protocol
Fast performance

Disadvantages
Requires a nontrivial amount of coding
Data must be flattened to strings before
sending
Additional code needed for multiple clients
15

Low Level TCP


How does it work?
Open/close connections to specific IP and port
Create/wait on listeners
Write and read

16

TCP Demo

17

Low Level TCP


Use Cases

Streaming data
Control, embedded applications
Custom protocol development
LabVIEW to third-party communication
WAN communication

18

Requires Minimal Programming


High-Speed Data Streaming
Low Latency
High Scalability
Compatible with Thin Web Clients
Standard IT Friendly Protocols
Method Invocation
19

TCP Simple TCP/IP Messaging Protocol


Model architecture built on TCP
Server and client share session data
Solution to low-level complexity

http://zone.ni.com/devzone/cda/tut/p/id/4095

20

TCP STM Protocol


Example of what is possible by building on
low-level protocols
Abstracts the TCP/IP layer
Improves productivity
Improves performance

21

Bluetooth
Mobile devices
Wireless

No network backbone

Low Level Bluetooth


Why use Bluetooth?

Current and future device support


No network backbone required
Device discovery
Wireless PAN
Many devices not in line of sight

LabVIEW to third-party communication

23

Low Level Bluetooth


LabVIEW implements the RFCOMM protocol
Virtual serial connection
Simple binary data transport between devices

24

Low Level Bluetooth


Similar palette to TCP

25

National Instruments
Customer Education

LabVIEW
Intermediate II

Network-Published Shared Variable


LabVIEW to LabVIEW
Standard
Scalability
High LabVIEW Integration
Abstracts communication

Shared Variable
LabVIEW structure abstracts communication from
diagram
Supports almost any LabVIEW data type
Any LabVIEW application on network can be a client
NI LabWindows/CVI and Measurement Studio applications
can also be clients

The mark LabWindows is used under a license from Microsoft Corporation. Windows
is a registered trademark of Microsoft Corporation in the United States and other
countries.

27

Shared Variable
Advantages
Abstracts communication code
Scalable
Multiple client support
Front panel binding
OPC server functionality
Integrates LabVIEW Real-Time and LabVIEW Datalogging
and Supervisory Control module features

Disadvantages
Proprietary transfer protocol
Not optimized for streaming
Slightly more overhead than TCP/UDP

28

Shared Variable
Problems solved
Overly complicated LabVIEW networking code
Network congestion

Use cases
Large distributed network system
Quick interfacing between LabVIEW applications on
a variety of targets

29

Network-Published Variable: What You Gain

30

Shared Variable Engine


Service that publishes shared variables
Tagsrv.exe is Windows OS startup service
Network variable engine component on real-time targets
Requires 32 MB of total system memory (64 MB recommended)
Windows Systems

LabVIEW Real-Time Targets

31

Shared Variable NI-PSP


Uses the NI publish and subscribe protocol
Decoupling of publisher and subscriber
SVE acts as broker

Uses TCP

Designed for efficient data transfer


Updates are packaged into one packet
Values change updates

32

Shared Variable

33

Shared Variable

Ethernet Network

34

Shared Variable Buffering


Configured in shared variable properties
Creates several buffers
Protects against fluctuations in device speed
Buffer

Buffer

Buffer

Writer

Reader
Published Location

35

Shared Variable Demo

36

Requires Minimal Programming


High-Speed Data Streaming
Low Latency
High Scalability
Compatible with Thin Web Clients
Standard IT Friendly Protocols
Method Invocation
37

Shared Variable LabVIEW Datalogging and Supervisory


Control Module
LabVIEW add-on for large and distributed applications
HMI/SCADA applications
High-channel-count test systems

Configuration based

Logging
Alarming
Security
Trending

Third-party I/O integration


OPC and Modbus

Power programming tools

Industrial graphics
38

Shared Variable LabVIEW Datalogging and Supervisory


Control Module

Use cases

High-channel-count systems
Long-term data logging
Need for alarming
Connectivity to third-party
OPC servers

Alarms and
Database Events

Windows PC

OPC I/O
Server

Ethernet

NI Compact FieldPoint PLC

39

Modbus I/O
Server

Modbus

National Instruments
Customer Education

LabVIEW
Intermediate II

VI Server
LabVIEW run-time control
High LabVIEW integration
Abstracts communication

VI Server
Programmatically change application settings
and the LabVIEW environment
Access properties/methods at run time
Class hierarchy
Platform independent

41

VI Server
Provides a back end for remote LabVIEW control
Use cases
Network with LabVIEW targets
RPC

Application synchronization

42

Web Services
High LabVIEW integration
Abstracts communication
Invoke VIs through the
Web

Web Services
Request
Standard http protocol
Firewall friendly
No RTE required
Multiple connections

Desktop or real time


Custom clients

Web Server

Response

Web Clients
44

Web Services
Client

LabVIEW

RESTful

Web Server

http

http

TCP

TCP

IP

IP

Hardware

Physical

Hardware

45

Web Services Demo

46

Web Services

HTML, JavaScript, AJAX

Adobe Flex

Adobe Flash

Microsoft Silverlight

Sun Microsystems JAVA

47

Web Services
Server-Side Scripting (ESP)
Session Data
Parse Form Data
Stream MIME Data Types

48

VI Deployed as Web Service


XML Data

Standard, Thin-Client Interface

Web Services
Flash Demo
49

Web Services
Advantages

Industry-standard http
Firewall friendly
RPC from anything that can make a Web request
Automatic multiple-connection handling
Real-time support

Disadvantages

Proprietary transfer protocol


Not optimized for streaming
Slightly more overhead than TCP/UDP

50

Web Services Application

Any Computer
Network
Web services in LabVIEW 8.6 will save us considerable time by making the process of
communicating with LabVIEW from standard, Web-based interfaces powerful and easy. End
users will now be able to monitor and control LabVIEW applications running on a
CompactRIO from custom thin clients we create using today's most common Web
technologies.
Matt Whitlock, Senior Project Manager, National Analytics
51

Requires Minimal Programming


High-Speed Data Streaming
Low Latency
High Scalability
Compatible with Thin Web Clients
Standard IT Friendly Protocols
Method Invocation
52

Summary
Use an array of LabVIEW technologies for
network communication
Choose communication method depending on
application requirements
Consult the NI Developer Zone for advanced
examples

53

Additional Resources
Customer Education
LabVIEW Intermediate II: Performance and Connectivity
LabVIEW Real-Time Application Development

NI Developer Zone
Using the LabVIEW Shared Variable
Deterministic Data Streaming in Distributed Data Acquisition
Systems
Command-Based Architecture for LabVIEW Real-Time

54

LabVIEW Learning Paths

Advanced

LabVIEW Advanced I: Large


Application Development

LabVIEW Intermediate I and II

Intermediate

Specialty

Foundation

LabVIEW Object-Oriented
Programming System Design

LabVIEW
Real-Time
Application
Development

CompactRIO
Fundamentals
and LabVIEW
FPGA

LabVIEW
Instrument
Control

RF
Fundamentals
and RF
Application
Development

LabVIEW
Machine Vision
and Image
Processing

LabVIEW Basics I and II

LabVIEW
DAQ and
Signal
Conditioning

Ways To Learn LabVIEW


In A Classroom Near You
Held at a local hotel or training facility
Personal Interaction with Instructor and other Attendees

On-line At Your Desk


Live and Instructor-led
No travel and reduced time away from work

At Your Company Office


Tailored course material for your companys needs
No travel required

At Your Convenience
Self-paced course kits
On-demand training modules located in the Services Resource Center

Training & Certification Membership Program


Unlimited access to all
regional and on-line
courses for one year
Unlimited access to all
certification exams for
one year
Option to retake all
courses and exams

ONE PRICE

Questions?

Vous aimerez peut-être aussi