LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

network shared variable vs RT fifo enabled

Good morning.

 

I have an application for using a "notifier" for changing state on a real-time system.  I am thinking of using a shared variable to accomplish this (I could use a network stream, but I think that would be overkill).

 

I implemented a test VI that uses a network published shared variable with update timeout in a loop on the RT platform.  On the Windows side, I wrote to the network published shared variable and observed the behavior on the RT platform.  The timeout indicator would go off immediately after the write and then go back on as no data change occurred.

 

I implemented a test VI that uses a network published shared variable with single element RT FIFO enabled and update timeout in a loop on the RT platform.  On the Windows side, I wrote to the network published shared variable and observed the behavior on the RT platform.  The timeout indicator would go off immediately after the write and then go back on as no data change occurred.

 

I am puzzled.  The behavior of the network published shared variable and the network published shared variable with single element RT FIFO enabled appears to be identical.  Is there a suggested approach for mimicking a notifier between devices?  I would have assumed that the single element RT FIFO-enabled network shared variable would be the "correct" approach.

 

Thanks for any help,

Hamilton Woods

0 Kudos
Message 1 of 4
(3,077 Views)

I'm not quite sure I understand what you've done.  Can you post your test code?  I've used Network Shared Variables for communication with an RT Engine, so might have something useful to say ...  [In any case, I'm curious about your findings].

 

BS

0 Kudos
Message 2 of 4
(3,071 Views)

Per Bob's request, I am attaching a zip file that contains a demo project that shows apparent identical behavior of network shared variables with and without RT FIFO enabled.

 

Hamilton Woods

0 Kudos
Message 3 of 4
(3,063 Views)

It really helps to see the code -- now I understand the problem!  It has nothing to do with RT FIFOs, but with the nature of the "TimeOut". This acts similarly to the TimeOut on a Queue -- it causes the code to "block" for that length of time, and then returns an indication of whether or not the Queue (or Shared Variable) is "empty" (or timed out without getting any new data).

 

In your example, your "Wait" time is 1 msec.  Your Read clock is set to 200 msec.  Before you input any (new) data into the Shared Variable, each of the two Reads will "time out" (because they've sat without new data for >1 msec).  Now you put in some data.  When the next Read occurs, there will be "data", so it will be read and Timed Out will be false.  But unless you are very quick and get another value in before the next Read (i.e. within 200 msec), the subsequent Read will see "Nothing new here".  Note that it will have actually "timed out" 199 msec previously, as the Wait time is 1 msec.

 

I'd forgotten that Reads with Time Out "block".  Try setting the TimeOut to 10000 (10 seconds) and running your VI.  You'll see that not only does the Timed Out line stay low for 10", but the value doesn't update, either.  However, you can update the second Shared Variable (once).

 

Regarding whether or not to use RT FIFOs and what difference they make, this comes down to the question of Determinism.  If your Shared Variable is inside a Time-Critical Loop and you want to pass data out without causing jitter, use the RT FIFO.  [If you do a search for Queues vs RT FIFOs, there's a discussion that explains the difference].

 

I use Shared Variables when I want to transfer data, but don't care if I "miss a point".  So I'll use it to send "monitoring" information (at, say, 10 times a second) from my RT system to my host -- who cares if a point is missed (or, alternatively, if I read the same value twice because the RT system has been "busy" and hasn't updated yet).  If I need to get every value (for example, when I'm collecting sampled A/D data), I use RT FIFOs to get the data out of the Time-Critical loop, and then use a Queue or Network Stream to deliver it safely to the Consumer without missing any data points.

 

BS

 

Message 4 of 4
(3,053 Views)