08-24-2012 11:58 AM
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.
Solved! Go to Solution.
08-24-2012 12:03 PM - edited 08-24-2012 12:06 PM
Hi,
there is a Queue Flush you can use.
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.
08-24-2012 12:15 PM
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
08-24-2012 12:15 PM
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.
08-24-2012 12:17 PM
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.
08-24-2012 12:18 PM
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.
08-24-2012 12:38 PM
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.
08-24-2012 12:51 PM
@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.
08-24-2012 12:59 PM - edited 08-24-2012 12:59 PM
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.
08-24-2012 01:39 PM
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