From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Overlay data from file on an XY graph both during and after acquistion

Solved!
Go to solution

I'm not sure if this topic has been discussed yet (I couldn't find a suitable thread, but maybe I was using incorrect search terms....).

 

I'm probably overthinking this, but essentially, I am trying to create a routine that displays measured data on an x-y graph (x-axis is not uniformly spaced in this data set) and allow a user to "overlay" historical data from a text file(s).  I am using a queue to pass the data from an "acquisition" loop to a "plot" loop, as I don't want the time spent finding a file to hold up the acquisition.

 

Within the plot loop is an event structure that looks for user input to add data from a text file.  Outside the event structure is the Dequeue Element that adds the acquired x-y pair to the "active" graph array and replots the active trace and all traces that may have been loaded.

 

As you can imagine, everything works well while the acquisition loop is running, however once acquisition stops, the plot loop stops, since there is nothing to dequeue (in other words it ignores the request to overlay data).  Wiring a timeout on the dequeue was a temporary workaround, but I run into the opposite problem in that the event structure holds up the loop when the acquisition restarts, unless the user loads a file.  I didn't want to wire a timeout to both, as it seemed like a waste of computer resources (maybe I'm wrong here).

 

Any thoughts would be greatly appreciated and thank you for your time.

0 Kudos
Message 1 of 15
(3,285 Views)

That's the kind of question where it would be very helpful if you uploaded your VI so we can see how you are doing things now and be able to understand the description of your VI by more than just reading words.

0 Kudos
Message 2 of 15
(3,277 Views)

There are plenty of ways to do xy graphs, so we need to see some code (hopefully you are not using the build xy graph express VI).

 

Why would you need to update the graph is there is no new data?

 

 

0 Kudos
Message 3 of 15
(3,270 Views)

Thanks for the quick response.  Please find attached a mock-up of the code.  I've simulated the acquisition routine with one that draws a circle of specified radius.  The overlay files are circles of different diameters I've been using to debug the routine.

Download All
0 Kudos
Message 4 of 15
(3,248 Views)


@altenbach wrote:

There are plenty of ways to do xy graphs, so we need to see some code (hopefully you are not using the build xy graph express VI).

 

Why would you need to update the graph is there is no new data?

 

 


Definitely not using the express VI in my application.  Ultimately, I would like to look at old files between acquisitions so I have an idea of how to configure for the current run and/or spot for any changes that may have occurred run to run (which may imply changes in the setup or other problems).

0 Kudos
Message 5 of 15
(3,239 Views)

had a look at your code, and have some suggestions

mpf3.png


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 6 of 15
(3,233 Views)

you can also decouple the "get data from file" from your "Plot Loop"

 

just move the event-structure to a new loop

and add another queue

 

also you might want to replace "dequeue" with "flush", because your acquisition loop might produce faster than you consume

 

 

personally i would go with "User Events", it behaves like a queue,

but you can act on the events with your event structure,

also you can have multiple user-events, each with its own data-type.

which means, you only would have one EventQueue wire and not two queues.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 15
(3,226 Views)

@cp73 wrote:

As you can imagine, everything works well while the acquisition loop is running, however once acquisition stops, the plot loop stops, since there is nothing to dequeue (in other words it ignores the request to overlay data).  Wiring a timeout on the dequeue was a temporary workaround, but I run into the opposite problem in that the event structure holds up the loop when the acquisition restarts, unless the user loads a file.  I didn't want to wire a timeout to both, as it seemed like a waste of computer resources (maybe I'm wrong here).


 

When you press "stop", you destroy your queue and stop the "Acquisition Loop",

since the queue is no longer valid, "Dequeue" in "Plot Loop" throws an error,

which then stops the loop.

 

destroy the queue only after all loops have finished.

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 8 of 15
(3,216 Views)

@jwscs wrote:

@cp73 wrote:

As you can imagine, everything works well while the acquisition loop is running, however once acquisition stops, the plot loop stops, since there is nothing to dequeue (in other words it ignores the request to overlay data).  Wiring a timeout on the dequeue was a temporary workaround, but I run into the opposite problem in that the event structure holds up the loop when the acquisition restarts, unless the user loads a file.  I didn't want to wire a timeout to both, as it seemed like a waste of computer resources (maybe I'm wrong here).


 

When you press "stop", you destroy your queue and stop the "Acquisition Loop",

since the queue is no longer valid, "Dequeue" in "Plot Loop" throws an error,

which then stops the loop.

 

destroy the queue only after all loops have finished.

 


Thanks jwscs for all of the input.  I really appreciate the suggestions on how to make the code leaner with respect to CPU and memory, as well (that's one thing they don't really teach a lot on in the introductory classes).

 

I may have "misspoke" earlier when I mentioned the "acquisition stopping."  Stop was the wrong word for me to use.  What I meant to convey is that once the acquisition is complete, the acquisition loop goes back to waiting on the user to either press "acquire" and draw the next circle, or to press "finished" to execute a "clean" exit of the program (clean in quotes, as it is not a clean exit in the example I uploaded).  It is in this waiting condition when the plot loop becomes unresponsive to it's own event structure (the add overlay button), as the Dequeue Element is waiting for data, therefore holding things up.  I wasn't actually referencing the "exit" condition of the acquisition loop, so my sincere apologies for the confusion.  That being said, thanks for pointing out the bug where I can destroy the queue with data still in it.  I'll be sure to fix that in my final version.

0 Kudos
Message 9 of 15
(3,193 Views)

it took about 12 hours but i think i have a solution. Please see attached.

 

I first saw that you didn't have anything wired to the file path terminal of the "Read from Spreadsheet File.VI" so i wired a file path control. This resolved the 1st problem of:  browsing for a file "holds up the acquisition".

 

the 2nd issue of being able to overlay a plot whether you are acquiring or not, while retaining plot history was much more difficult. i followed the continuous measurement and logging project template for LabVIEW, which is a producer consumer architecture because i thought separate while loops for acquisition, overlay, and data display would help. I still ran into the issue of both "wait on notification" functions (similar to queue functions) for acquisition and overlay having to receive a notification to complete the data display while loop. I used case structures to only execute the wait on notification for the overlay if overlay was pressed. when not overlaying, i either replaced an array subset with acquired data or re-plotted the old data if the acquire notification times out. if you are acquiring and select overlay, 1 acquired point will not be plotted during the overlay display loop execution but since it is stored in arrays in the acquisition loop, the next iteration of the display loop will have the acquired data points.

 

general comments: 

The "read from spreadsheet file VI" will not be supported in future versions of LabVIEW. The code only displays 1 overlay at a time. it also makes a line from circle to circle if you change the radius. The code could be revised to improve on these. I don't think you will be using an xy graph for data acquisition. You will likely use a waveform chart but i went ahead and made a solution as close as described with the provided VI.

 

Ryan Moore

Aiken Engineering Company

 

0 Kudos
Message 10 of 15
(3,180 Views)