LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read and graph an .lvm file?

Hi everyone,

 

I have an.lvm file with time in column 1 and 6 channels of data (only one header, tab delimited) that I would like to be able to read and graph in labview so that I can analyze it (using graph cursors to select segments of interest and get the mean, max, etc)... However, I am having some trouble doing this...?

 

To do this, I assume I will need the read the data into a while loop.... I have tried using the "Read from measurement file.vi" placed inside the loop and outide the lopp; but either only the first 400 samples (one write interation) are graphed OR I get an error saying "end of file encountered"?...

 

Do I need a for loop inside the while-loop?

 

 

Any suggestions would be greatly appreciated...

 

Regards,

Jack

 

0 Kudos
Message 1 of 9
(5,728 Views)

Hi Jack,

 

Does your .lvm file consist of multiple 400 sample segments (you mentioned 400 samples was one write iteration)? If so, I'm guessing you want to read and concatenate all of these segments into a single graph plot. Placing the "Read from measurement file.vi" within a while loop would be the simplest way of doing this as it will read the subsequent segments on each iteration, however, you need to monitor the EOF (end of file) boolean output from the VI to determine when to exit the loop. That way you won't receive the error.

 

It's also worth baring in mind that using a while loop in this manner when the file size is unknown will result in a performance/efficiency hit memory wise, but this is only generally a problem when dealing with extremely large files for which the .lvm format isn't designed for.

 

Hope that helps,

 

Paul

0 Kudos
Message 2 of 9
(5,707 Views)

What did you set the Segment Size parameter to?

 

Perhaps it would help if you uploaded your code and your .lvm file. If the .lvm file is large, zip it.

0 Kudos
Message 3 of 9
(5,705 Views)

Hi Paul,

 

Thanks for the reply... I followed your suggestion and managed to get it to work.... Attached is what I have done... Not sure if this is the best way to go? My files range form 12-30mb in size to take about 15-30secs to load... I have attached an edited file with data deleted for you to view (data are force from a strain guage from 1 muscle contraction, triggers from 2 muscle stimulators, and 3 channels of EMG; all sampled at 4k)....

 

Can I make it load quicker?

 

NOTE: the .xlsx file is .lvm file... I changed the extension as I could not upload it? change it back before viewing.

 

 

Regards,

Jack

Download All
0 Kudos
Message 4 of 9
(5,682 Views)

Hi ,

 

Please reply and code below...

 

Regards,

Jack

0 Kudos
Message 5 of 9
(5,679 Views)

Hi Jack,

 

Glad to hear you made some progress with loading the file.

 

I'm afraid with regard to the loading speed, there is little else you can really do. You are always going to have a loading delay when retrieving an entire files worth of data into memory. One thing that would be worth trying is specifying a smaller segment size within the read. I've done some bench marking with sample data and it appears this can reduce the loading time by half, most likely because the memory manager can deal with smaller chunks of memory rather than juggling several large contiguous pieces.

 

All the best,

 

Paul

0 Kudos
Message 6 of 9
(5,671 Views)

@jcannon wrote:

Hi Paul,

 

Thanks for the reply... I followed your suggestion and managed to get it to work.... Attached is what I have done... Not sure if this is the best way to go? My files range form 12-30mb in size to take about 15-30secs to load... I have attached an edited file with data deleted for you to view (data are force from a strain guage from 1 muscle contraction, triggers from 2 muscle stimulators, and 3 channels of EMG; all sampled at 4k)....

 

Can I make it load quicker?


For the file that you uploaded I read the file in 40 msec. And I was running this in a virtual machine. The first loop you have in your code seems to be there based on the premise that you are reading the file in chunks. If you are not, then that all first loop is unnecessary. You would need just a single Read From Measurement File, Convert From Dynamic Data, and Array Size to calculate your total duration.

0 Kudos
Message 7 of 9
(5,647 Views)

TThanks for the reply... that makes sense..

 

But what happens when the EOF is reached? Won't I get an error? Or is the "Read Measurement...vi" called outide the while loop and just sends the array into the loop for display and analysis?

 

Thanks,

Jack

0 Kudos
Message 8 of 9
(5,641 Views)

jcannon,

 

As you guessed, it looks like the first while loop is only meant to pull data out of the file and send the array to the second loop for processing.  It terminates the first loop when it hits EOF.

 

 

Thanks,

 

David B

0 Kudos
Message 9 of 9
(5,629 Views)