LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save XY Graph programmatically

Solved!
Go to solution

Hi

I have a LabVIEW program that would automatically export its logs to predefined file names, and paths, the only part that I am having an issue with is exporting an XY Graph.
I would like to export this XY Graph just like using the following menu command:
2019_01_30_17_51_33_Window.png

 

I want to save the XY graph into a predetermined path, block diagram follows:
2019-01-30 18_00_40.pngThank you very much in advance 🙂

0 Kudos
Message 1 of 11
(7,036 Views)

The quality of help here is typically better if you would attach a VI instead of a picture. What is your LabVIEW version? Where are the terminals? (All I see are locals)

 

You need to do a few things:

  • Extract the xy graph data into a suitable form
  • write it to a file

 

If you want real excel, look in the "report generation" tools. (You placed an old version of "write to spreadsheet file", which has nothing to do with excel).

0 Kudos
Message 2 of 11
(7,032 Views)

Export Data to Excel does not actually save the data, it simply opens the data in a spreadsheet that you can then save wherever you'd like.  If you want to programmatically save data, you need to develop the code to do so

0 Kudos
Message 3 of 11
(7,025 Views)

@altenbach

My apologies, I have forgotten to mention the LV Version
I am using LabVIEW 2014

Regarding the question about the terminals, if I am understanding you correctly, these local variables are actually being written to from a different part of the program. So the idea of this little snippet of code is to record that value every five seconds into the XY Graph
And you hit the nail on the head, that is exactly what I want to do, I want to eliminate the operator forgetting to export the graph into an excel sheet by having to go to the front panel, pressing right click, and exporting the data

As long as the data is exported into a spreadsheet, whether be it a CSV, or an XLS, it doesn't matter to me

@RMowatt
Thank you very much for your suggestion, that is precisely what I am trying to do, but it doesn't work for me, it tells me that the source is a 1D array of clusters, and the sink is a cluster of 0 elements

 

I am attaching the snippet of code

 

 

0 Kudos
Message 4 of 11
(7,013 Views)
Solution
Accepted by DesolateAOD

I would open the log file before the loop, append a formatted row with two scalar values (x, tab, y, linefeed) whenever you also write that data to the xy graph, and close the file at the end of the program. This also guarantees that you have a complete log. Doing it at the end loses everything if the computer crashes or an error occurs, for example.

 

(Be aware that your "built xy graph express VI" will accumulate data forever and you'll ultimately run out of memory. You also need a small wait in your greedy loop)

 

Message 5 of 11
(7,011 Views)

The build xy graph is creating an array of clusters and writing it to your xy graph.  Therefore you need to index that array to find the data you are looking for.  I agree with @altenbach that the express vi can lead to memory overload, and with no wait leads to a greedy loop.  Also writing each entry one at a time is a great idea so you don't lose any data in case of crash.

 

Using a shift register and building your own arrays with the data is a useful way to go, and initializing those arrays if you know exactly how many elements will be in them will allow for a stable program - not building arrays of n elements programmatically.

Message 6 of 11
(6,990 Views)

@altenbach

How have I not thought of that, especially that I am implementing this in a different program, saving each line into a file, duh. Thank you very much for the solution 🙂
Regarding the greedy loop, I do have a 5000ms wait inside the loop, is that not enough?

 

@RMowatt

unfortunately, I cannot use a fixed array size since I do not know when the operator will hit the stop button, but I will go with @altenbach's solution of writing the data every loop cycle, which happens every 5000ms since there's a wait vi

0 Kudos
Message 7 of 11
(6,981 Views)

@DesolateAOD wrote:

Regarding the greedy loop, I do have a 5000ms wait inside the loop, is that not enough?

 


I don't see any wait here.

grinch.png.

0 Kudos
Message 8 of 11
(6,964 Views)

Oh, this one is just to wait till the Sync signal comes from a different part of the program, the Sync gets asserted in about a second into the program execution. I guess I can add a small wait there.
Thank you very much for your suggestion 🙂

0 Kudos
Message 9 of 11
(6,958 Views)

You could use MathScript and write a short Matlab code to dump your plot after wiring the data to the node.

 

For instance (modify as needed):

 

h1=figure(1);

p1=plot(x1,y1,'-r');

print -dpdf h1;

close(h1);

0 Kudos
Message 10 of 11
(6,934 Views)