LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

network shared variable read

Hello all,

 

I am trying to stream data from my RT target (PXI 8196 running LVRT 9.0)  to my host using network shared variables. The NSV has a FIFO of about 1500 values. I am writing values to the NSV from a timed loop @ 1000 values/s.

 

As far as my understanding goes, there should be some mechanism whereby I can read an entire chunk of values on my Host PC (say 1000 values if I poll every 1 second). the whole point is to log the data without losing any values. I have read a few articles which brush on this issue but none mention conclusively how to empty the FIFO of a network shared variable.

 

If I just read the variable in my slower loop, I only get the latest value which leads to an effective sampling rate of 1 sec.

 

Where can I find some sample code bzw. can someone post some basic structure to help me through?

 

Many thanks in advance.

 

Regards,

Shailesh

0 Kudos
Message 1 of 10
(4,045 Views)

What version of LabView are you using? They finally released network streaming in LV2010 which would be what you want to do. 

https://www.ni.com/docs/en-US/bundle/labview/page/streaming-data-and-sending-commands-between-applic...

There is a good explanation of how it works in this video

http://zone.ni.com/wv/app/doc/p/id/wv-157 

 

Shared variables are great for point by point sharing. They are not good for data streaming like you are trying to do.

---------------------------------
[will work for kudos]
0 Kudos
Message 2 of 10
(4,034 Views)

You could try sending blocks (arrays) of data.  Lets say you transmit 10 blocks/s each containing 100 samples.

Then on the PC you could read at a 10hz rate which is doable.  Also, you could try setting up your existing system

with a read with timeout set to 1 ms and just spin that puppy as fast as it will go.  You may find that it will keep up with the

1000s/s rate.

0 Kudos
Message 3 of 10
(4,029 Views)

To avoid data loss you have to use the Buffered Network Published Shared Variables

read this first BNPSV

 

You have to check the timestamp and/or data to avoid multiple reads of the same (last) value if the buffer is empty.

 

The FIFO you mentioned is probably an SV enabled RT FIFO and ineffective in terms of network traffic.

 

Hope it helps

Christian

0 Kudos
Message 4 of 10
(4,006 Views)

Hello All,

 

many thanks for your replies.

 

rex: LV2010 is not a possibility right now. But I will keep an eye on it as an option for the near future.

 

sachsm: I am sending data one set of values at a time. I guess you are suggesting setting up some kind of accumulator and writing that to a network variable? Anyways, I have chosen another approach which seems to work for me.

 

My Solution: I put the network variable read in a for loop for 1000 entries and read out an array. This method had only one little problem. When the buffer was empty, the last value was being repeated till a new loop iteration could begin. But many thanks to christian w for suggesting variable timestamp comparison. Putting the variable read in a WHILE loop instead of a FOR and wiring the stop condition to a simple timestamp comparison has done the trick. Now I dont lose any data and no data is repeated. Works like a charm.

 

Many thanks again to you guys!

 

I have only one grudge and that is that you cannot find example programs for something like this. There must be many people who wish to log data at rates beyond 1 KHz. Am I to assume that everyone else figured this out by themselves? If yes then I have missed a few vital steps of my LabVIEW training 🙂

 

Regards,

Shailesh

0 Kudos
Message 5 of 10
(3,998 Views)

Can you post your code?

---------------------------------
[will work for kudos]
0 Kudos
Message 6 of 10
(3,985 Views)

Do you mean the before code or the after code?

 

Just as a follow up, I have noticed that despite the time stamp comparison, SOME VALUES ARE BEING REPEATED. I can filter them out later offline but I would rather avoid the situation in the first place.

 

The only explanation I have is that somehow the time stamp is being revised. As a last alternative, I plan to log the time stamps just to see the exact duration between the repeated values. I will keep you posted.

 

Regards,

Shailesh

0 Kudos
Message 7 of 10
(3,955 Views)

Hi Shailesh 

 

I wanna do similar stuff from Smart Camera, do u mind sharing your code. 

 

Thanks 

Kunal

-------------------------------------------------------------------------------------------------------------------------------
Thanks & Regards,
Kunal Raithatha.
CTD - CLAD (I wish I can take off that A, and maybe use it later to replace D 🙂

Easy Tip :- "To copy an image to a VI icon, drag the image file and place it on the icon
located in the upper right corner of the front panel or block diagram" ...If you know any
more reply back.
-------------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 8 of 10
(3,745 Views)

Hello Kunal,

 

are you using LabVIEW 2009? Do you need code for a specific part or do you want the entire code for logging data from the RT system to the development computer?

 

Shailesh

0 Kudos
Message 9 of 10
(3,726 Views)

I have 2010 so any version will work.

 

Basically I am a newbie and want to learn how to use timed loop, time stamped shared variable, making FIFO.

 

My project need is to compare current and previous shared variable to see a difference and divide by time diffrence to get velocity. 

 

Right now m using time to wait vi in loop to get data every 400 ms from smart camera. When you said getting repeated data, by chenging this time loop waits for each iteration, repeatation can be avaoided.

 

Wanna look at the VI for streaming and control of shared varable timing loop.

 

Thanks for reply

-------------------------------------------------------------------------------------------------------------------------------
Thanks & Regards,
Kunal Raithatha.
CTD - CLAD (I wish I can take off that A, and maybe use it later to replace D 🙂

Easy Tip :- "To copy an image to a VI icon, drag the image file and place it on the icon
located in the upper right corner of the front panel or block diagram" ...If you know any
more reply back.
-------------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 10 of 10
(3,717 Views)