LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to release and read another external file

My vi is set to read an external file (a previously collected force plate signal), then perform a string of analyses on it and finally save the analytical output. Currently, "Read from measurement file" is outside the while loop containing all of my analysis.

 

Without completely restarting the vi, I would like to be able to release the file and load another.  How might I do this?  

 

Thanks!

0 Kudos
Message 1 of 9
(3,298 Views)

I think you need to put one loop inside another loop.  The inner loop does the analysis and saves the output.  It sounds like you already have that working.

 

The outer loop provides the inner loop with a fresh set of data each time.

 

It would be easier if we could see your program.

0 Kudos
Message 2 of 9
(3,292 Views)

Attached to this post is the program I have so far.  

 

When started, the program prompts the user to enter the linear scaling equation for the signal from the force plate, as well as prompting the user to choose the signal file.  I would like to enter the scaling equation, then analyze a file, save the output, then analyze another file without having to enter the scaling equation again.

0 Kudos
Message 3 of 9
(3,281 Views)

The first thing I'd like to mention is that in 15 years of Labview programming, I've never once made a program with a block diagram bigger than one screen. (I'm sure there are many other things I do wrong, but I think clean, neat code is important.)  Yours definitely isn't the worst I've seen... but I really hope you clean it up.

 

I haven't checked carefully, but it looks to me that the only thing you have to do is move "Read Measurements File" from outside the loop to inside the loop.  If it's inside the loop, it gets called every time the loop runs, so a new measurement file gets selected each time.

 

Leave the equation input outside of the loop.  That way, it only runs once, before the loop starts so the operator doesn't have to enter the equation again. 

 

Weightlifter.jpg

 

Let me know if that doesn't work.

 

0 Kudos
Message 4 of 9
(3,272 Views)

It looks like the solution is a slight modification of the first one suggested.  I created a second while loop around the while loop in the original program I posted, with the "Read from measurement vi inside of the outer loop, but outside of the inner loop.  I wired the "EOF?" output to the "Reopen File" input.  When the inner while loop finishes, the "read from measurement file" vi reaches the end of the file, prompting the open file dialog again.  

 

Thanks for the help!

 

 

As a follow up question to LandBelenky, how would you suggest that I clean up the program?  I had assumed that the program would be necessarily complex, as the final analysis has a total of 66 outputs, each of which has a different calculation.

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

I would do several things to clean up the block diagram.

 

  • whenever you have multiple outputs that are related to each other (PF, F100, F150, F200, F250, etc...) or all of the RFDs and Impulses, you can bundle them together and then display them with one big cluster, or as an array, if that makes sense.  This will reduce your total number of outputs and maybe improve organizaiton.
  • If you have a seqeunce of functions that go together, you can combine them into a SubVI to save blockdiagram space and making things more logical.
  • If you have several places where the same sort of function is being done, (for example, you have Extract-Statistics-Formula several times and Extract-Integral-Statisics several times) you can make this into a sub-VI and then loop through it.  That way you can execute the function multiple times (with slight changes on each loop), but you only have to have the code written once. It also makes it much easier to improve the code because you only have to make one change instead of four. 

The attached VI shows two ways of doing something.  On the left is your code, which is four sets of the same thing.  On the right, I've taken this code and put it into a loop so it does the same thing four times.

 

 

Message 6 of 9
(3,249 Views)

Can you make that vi into a 2010 labview file?  I can't open the one you attached.  Thanks!

0 Kudos
Message 7 of 9
(3,236 Views)

Hey Georgebb,

 

Those are some great suggestions by LandBelenky! SubVIs are a great way to keep your code maintainable and easier to follow.

 

I made a 2010 version of his example file for you. 

 

Hope it helps! let us know if you have any more questions!

 

Joe S

Applications Engineer

National Instruments

0 Kudos
Message 8 of 9
(3,213 Views)

Sorry,  I keep  forgetting that I'm using LabView 2011.

Message 9 of 9
(3,209 Views)