Example Code

Basic Real-Time Network Communication Using Shared Variables

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Real-Time Module
  • LabVIEW

Code and Documents

Attachment

Description

Overview

This example demonstrates how to use shared network variables communication between host PC and real-time target device.

 

Description

This example project demonstrates the most basic version of network communication between a host PC and an RT target device. After adding the target to the project, right-click on the target and select New>>Variable. Then name the variable and enable the RT FIFO (for an in depth understanding of how shared varibles operate and their different options read Using the LabVIEW Shared Variable). Now that the shared variable has been created you can simply drag and drop the variable onto the block diagrams of VIs in the project.

In this project automatic deployment of the shared variables is disabled (right-click on the target and select Disable Autodeploy Variables), so that the host can be started and stopped without interupting the target VI. For a more complete example project open LabVIEW's  Example Finder and browse to Toolkits and Modules>>Real-Time>>Network Communication>>RT Network Communication.lvproj.

 

Requirements

 Software

  • LabVIEW Full or Professional Development System 2012 (or compatible)
  • LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • NI Real-Time target (e.g. 9024 or compatible) with installed Network Variable Engine 12.0 (or compatible)

 

Steps to Implement or Execute Code

  1. Download and extract the attached file "Basic Network Communication LV2012 NIVerified.zip"
  2. Open project file and follow the instructions in Front Panel and Block Diagram of both VIs and run the program.

 

Additional Information or References

Host VI:

Host VI LV2012 NIVerified.vi - Front Panel.png

 

Host VI LV2012 NIVerified.vi - Block Diagram.png

 

Target VI:

Target VI LV2012 NIVerified.vi - Front Panel.png

 

Target VI LV2012 NIVerified.vi - Block Diagram.png

 

Note: Even if the same timing value is used for both VIs (target and host) you can miss some values when reading (host) loop runs to slow because of some other
processes running in parallel and decreasing performance. Also some values can be read twice if reading (host) loop is running slightly faster than writing (target) loop.

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**

Justin Parker
National Instruments
Product Support Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
rvillarr
Member
Member
on

Do you have this in 8.2.1 version?

Rulee