From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

this program ask for choosing a file each cycle....why ?

I tried to log data to file using NI 6001. I used the write  measurment  to file assistant. But why it asks for choosing file each cycle?

 

Thanks for your help

0 Kudos
Message 1 of 3
(2,269 Views)

If you want all of your data to be written to a single file, why do you generate a different file name each time through the loop?

 

Are you hoping to learn enough LabVIEW to actually be able to use it for "useful" projects?  If so, stop using Express VIs and learn to use the file I/O functions, DAQmx functions, etc. as they give you far more "obvious" control of actions.

 

Bob Schor

0 Kudos
Message 2 of 3
(2,237 Views)

@dragon-long wrote:

I tried to log data to file using NI 6001. I used the write  measurment  to file assistant. But why it asks for choosing file each cycle?

 


First of all, you have a race condition because the reinit method runs in parallel to the other code and there is no way to tell what executes first. It also interferes, for example if you enter a path name before starting the program, it will get possibly erased, again depending if the terminal is read before or after the reset.

 

Second, you needs to wire the path across the other case of the case structure, else it gets reset to an empty path.

 

Third, you are building an infinitely (and illegal!) long path with each iteration. If you want all files in the same place, you need to strip the old filename before building the new one.

(ex. you start with mypath/1, but the next file with be mypath/1/2, then mypath/1/2/3, etc. i.e. you are treating an existing file as path, which creates a conflict.

 

Also, concatenating a string does not do anything useful and just returns the input. delete that function. There is a +1 primitive but there is also the iteration terminal that provides the same count information, so use that (no need for a shift regsiter and all that code!). Of course it would make more sense to only increment when you are actually writing a file, but that requires more changes. Counting should use integers, Why are you doing it in orange? All terminal should show the label in the diagram (e.g. start logging), for code readability. Leave the stop terminal in the lower right. No need to have it criscrossing the other code. Keep it clean! SInce the logging buttons is switch action, it should bel called "logging", not "start logging".

Message 3 of 3
(2,231 Views)