LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read and display waveform from a file continuously

Hi,

I have a board ( not NI board) that sends data over a USB connection to my computer and logs the data to a text file in CSV format. I am collecting voltage data every 0.000246s (sampling rate 8.138kHz).

I wrote a VI that uses “read from spreadsheet file” to open/read the data, then plot the waveform on a graph. I also do some calculations and finally write all my important data to another file with “write to speadsheet File” VI.

Basically, I create my input file first then I read this file and display it. Now, I like to convert this to “almost” real-time data streaming ( I don’t have real-time software and interface, just LabView). It doesn’t have to be real-time, as long as it refreshes the waveform every 0.5 seconds or 1 second (while data is still being written to the original input file with ~8KHz sampling rate).

I like to know what is most efficient way.

I read other postings here but most of them want real-time since they have LabView Real-Time or NI data acquisition board. I just want to keep track of my input but it can be delayed. I gather I should write a loop to open a file take a 0.5 or 1 seconds chunks (have to somehow keep track of where you are in the file too!?), add the waveform to screen, and calculate the key parameters, and write them to a file. Then, repeat. But I see people saying that opening and closing the files takes time. Am I on the right path or there is a better way?

I am new to LabVIEW and I would appreciate your help.

 

Thanks

0 Kudos
Message 1 of 6
(3,364 Views)

Reading and writing to a file by itself doesn't usually take that long.  Usually on the order of 5-10 milliseconds.  However, since you're likely using this on a Windows PC, you don't ever have a guarantee that time will always be that short, especially if there's a system operation using the disk in parallel with your process.  It could eventually get slow enough to affect you.

 

What you probably want to use is a queue.  Create a queue reference at the start of your program and pass it to both the read data and display data loops.  Every time you get a chunk of data, wire it to an "Enqueue" VI as well as writing it to disk.  And at the start of your data display loop, have a "Dequeue" VI there to get the next chunk of data and add it to your display.

 

If you could actually post your VI we may be able to offer much more specific solutions.

0 Kudos
Message 2 of 6
(3,350 Views)

Another issue you may run into is that the other program may have the data file locked, keeping you from opening it.

 

But a simple loop with what you have described should do it assuming you can get access to the file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(3,347 Views)

Yes, you are correct getting access to the file that is still being written to is an issue. ( I rememebr I had the issue before when the file was still updating and I made sure to stop my recording before). As wrokaround, should I be copying the the file each time and open the copied file and then discard it?

 

Thanks,

Behnoosh

0 Kudos
Message 4 of 6
(3,344 Views)

Thansk for the tip. I understand what you are saying with quesing it. I will lookinto finding some examples for Enqueue ( do u have any examples to share). And sure I will upload my VI soon.

 

Thansk,

behnoosh

0 Kudos
Message 5 of 6
(3,342 Views)

Here is the VI. There is not much to it ( sorry it is quite messy, I am just learning LabView.). It just read a CVS file that has three col. (time, voltage1/Channel1 and voltage2/channel2).  It does some data calculations based on two input waveforms and then it writes it out as well as display it on a graph and plot.

 

The input is something like this:

 

LOGGER
 
t(s), chA(V), chB(V)
 
0.000000, 0.957463, 2.058745
0.000246, 0.957280, 2.058425
0.000492, 0.957280, 2.058379
0.000737, 0.957463, 2.058471
0.000983, ...
0 Kudos
Message 6 of 6
(3,324 Views)