LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write waveform data in txt file

Solved!
Go to solution

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.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 11 of 19
(1,586 Views)

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.

l5.png

Thanks.

0 Kudos
Message 12 of 19
(1,581 Views)

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.

wer.png

Thanks.

0 Kudos
Message 13 of 19
(1,575 Views)

Stop using the Write Spreadsheet File.  Use the Write Text File function to write your header information before going into your loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 19
(1,566 Views)

Dear crossrulz, 

I use your suggestion and create another file with write to text file block, with your mind is it good and efficient ?

write.png

Thank you.

0 Kudos
Message 15 of 19
(1,561 Views)

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.

 

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 16 of 19
(1,558 Views)

can you explain your last post more ? 

I clean VI and result is :

write2.png

 

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 , ...... "

0 Kudos
Message 17 of 19
(1,551 Views)
Solution
Accepted by topic author ajapyy

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 18 of 19
(1,533 Views)

It worked .

Thank you.

0 Kudos
Message 19 of 19
(1,515 Views)