LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot a graph by retrieving file in LabVIEW?

Solved!
Go to solution

 

Hello everyone,

I want to plot a graph using file as input.Input file has 2 columns, X_axis - date,time & Y_axis - data.

File in string format is converted to array.Then,1D array is connected to the graph.Both X and Y axis in graph are set to 'AutoScale'.

I've attached the solution which I came to so far,please do suggest me the solution.

There might be some stupid mistakes as I'm v new to LabVIEW 🙂

Download All
0 Kudos
Message 1 of 6
(4,357 Views)

1) If you wire a length to delete from array, you get a 2d array (when input is 2d). So remove that (or use index array), so you get 2 1D arrays.

2) The dT is a scalar value, that specifies the time between every subsequent sample. You probably want to use an XY graph. The XY graph excepts an array of timestamps and an array of values (which is what you have). Or calculate the dT for one sample, and expect all dT's to be the same.

3) You're wiring an (array of) string to a (array of) doubles. That won't work (LV is not python) Insert a "Fract/Exp String To Number" function between the 2D, 1D or scalars to convert from string(s) to double(s). For the date\time you'll need some more advanced string parsing.

4) The date and time seem to be two columns. You need to somehow combine them.

Message 2 of 6
(4,340 Views)

I suspect you need to spend some time with the LabVIEW Tutorials, as there seems to be some basic ideas that you don't know/understand.  I'm guessing that you did not write the attached VI -- it looks like an NI Example.  Some things you should learn:

  • The idea of "sampled data", an array of points taken at equally spaced intervals of time.
  • The LabVIEW concept of a WaveForm (one method of representing sampled data).
  • The difference between "time", "sampling time", a TimeStamp, particularly as they apply to sampled data.
  • Strings and parsing strings to convert them to (numeric) data.
  • The difference between a Chart and a Graph, and when to use which and why.
  •  How LabVIEW uses Time as a primitive data type (not only is there a Timing Palette, but data acquisition and processing have Time woven into them and depend critically on understanding how time is measured and how hardware deals with time.

Spend more time with the Tutorials.  Then try writing your own code, based on your new understanding.

 

Bob Schor

Message 3 of 6
(4,299 Views)

I have modified my program accordingly,still not able to plot the graph.

Download All
0 Kudos
Message 4 of 6
(4,266 Views)
Solution
Accepted by topic author hmshwe

Remove the while loop, and the two index array's in the while loop. That should at least enable the code to compile.

 

The first column is still a problem. You're formatting a string to double, but that only works if the string is a double. But the string is a timestamp.

 

To convert the string to a double, isn't that easy. It would be a lot easier if you could store the dT's (relative to T0) instead of the absolute timestamps. Then the fist column will be doubles, and everything should work.

 

To parse a timestamp string to double, you'll need to use Scan From String, and make a format string like "%<%Y-%m-%d %H:%M:%s>T". The help should provide help on that. Note that Scan From String does not work on arrays, so you need to put a for loop around it...

Message 5 of 6
(4,261 Views)

Thanks for the reply  wiebe@CARYA!

0 Kudos
Message 6 of 6
(4,240 Views)