LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop to automatically change file path for writing continuously acquired data

HI Nathand and Olivia,

 

Thanks for your detailed input. The VI posted by Nathand above was identical to the screenshots posted by Olivia, except for one small thing.  This is that the pathname attaching to the shift register on the right hand side was attached to the output of the save block (on Nathand's) and bypassed this output on Olivia's.  This doesn't appear to make a difference to the way it write to file so thats great. I have set the append to file to "true" and the write header to "false, it seems to work well now. I am currently trying to implement some advice from a separate thread regarding a different way to decimate the data. (http://forums.ni.com/ni/board/message?board.id=170&message.id=401352&jump=true#M401352

 

One question - does this configuration mean that the  file is being opened and close on each iteration of the loop?

 

Thanks, 

Claire.

0 Kudos
Message 11 of 18
(1,184 Views)
Yes, which is why I suggested that eventually you should open the file once, in the true case, and store the file refnum in the shift register.  Make sure you close the previous file before opening the next one.  You can improve the efficiency a bit more beyond that if you know approximately how large your files will be by preallocating space for the file at the time you create it, using the Set File Size function.  If you don't know the exact size, make the file a bit too large, then use that same function to set the file size to the current file position just before you close the file.
0 Kudos
Message 12 of 18
(1,177 Views)

Hi Nathand, I've split up the standard Write waveform to spreadsheet VI and put some of it inside the loop and some outside. I've tried to put the "Close" block at the front of the True condition, with the idea that it closes the file before it opens the next one, but this is problematic because (1) in the first loop there is no file open yet and (2) I think it will close the file that was just opening, rather than the one previous. Can you  point me in the right direction?

Cheers, 

Claire.

0 Kudos
Message 13 of 18
(1,170 Views)

As for the first point about closing the file on the first loop iteration, I don't think anything will happen, but if it does generate an error, just use the "Not a Number/Path/Refnum?" function in the comparison to check that you have a valid refnum, and only close if the refnum is valid.  You should also wire a "Not a refnum" constant to the left side shift register to make sure that the shift register is initialized, and you should close the file outside the while loop as well (when the program ends) on the right side.

 

For your second point, you're misunderstanding either dataflow programming or shift registers.  Think about what value will be on the refnum wire when it flows into the Close function.  Despite this, it would be good practice to guarantee that the Close happens before the Open by using the error in and error out terminals to chain the VIs together.

0 Kudos
Message 14 of 18
(1,166 Views)

Thanks Nathand. Yes I did get errors for the close file on the first pass until I put in the check on the refnum (I think I've implemented what you described). I've added all the other things you said to. I'm not sure if the final Close (outside the loop) should be placed outside the prodcuer loop after the Stop Task, or outside the consumer loop adjacent the refnum shift register?

Thanks for your help, I'm excited to have something that works!

Cheers,

Claire.

0 Kudos
Message 15 of 18
(1,161 Views)

How to save data from VISA instrument automatically in different files for every iteration of FOR LOOP....?



0 Kudos
Message 16 of 18
(877 Views)

b412,

 

Try using a Write To Measuremen File VI in the Express Palette. You can wire in the data that you are trying to save to this VI and it will give you several options on how you would like to record it.

KyleP
Applications Engineer
National Instruments
0 Kudos
Message 17 of 18
(859 Views)

thank you sir...

0 Kudos
Message 18 of 18
(847 Views)