LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Data from a Queue - Store in Fast Loop, Display in Slow Loop

Solved!
Go to solution

Here's my BD below.  I am queueing data in a faster loop (either 100 ms or 50 ms) and sending that data to a 250 ms loop.  I need to be able to display the data in the slower loop (so that the FP doesn't have to update every 50 ms).

 

Problem I'm having:  How do I empty the data?  It builds and builds and eventually I'm looking at a chart that has data that's 1 minute old.  I've tried writing my own flush code (attached).  I've tried to use variables to pass data and use an array to parse...not working.  Any help would be appreciated.

 

BD.png

--------------------------------------------------

Nathan - Certified LabVIEW Developer
0 Kudos
Message 1 of 10
(3,338 Views)

Hi,

there is a Queue Flush you can use.  queue flush.png

 

 

 

You just have to decide when to call the flush.  Since you know the timing difference you can use a timer to flush the queue every so often.

-------
Mark Ramsdale
-------
0 Kudos
Message 2 of 10
(3,335 Views)

Nathan,

 

Another approach is to read (dequeue) the data as as fast as it comes in but only update the chart 4 times per second.

 

Any time you are using parallel loops you wan to make sure that all the data enqueued is dequeued, whether it is used or not.

 

Lynn

0 Kudos
Message 3 of 10
(3,326 Views)

Thanks for the help.  I am aware of that function, but if you check its output, it will not work with a standard chart that accepts waveform data.  The output of that function is an array of clusters of whatever data type.  I wrote a VI (attached) to do the same thing but to output chart-readable data. 

--------------------------------------------------

Nathan - Certified LabVIEW Developer
0 Kudos
Message 4 of 10
(3,325 Views)

Thanks for the help, Lynn.  What would be the best way to pass the data as an array?  I don't think I can only send the update four times per second as I need to be able to see all data encountered during the test.

--------------------------------------------------

Nathan - Certified LabVIEW Developer
0 Kudos
Message 5 of 10
(3,322 Views)

From your diagram, it appears that you don't care about showing all of the data.  Therefore, I would just use a notifier instead of a queue.  A notifier only keeps the latest information, so there should be no problem.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(3,320 Views)

My Bad, I thought you wanted to clean out the queue. 

 

If you want to get all the data that is building up in the queue you can dump the data at a fast rate into an array, etc... and then graph the data in that array at a slower rate.   If you don't need all the data you can use the latest piece in the array.

 

Hard to digest all your VI at once.  You might consider a fast loop inside the 250ms loop that reads the queue with the data and then outputs to the 250ms loop.

-------
Mark Ramsdale
-------
Message 7 of 10
(3,309 Views)

@crossrulz wrote:

From your diagram, it appears that you don't care about showing all of the data.  Therefore, I would just use a notifier instead of a queue.  A notifier only keeps the latest information, so there should be no problem.


Looks like this is the easiest and most effective solution, albeit I do wish I could somehow keep all data for plotting.  Thanks.

--------------------------------------------------

Nathan - Certified LabVIEW Developer
0 Kudos
Message 8 of 10
(3,306 Views)
Solution
Accepted by topic author Nathan_S

If you need all of the data to go into the chart, I would use the flush queue and write to the chart in a FOR loop (autoindexing with the elements array from the flush queue).  You may set the Defer Front Panel Updates before the FOR loop and reset it after, but I'm not sure that will buy you that much.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(3,305 Views)

We are getting conflicting messages.  You want all the data to go to the chart but you do not want to update it very often.

 

You could store the data in an array in a shift register. Put new data into the array as soon as it arrives from the other loop. Every 250 ms extract the newest (or oldest, or whatever you want) set of data from the array and write it to a graph (rather than the chart). This way you can have complete control over the processes.

 

Lynn

0 Kudos
Message 10 of 10
(3,287 Views)