LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"open file" vi doesn't work in executable

 

I have built an executable that reads a com port and displays the readings in a chart.

 

The vi also has a "start logging" button that uses the "open file", "write to file", and "close file" vi's, and it works on the machine with labview installed on it.

 

When saving it as an executable and executing it on a clean PC, I can select the com port, I can see the graph working, and when I start logging, I can select a new filename.

 

However after closing the file, and opening it in a text editor, there is nothing in the file.  So I think there is a problem with the "write to file" vi.

 

 

 

I tried this both in LV 8.5 as well as 7.1 with the same results. Any ideas? I have Visa and Run-time running on the clean PC. Are there any other drivers that I need to run on the host PC?

0 Kudos
Message 1 of 13
(3,677 Views)

Without seeing your VI, we can only guess at what may be wrong.  Are you using relative file paths?  If so, look at Why Does My Executable Not Work When Using the Current VI's Path Constant?

0 Kudos
Message 2 of 13
(3,671 Views)

Attached is the VI. It does not link to anything as far as I can see.

 

When running it, there are no errors, it just doesn't write anything to the file.

0 Kudos
Message 3 of 13
(3,663 Views)

Hi!

Please note that Labview no longer supports Open_Create_Replace File.

Try using Open File instead.

Moreover: do you get any error from file operations? (Indicator Error out 2)

Why do you set prepend array or string size? to false?

 

Marco

 

0 Kudos
Message 4 of 13
(3,648 Views)

 

 

Ah... I didnt know that "open_create_replace_file" was no longer supported.

 

When I save the file in 7.1 and open it in 8.5 it changes a few things without telling me, and I didnt notice the changes.... it changed the write_to_file function into a write_to_binary function. So the information is there, but I am opening it as a text file in notepad, so I can't see anything. Also, no errors pop up, so that led me to believe it was a runtime or visa fault. Or some sort of file handling fault.

 

I'll change the functions around in 8.5 and see if it works!

 

 

0 Kudos
Message 5 of 13
(3,618 Views)

What are you actually trying to log?  The only file functions I see write the string control out to a log file.  By default it is empty.  And the string control on the front panel is off the bottom.  So it looks like you are just writing a carriagereturn/linefeed character every second, which wouldn't really show up in notepad all that well.

0 Kudos
Message 6 of 13
(3,610 Views)

 

 

There is a data_to_be_logged local variable that is getting logged. It's a string that is generated by the left hand while-loop.

 

In practice the string is four temperature sensor measurents and date time stamp.

 

Cheers for the help.

0 Kudos
Message 7 of 13
(3,604 Views)

Where?  In the VI you posted in reply #3?

 

I don't see any local variables anywhere in your VI and I don't see anything by the name "data_to_be_logged".

 

Are you sure you posted the correct VI?

0 Kudos
Message 8 of 13
(3,597 Views)

 

 

Oh, sorry. Updated it now. Must have been working on that when I saved and uploaded.

0 Kudos
Message 9 of 13
(3,590 Views)

You have a lot of problems with your VI:

  • Lousy architecture. You have 4 loops. That's 3 too many. You only need one loop. The code that does the data logging should be in the main (and only) loop.
  • Do not open and close VISA sessions every time you iterate. Open once. Close once.
  • Do not open and close files every time you iterate. Open once. Close once.
  • You do not need to write to an indicator and to a local variable at the same time. A local variable is not a separate entity from a control/indicator - it's the same thing. Thus, the write of the local variable is superfluous. Besides, if you were to correctly code this to use only one loop you wouldn't need the local variable in the first place.
  • Why are you creating dynamic data from a set of 4 floating point values? Use Build Array to create an array. Charts and graphs do not require you to use dynamic data.
  • Identical labels. You have four controls called "Current Temp °C". If I mentioned the "Current Temp °C" control, would you know which one I'm talking about? Make your labels distinct. Use captions if you want the text on the front panel to say the same thing. 
  • I don't know if that serial stuff is a by-product of you opening an old VI in 8.5, so I don't know what that SetSerialTermChar VI is supposed to be. You should look at the serial port examples that ship with LabVIEW for updated VIs.

That's it for now....Smiley Wink

0 Kudos
Message 10 of 13
(3,582 Views)