Example Code

Using Secondary Ethernet Port on a Remote Target for Data Transfer

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.

    Hardware

  • CompactRIO|SingleBoardRIO
  • PXI|VXI

    Software

  • LabVIEW

    Operating System

  • NI Linux Real-Time

Code and Documents

Attachment

Description

 

Introduction

If you want to be able to use a secondary ethernet port (on a controller or a add-in card) to perform UDP transmission, then this basic example code will get you started in the right direction. The first thing you have to do is properly configure the secondary ethernet port for use. KnowledgeBase 4E0DGASK: Configuring the Dual Ethernet Ports on Real-Time Controllers has a step-by-step tutorial that can walk you through this process. After the secondary ethernet is properly configured, then just use the attached LabVIEW project (UDPServerFrom2ndEthernetPortLV2009f2.zip) to get a basic understanding on how to broadcast UDP packets only from this secondary ethernet port to another remote target. This code was programmed and saved in LabVIEW 2009f2 (with the f2 patch). I have posted pictures below with descriptions showing the two main VIs. If you need this functionality in an earlier version of LabVIEW, please just try to replicate the code from the pictures because I can't downgrade the code.

 

 

Steps to Complete

  1. Download the attached zip file (UDPServerFrom2ndEthernetPortLV2009f2.zip)
  2. Unzip the contents and open the 2ndEthernetUDP.lvproj file
  3. Change the IP Address of both remote targets in the project to your own (Right-click on each one and choose Properties)
  4. Open the UDPServerOnRemoteTarget.vi and look through the code
  5. Change the IP Address being wired into the UDP Open.vi's net address input to the secondary ethernet port's IP Address
  6. Change the IP Address being wired into the UDP Write.vi's address input to the remote target's IP Address that you would like to broadcast to
  7. Make sure that the port number wired into the UDP Open.vi port input isn't being used by any other application (this port should be unused unless you are specifically using it in another application)
  8. Open the UDPClientOnRemoteTarget.vi and look through the code for understanding
  9. Run the UDPServerOnRemoteTarget.vi
  10. Run the UDPClientOnRemoteTarget.vi while the other vi is still running
  11. Notice on the UDPClientOnRemoteTarget.vi is displaying the iteration number that the other vi is on.

 

 

Additional Notes

Here is the VI that acts as the UDP Server on the PXI controller (or any other remote target) that broadcasts data using only the secondary controller:

UDPServer.png

Here is the VI that acts as the UDP Server on the cRIO (or any other remote target that you want to read the UDP data):

UDPClient.png

 

 

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

Comments
BADWI
Member
Member
on

hello Grant

can you illustrate to us the hall schematic by a small picture ( PC, pxi, cRIO, ethernet cables, ports ) and how they are related?

best regards