LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Set number of files

Solved!
Go to solution

I created a vi to control a instrument, I would like to leave this instrument on indefinetly until I hit a stop button to turn off the instrument.

Also this vi saves data to a file.

 

I created a record button which starts recording a file, when that is done the file checks to see if the file the user orginally set in the file path is different then the output file if it's it stops saving data. But what happens is some data gets saved into another small file after it has written the #of samples I want, this is ok based on the way I have the code. Then the user sets another file path(which is different then the original path) and the program starts to save data again, but the new file which was created is short by the amount of data that was saved in the small last file.

 

How would I correct this issue of missing data in my new file, given the way I have written the code I know it will do what i'm seeing but I just need to know how to correct it.

 

I have attached my code for review. 

0 Kudos
Message 1 of 11
(2,697 Views)

 


But what happens is some data gets saved into another small file after it has written the #of samples I want, this is ok based on the way I have the code. Then the user sets another file path(which is different then the original path) and the program starts to save data again, but the new file which was created is short by the amount of data that was saved in the small last file.

 


I am not Clear about these sentences,Please explain me little more.

 

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 2 of 11
(2,691 Views)

But what happens is some data gets saved into another small file after it has written the #of samples I want, this is ok based on the way I have the code. Then the user sets another file path(which is different then the original path) and the program starts to save data again, but the new file which was created is short by the amount of data that was saved in the small last file.

 

Sorry about that, what I need to do is kindaa confusing.

 

If you download my attachment you will see the File saving VI is setup for accquiring  # of samples per file(50000) then stopping. What I do is read the file name the user writes into the path and compare this to the file name output of the vi(FILE NAME OUT signal), when this output changes and is different then the original file name(which it does after writing a new file) I stop the File writing VI. Then what happens is 1 Large file gets created(50,000 samples) but a smaller file also gets created, it seems like the enable signal on the File saving VI doesn't stop the VI right away because I get the smaller file. 

 

Let me know if this makes sense, thank you. 

0 Kudos
Message 3 of 11
(2,681 Views)

what do u mean by small file and large file,What u want to really do?. You are acquiring data and writing in a file.

 

1. Do u want to create a new file automatically for every iteration?

2. When you change the file path and why you changing the file path in the middle of the programme

3. If the file path is changed do u want to contiue the data to save in the new file?

4. Where u loosing the data,While changing the file path?

 

 

Message Edited by Baji on 06-11-2009 11:05 AM
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 4 of 11
(2,676 Views)

what do u mean by small file and large file,What u want to really do?. Large file is (50,000 samples) small file is (about 2000 samples). You are acquiring data and writing in a file.

 

1. Do u want to create a new file automatically for every iteration? Yes but only when the user wants to create a new file.

2. When you change the file path and why you changing the file path in the middle of the programme. The program is running that is correct but I change the file path name after the first file has been saved, so if user wants to save another file they need to specifcy a new path(that's the way I have my code written). 

3. If the file path is changed do u want to contiue the data to save in the new file? Yes 

4. Where u loosing the data,While changing the file path?Yes, what happens is the third file is smaller by the small file size.

 

Could you please run my Vi and you will see what i'm talking about. 

 

Also I need the VI to stay on all day because this also controls LEDS that need to stay on all day  due to warm up reasons. This code is on the top portion of my block diagram.

 

Steps to RUn:

1) Define a path with a dummy file with a .lvm extension in the path.

2) Run the VI

3) Hit record

4) When the file is done writting the green light turns off. This creates a file with 50,000 data points which I want but it also creates a small file with about 2000 points. Which I don't want.

5) The user then needs to define a new path to where a new file needs to be saved, when they do the file is created (The record button is still on). I get a Large file but it's missing 2000 points (50,000 (data points I want) - 2000 (Points that the small file had) = 48,000 points.

 

0 Kudos
Message 5 of 11
(2,668 Views)
I simulated ur application with a simple Vi try this Vi and tell me where u getting problem im not writting 50k datas just a single data.note down the numeric value while clicking the record button.
Message Edited by Baji on 06-11-2009 11:46 AM
Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 6 of 11
(2,663 Views)

Do u want to append the data to the file if already exists?

 

Use this VI

Balaji PK (CLA)
Ever tried. Ever failed. No matter. Try again. Fail again. Fail better

Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
0 Kudos
Message 7 of 11
(2,657 Views)

Hi Baji,

You have to place a dummy .lvm (such as data.lvm) extension file or it might be .txt extension (I'm not at work right now so I can't check the file extension i have in my code) in your directory path because that is what I look for otherwise it will just continiously keep writing files and not stop. Please look at my block diagram.  Also you have to make it around 50,000 data points otherwise it will not produce the same error i'm seeing. 

0 Kudos
Message 8 of 11
(2,657 Views)
No I don't necessarily want to append to the file because the user might want to save to a file at different times of the day.
0 Kudos
Message 9 of 11
(2,654 Views)

I just want to create 1 file at a time then stop until the user wants to create a new file, they do this by modify the path after the record light goes off.

 

Remember the VI should keep running to keep the LEDS on

0 Kudos
Message 10 of 11
(2,653 Views)