12-08-2014 07:39 AM - edited 12-08-2014 07:40 AM
The biggest issue here is your logging of the data. Since you are streaming the data to disk, you should open/create the file before your loop and close it afterwards. Use the Write To Text File inside of the loop. This is a lot more efficient since the Write Spreadsheet File actually constantly opens and closes the file each time you write a value. This is SLOW. So by opening the file before the loop, you are skipping a lot of overhead and making the writing to disk a lot more efficient.
The other major issue is you need a clean way to stop your VI. Using the abort button in the toolbar is not a proper way to stop a VI. Create a stop button and use that to stop your loop.
12-08-2014 07:57 AM
Dear johnsold ,
Thanks to you.
I learn new ways from your answer. now Data save in specified text file.
I have 2 new question from you and will be appresiate from you.
1. I save my VI in a folder and I want whenever I run program, a new txt file created in same folder with new named (e.g. Channel1_1) and data saved in it. next time that I run program it create a new file which it's name be Channel1_2 and again in next times Channel1_3 , Channel1_4 , ......
2. How I can save a header in first lines of my specified text files and after that data save in normal like before saved. e.g. header file will be :
I want save two Constant sentences and in next line, date and time which in my VI has been run .
---Ajapyy---
---Data From LabVIEW---
---current time and date---
0.0012 // Data
0.132 // Data
is my question possible in LabVIEW ?
I found a block that get time and date , but I don't know haw I can append this information to txt file in mentioned approach.
Thanks.
12-08-2014 08:33 AM
thanks crossrulz,
your words is true, because finally I want to use this vi in other VI to save 4 Channel data in seperate text file and it will be so good if code be effiecent. in final VI data will come in datarate equal to 16 kHz ( each 62.5 us) and I want to save them in 4 seperate text file.
I designed this vi with my knoledge for append a header to txt file.
I will be wait for your suggestion. I will use your methode in my final VI for write data.
Thanks.
12-08-2014 08:57 AM
Stop using the Write Spreadsheet File. Use the Write Text File function to write your header information before going into your loop.
12-08-2014 09:06 AM
Dear crossrulz,
I use your suggestion and create another file with write to text file block, with your mind is it good and efficient ?
Thank you.
12-08-2014 09:09 AM
Use the output reference of the Write Text File. If you don't wire that up, it will actually close the file and then you will get an error. In general, file references should never fork.
And do some cleaning up. Avoid wire bends. Avoid letting your wires go right to left. Your code should flow left to right. You don't need that sequence structure at all since data flow will determine the sequence of what runs.
12-08-2014 09:26 AM
can you explain your last post more ?
I clean VI and result is :
have you any idea for my 2nd question ?
"1. I save my VI in a folder and I want whenever I run program, a new txt file created in same folder with new named (e.g. Channel1_1) and data saved in it. next time that I run program it create a new file which it's name be Channel1_2 and again in next times Channel1_3 , Channel1_4 , ...... "
12-08-2014 10:05 AM - edited 12-08-2014 10:08 AM
@ajapyy wrote:
can you explain your last post more ?
Which part? There was a lot mentioned there. Here's how I would clean up your VI even more.
ajapyy wrote:
have you any idea for my 2nd question ?
"1. I save my VI in a folder and I want whenever I run program, a new txt file created in same folder with new named (e.g. Channel1_1) and data saved in it. next time that I run program it create a new file which it's name be Channel1_2 and again in next times Channel1_3 , Channel1_4 , ...... "
Use the List Folder function to see how many "Channel1" data files there are and append the next number to the file name before creating the file.
12-08-2014 03:01 PM
It worked .
Thank you.