06-10-2009 10:19 PM
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.
Solved! Go to Solution.
06-10-2009 10:34 PM
06-11-2009 12:07 AM
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.
06-11-2009 12:30 AM - edited 06-11-2009 12:35 AM
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?
06-11-2009 12:58 AM
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.
06-11-2009 01:14 AM - edited 06-11-2009 01:16 AM
06-11-2009 01:26 AM
Do u want to append the data to the file if already exists?
Use this VI
06-11-2009 01:26 AM
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.
06-11-2009 01:28 AM
06-11-2009 01:29 AM
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