LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sample saving

Solved!
Go to solution

Hi guys

 

I have app, when i read from sensor. I want my sample save in .csv file.

 

Yaamamoto_0-1583825487520.png

Saving is in while loop with reading from sensor.

But always i get :

 

Yaamamoto_1-1583825628363.png

 

Data is always overwritten on same line.

 
If i want get time stamp to every sample i need my array with values unite with time stamp?
Is possible in LabVIEW treat for some reason malfunction of communication? (I mean, if sensor stop workings, i need get data like xFF still write on my csv.file)
 
Thank you for your ideas.
 
0 Kudos
Message 1 of 14
(2,889 Views)

HI Yaamamoto,

 

when you want to append data at the end of the file you need to set the file position to the end of the file after opening it…

 


@Yaamamoto wrote:
If i want get time stamp to every sample i need my array with values unite with time stamp?
Is possible in LabVIEW treat for some reason malfunction of communication? (I mean, if sensor stop workings, i need get data like xFF still write on my csv.file)

You can also format the timestamp to text and concat strings before writing to file.

You can handle any malfunction as you like - you only need to create your program as needed by your requirements…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 14
(2,877 Views)

If you're doing this inside a loop, you should usually open the file before the loop and close after, and keep a file reference inside a shift register for the Write operation.

This will automatically keep the cursor at the end.

 

If you have to open and close repeatedly, then you'll need to use Set File Position as GerdW said.

You can see this link for more details: Append to a Text or Binary File in LabVIEW 

 

This is copied from the 2nd link and explains a bit more (copied here for ease of reference):

 

When a file is opened in LabVIEW the cursor is set to the first position in the file. When a Read Text File or Read Binary File function is used it scans the full file and subsequently moves the cursor through the file to the end and so when a write occurs after that it will do it from the end. 


GCentral
0 Kudos
Message 3 of 14
(2,850 Views)

Thank you.

 

I tried get timestamps to samples, but Humidity is never written.

Yaamamoto_0-1583835137570.png

 

I connect timestamps :

Yaamamoto_1-1583835282855.png

 

0 Kudos
Message 4 of 14
(2,842 Views)
Solution
Accepted by topic author Yaamamoto

With that image, it seems like you'll be missing a delimiter.

Add an additional input to Concat Strings in the middle and wire a ";".


GCentral
Message 5 of 14
(2,839 Views)

I have a question and have a different issue. I attached the code I have. I used to program in LabView, (2003), totally forgot how to solve my issue. Thanks for having time to look at it.

 

I am trying to save a set of data collected. I need to plot the data vs time. Time should be in seconds, or milliseconds. The problem is that when I save it, it saves either in Year/Month/Date/... format, or something which is given in the picture below. What I want is to save the data in seconds, instead of changing the format in CSV file in excel.

 

Thanks for assisting.

Best, S

Download All
0 Kudos
Message 6 of 14
(1,324 Views)

Hi inst,

 


@inst_soleil wrote:

I am trying to save a set of data collected. I need to plot the data vs time. Time should be in seconds, or milliseconds. The problem is that when I save it, it saves either in Year/Month/Date/... format, or something which is given in the picture below. What I want is to save the data in seconds,


It's all your fault! You are saving "complete" timestamps in the first column - and you are using Excel to look at them…

 

When you want "just" elapsed time since start of measurement then you should save that value instead.

Do you know how to measure the (elapsed) time since start?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 14
(1,313 Views)

Hey GerdW,

 

I appreciate your comment.

 

Agree with you, and I don´t know how to correct it. Do you have any guidance that can help me to correct the program?

 

Thanks for your time and effort.

0 Kudos
Message 8 of 14
(1,299 Views)

Hi inst,

 


@inst_soleil wrote:

Do you have any guidance that can help me to correct the program?


Right now there is a "sample time" timestamp, formatted as an absolute time string.

You need to replace that by a relative time (aka "difference between sample time and time of start of measurement") and you need to change the formatting of that relative time value to suit your requirements…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 14
(1,295 Views)

I couldn't  make it. The elapsed time

 

It is not counting or saving to the file. Am I connecting the wrong wire? Or do I need to use Shift register?

0 Kudos
Message 10 of 14
(1,262 Views)