LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save data to a file

Hi everybody, I am having some problems in my labview code,

I am runing a Triax320 from Horiba and I want it the program to save a file with the data from it every time it takes data. I want it to put the data files all in the same folder and with the date and time as file name.

I have managed to add the saving part to my code but, I get a promp every time asking for the file name and the folder.

Obviosly I am doing something wrong but I don`t know how to solve this problem.

Can you help me please?

I am attaching a jpg image of the code and the vi.

Thank you

Download All
0 Kudos
Message 1 of 9
(3,977 Views)

Hi Laura,

 

- clean up your VI

- delete local variables and replace them by wires - especially when the terminals aren't used anywhere else!

 

I have managed to add the saving part to my code

I guess you talk about this code in the frame you show in your image!?

You are saving data from "Collected Data 2" indicator, but this indicator doesn't get any data written to!

Did you just copy the code (without knowing what you are doing here)?

 

I get a promp every time asking for the file name and the folder.

Which function is asking your for that data? Did you try to debug your VI?

 

Obviosly I am doing something wrong but I don`t know how to solve this problem.

You can solve it by learning LabVIEW! 😄

Most important advice: THINK DATAFLOW!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,963 Views)

Dear GerdW,

Obviously you think you are really smart and funny, making fun of a new person trying to learn a new programming language, but you are´t

If I am asking for help maybe is because I need it.

The VI I am sending is a part of a bigger VI. That is the reason why there are "terminals that aren´t used anywhere else!". Also, the "Collected Data2" is not collecting the data as is part of a different VI.

Anyway, all of that is not helping me with the question I am asking.

In the part of the code I am showing in the image, I am asking the program to save a file. My only concern is that I want to save it in an specific folder with a specific name and that the part I am asking for help.

I did not "copy the code without  knowing what I was doing here", the code is bigger than the piece I am showing you and I wanted help with a specific point.

 

0 Kudos
Message 3 of 9
(3,934 Views)

Hi Laura,

 

as you didn't answer my question I will repeat it:

I get a promp every time asking for the file name and the folder.

Which function is asking your for that data? Did you try to debug your VI?

 

The VI I am sending is a part of a bigger VI. That is the reason why there are "terminals that aren´t used anywhere else!".

You should mention such things when you attach a VI. We can only analyze VIs with the information you provide!

 

Also, the "Collected Data2" is not collecting the data as is part of a different VI.

Then how do you transfer the data?

 

In your VI you read a key from an INI config file and use the content of that key as input for OpenFile.

Did you check the correct reading of the key?

 

making fun of a new person trying to learn a new programming language

I'm not making fun of you - all those comments are meant serious! (Keep in mind the limited information you gave about this VI.)

Did you check the content of the key?

Did you debug your VI? (I have to ask again…)

 

making fun of a new person trying to learn a new programming language

I'm not making fun of you - all coments are meant serious! (Keep in mind the limited information you provided.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(3,929 Views)

Create File path Control or File constant and browse for path and connect to Open Create Replace Vi and see if it works.

 

Edit: All the previous comments by GerdW are to help you of the upcoming pitfalls you might face in future (Been there done that).

Thanks
uday
Message 5 of 9
(3,919 Views)

Dear GerdW,

I would try my best answering your questions:

  • Which function is asking your for that data? Did you try to debug your VI

There were no bugs in the code (as far as I understand, it had a white arrow, not broken grey one), so the code was working as it was ment to, the problem was I wanted it to do something different.

I tried to get rid of the local variables where possible and clean up the code, the result is much more clear.

The function asking for data (file name and location) was the "open_create_replace File.vi" as the prom terminal was connected to a string asking for it and the folder path was not determined.

  • I appologize for not saying this VI was a sub-VI in a bigger one. I thought it was going to be obvious one the VI was open and some of the sub-VI were going to be missing. I´ll try to be more clear in the future about this point.
  • The "Collected Data" is a local variable conected to the spectrometer VI that is not attached in a different part of the code (2nd stack in the stack secuence of the 3rd structure in the Event Structure on the 2nd main Stacked Secuence of the VI), while I am triying to save the data on the 3rd stack in the stack secuence of the 3rd structure in the Event Structure on the 2nd main Stacked Secuence of the VI.
  • About the key, I have not idea what was it, so I have deleted it. everything seems to work if that part of the code is deleted ( I copied that from another part of the code)
  • I have change some things but I have some errors now. I am attaching the VI (that show some errors if is not connected to the spectrometer, that is something I have done so we can have the same errors) and three pictures.
    • In the first, "saving2.jpg" the part I have problems with can be shown, so it is easier to get into that part (3rd stack in the stack secuence of the 3rd structure in the Event Structure on the 2nd main Stacked Secuence of the VI)
    • In the second, "saving3.jpg" the first error I get (1059) on the "Open\Create\Replace File.VI".
    • In the third, "saving4.jpg" I get another error (1) on the "Write to text File.vi"

I would realy apreciate your help.

Best regards,

Download All
0 Kudos
Message 6 of 9
(3,897 Views)

And the promised VI attached

0 Kudos
Message 7 of 9
(3,896 Views)

Dear Udka,

I have tried creating a file path constant as suggested (can be seen in my previous post) but I hasn't work completely.

0 Kudos
Message 8 of 9
(3,893 Views)
It requires file path not folder path.
So you should be giving C:\Users\LocalAdmin\Documents\DATA\ABC.csv
Thanks
uday
0 Kudos
Message 9 of 9
(3,887 Views)