LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I dynamically read a file and show/plot the data in the GUI?

Hi, everyone,

 

I hope to implement a VI with the following function:

 

Usually, when we "read a file" in VI and then show the data in the Waveform Chart or other display GUI, the VI will first read and record all of the data from the file and then show them simultaneously. Now, I want to implement a VI, which could read  the data from a file and display it in a time series. That is, I can define a "sampling rate" or "reading rate", like 100 data points / second,  then the data points could be correspondingly shown in Waveform Chart one by one as the time moves on. The key purpose is to simulate a real-time data collection module using an existing file.

 

I don't know how to implement this function. Any suggestion and solution are really appreciated.

 

Thanks.

 

Zhanpeng

  

0 Kudos
Message 1 of 7
(3,759 Views)

Heres the same effect, just a different approach :

The code in the red box was used to create data that you would be getting from a file.

What you could do is (shown above) :
- Read all of the data

- Index only one value at a time, and set the 'sampling rate' using a wait in a while loop.

- Build an array using this value, which will simulate collecting data in real time.

- I used an array of the iterations as X-values, because they coincidentally correspond to # seconds in my example

- I then bundled the time array (xvalues) with the values from your file (yvalues)

- Send that bundle to an XY graph

 

That should work, though you could implement some different logic for different sampling rates.

Let me know if you need a hand with that.

Message Edited by Cory K on 02-26-2009 11:36 AM
Cory K
Message 2 of 7
(3,754 Views)

Hi Zhanpeng,

 

most of the file read functions allow for setting how much data should be read from the file.

So you program to read just 100 datapoints instead of loading the whole file at once... This will also help to minimize memory footprint of your program when it comes to (really) big files.

Message Edited by GerdW on 02-26-2009 06:50 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 7
(3,745 Views)

Zhanpeng, do you only want to read part of a file because :

 

A) You want to simulate reading the data in real time

 

or

 

B) The files are very large

 

My solution above can be used for A, however you would want to use a different approach for B.

 

Cory K
0 Kudos
Message 4 of 7
(3,742 Views)

Cory, thanks a lot for your solutions.

 

The main purpose for my implementation is :

 

I have a large data file need to read, also this type of data need some simple arithmetic processing and then to be displayed in the GUI. Originally, if I read the whole data file, it will consume too much time and memory, as well as I still can't put all of the data in the screen at the same time (the Time x-axis is limited). So, I wonder whether I can read the data file in a "one by one" way, that is, I only read piece of data (we assume 100 data here), and then process and display them immediately. It seems like the ECG machine collect the patients' ECG signal and display it on the screen in a real-time way. However, I don't know whether LabVIEW support some sort of parallel processing.

 

read 100 data --->  process them                 --->  display

                                 read another 100 data  ---> process them                ----> display

                                                                                read another 100 data ---->  process   ---> display

 

Or I have to split the data into piece to piece:

 

read 100 data --> process ---> display ---> read another 100 data ----> process ----> display ---> read third 100 data ---> process .....

 

 I am not sure whether you are clear about what I want to do. Any suggestion are very appreciated.

 

Regards,

 

Zhanpeng

0 Kudos
Message 5 of 7
(3,719 Views)

How big is your data file?  I can read about 37000 numbers from a spreadsheet file instantly.  Assuming it's not a huuuuuge file that you can't wait a second or two to load, what's stopping you from just doing what I pictured below

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 7
(3,714 Views)

hello captainjin,

 

What type of file are you reading?  The Read from Spreedsheet file.vi has an input terminal that allows you to specify the starting location of the read.  It also allows you to specify the amount of data to read.  It would help if we knew what type of file and how the data was formatted.

Regards,

Jon S.
National Instruments
LabVIEW NXG Product Owner
0 Kudos
Message 7 of 7
(3,686 Views)