LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Close file causes Labview to freeze

Solved!
Go to solution

Hi,

 

I have a Labview program that contains a while loop in which a file is created every time the loop runs. The file is created at the beginning of the loop, and closed at the end of the loop, after some data is written on it. The file created are .raw pictures, and they are about 2.8mb each. 

 

The program runs fine at the beginning and creates the first file without any problem, and then goes on to create the second file and writes in it. Everything goes well until it tries to close the second file with the Close File function. Then, it just completely freezes. There is no error, nothing. It just stops and stay there for as long as I don't force-stop the program myself.

 

I searched on the internet, and found that maybe the creation and closing of a file at every loop is too much for LabVIEW and it causes it to crash, but I don't really know how to change that since I have to create a new file everytime.

 

I can't really attach the .vi file to this message since there is about 15 subvis that it needs to run, but I attached a screenshot of the section that causes problem if it can be of any help.

 

Maybe there would be another way of coding the labView program so it bypasses this problem?

 

Thanks

 

sectionVI.PNG

0 Kudos
Message 1 of 8
(4,424 Views)
Solution
Accepted by alric

I don't see any issue with the file aspects of your VI.

 

What I see that might be the problem is that you have an event structure buried in the VI.  Your innermost For Loop is going to pause on every loop iteration unless you cause an event that is handled by that structure to happen.  The only event shown in your picture (there might be other events but we can't see them) is the Rotation Go boolean contol needs to be changed in order for the event to fire and the For Loop to finish and start the next iteration.

 

Are you hitting the Rotation Go boolean on every iteration?  Of course if you hit that button and make it go True, the way it is wired will stop both of your For Loops and your inner most code will never repeat.

 

(Tip:  You can simplify the code where you build up your file name by using a Format Into String function.  All the string constants get built into the format string.  And all the functions to format the numbers get formatted by the format string as well.  6 nodes and 16 constants will get reduced to 1 node and 1 constant with a corresponding decrease in the number of wires.)

Message 2 of 8
(4,417 Views)

I'm the Chief Complainer, but I hate pictures of Block Diagrams -- I can't see them clearly, I can't see the "rest of the code", I can't see the other Cases of Case Statements, I can't type ^H on a function I don't recognize to "get LabVIEW Help", and I can't execute it to see where the errors occur.

 

Please attach your VI, instead.  Use the "Attachment" button on the left below this window.  Note you can only attach a few VIs -- if you need to attach more, compress a folder containing them and attach the resulting .zip file.

 

Having said that, what might be happening is a "clash" between closing a file and opening the next one.  I've seen this, on occasion, usually when using Excel, and solve it by putting a delay after the Close File (start by putting in a 1 second delay -- if you still get the crash, then this is not the problem).

 

Do attach your code, however, as it might be "something else" that we might be able to help you discover.

 

Bob Schor

0 Kudos
Message 3 of 8
(4,412 Views)

@Bob_Schor wrote:

I'm the Chief Complainer, but I hate pictures of Block Diagrams -- I can't see them clearly, I can't see the "rest of the code", I can't see the other Cases of Case Statements, I can't type ^H on a function I don't recognize to "get LabVIEW Help", and I can't execute it to see where the errors occur.

 

Please attach your VI, instead.  Use the "Attachment" button on the left below this window.  Note you can only attach a few VIs -- if you need to attach more, compress a folder containing them and attach the resulting .zip file.

 

Having said that, what might be happening is a "clash" between closing a file and opening the next one.  I've seen this, on occasion, usually when using Excel, and solve it by putting a delay after the Close File (start by putting in a 1 second delay -- if you still get the crash, then this is not the problem).

 

Do attach your code, however, as it might be "something else" that we might be able to help you discover.

 

Bob Schor


Correction:

You might be the loudest complainer.  There's a difference.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 8
(4,380 Views)

Thanks, that was the problem! I completely deleted that last frame since it wasn't really necessary, and it know works like a charm! LabVIEW wasn't freezing, it was just waiting for the Rotation Go boolean 😛

 

Thank you very much for your help and that very fast answer!

0 Kudos
Message 5 of 8
(4,376 Views)

As has been said, We need to see the VI, not a picture.

 

  • What triggers the event structure?
  • Does anything display in the error out indicator when it freezes?
  • What triggers the inner event structue and what is its purpose?
  • Does the generated file name contain any characters that are illegal for the OS?
  • How long is the resulting path?
  • What is the evidence that it "freezes here" and not elsewhere?

 

Overall, the code is way too complicated and convoluted. For example....

  • That huge construct to make the file name could be replaced with a simple format into string with a handful of integer inputs. SImplify!
  • Why does the event structure contain a local variable instead of just tapping into the new value event data node?
  • Where is the terminal for the Image and why are you writing to a local variable instead?
  • Where is the terminal of the boolean for the event structure? What is the mechanical action? Why not latch action?
  • That bundle/unbundle exercise just to determine execution order is silly. You could just use loop only the error wired through the frame.

 

 

0 Kudos
Message 6 of 8
(4,367 Views)

@Bob_Schor wrote:

I'm the Chief Complainer, but I hate pictures of Block Diagrams


Yet another chance for me to use this:

 

 

That image is a link describing what is a snippet, and how it can be used to upload pictures which have executable code in them.

0 Kudos
Message 7 of 8
(4,343 Views)

Thanks, Billko and Hooovahh, for the "votes of confidence".

 

Bob "Am I Really That Loud?" Schor

0 Kudos
Message 8 of 8
(4,327 Views)