How to Detect Network Connection Loss of NI Real-Time Target

Updated Oct 30, 2023

Environment

Hardware

  • CompactRIO Chassis

Software

  • LabVIEW
  • LabVIEW Real-Time Module

Let's suppose you want to discover a network connection loss on your NI Real Time Target in order to avoid damage to your hardware. 
There are several methods to implement this: continuously pinging the host target, TCP/IP communication or NI cRIO Watchdog.vi. 
 In this article, we will discuss another method of implementing this by means of Network Published Shared Variable. 

First of all, it is necessary to create a Network Published Shared Variable. It is not important the datatype of the variable. 
 After that add into your Real-Time VI Read Variable with Timeout.vi and add the necessary information as the name of the variable, timeout duration, and connect Timed out output of the VI to a Case Structure where you implement some logic (for example setting the output voltage to 0). The screenshot below demonstrates the suggested solution.
12.jpeg

When the Network connection of the RT Target is lost, the Read Variable with Timeout.vi outputs as Timed out = True. The RT Target implements the commands in the Case structure. When the connection is recovered, the Timed out becomes False.