LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Logging

Hi everyone,

 

I'm creating an interface where I have to report cumulative energy spent. It cannot reset to zero every time the executable runs, kind of like the mileage on a car. How can I do this? Is this even doable? My idea is to log the data and then have labview maybe read the last value from the file when the executable runs and then continue to log data, and then save the last value for the next time to continue to log data.

 

Thank you,

Omar

0 Kudos
Message 1 of 18
(2,423 Views)

you can certainly use a file, make sure it's in a location where others won't have it open or your data write will most likely fail.  you could also use a database entry.  if you're crazy enough you could even use a Windows registry entry.

 

0 Kudos
Message 2 of 18
(2,382 Views)

Hi, 

You need to initialise a 'zero' using either property node, local variable, or a shift register with '0' input constant initialization so that every time the LabVIEW run again it set it to zero.

Convert your logged/read data in array spreadsheet form, and extract the last row of the array value using 'index array'. How to know which row is the last value?

You can use 'array size' to detect the first eg.7 and minus it with 1 using minus function and get 6 which is the last row since index calculate from zero.

It is recommended for you to convert string data in array form from file so it is easy to be extracted or analyzed later.

 

0 Kudos
Message 3 of 18
(2,345 Views)

I think a little more information about your program is appropriate. Are you already logging data? If so, how are you logging data? If not, is there a need to have a data log? If not then logging the data is a waste of resources and I would store a single value (perhaps in a cfg or xml file) and update that value as needed (this assumes that the required update rate is not too fast). You could, in theory, only write the value at shutdown, but I prefer to update these sorts of things periodically so that it is updated in the event of improper shutdown.

0 Kudos
Message 4 of 18
(2,337 Views)

@WaiLee wrote:

Hi, 

You need to initialise a 'zero' using either property node, local variable, or a shift register with '0' input constant initialization so that every time the LabVIEW run again it set it to zero.

If he doesn't want a 'zero' then why initialize to zero? And why go through such a tedious process even if he wanted a zero - if you want the default to be zero then just set the default value to zero? No need for property nodes or local variables in that case.

 


@WaiLee wrote:

Convert your logged/read data in array spreadsheet form, and extract the last row of the array value using 'index array'. How to know which row is the last value?

You can use 'array size' to detect the first eg.7 and minus it with 1 using minus function and get 6 which is the last row since index calculate from zero.


Once again this seems very convoluted. I'm assuming the OP would have a single column of data. To get the last value one can simply reverse the array and read the first value.

 


@WaiLee wrote:

 

It is recommended for you to convert string data in array form from file so it is easy to be extracted or analyzed later.


It would be much more appropriate to read the data as a numeric data type. Why use strings when a number is what you need?

0 Kudos
Message 5 of 18
(2,333 Views)

Like others have said, what your asking for is easily doable. Have you attempted to do this? If so, upload your VI and show us what you've done. We'll be able to provide help and assistance this way far better than offering suggestions without seeing any code.

0 Kudos
Message 6 of 18
(2,317 Views)

This is what I have so far, it's mostly the calculations. I have set up historical data to be an array of clusters which contains the cumulative data, however this resets at the end of each executable.

0 Kudos
Message 7 of 18
(2,304 Views)

i don't have any data logging implemented. This is also my first time doing it and i am very new to labview so I don't really know how to implement it. Ideally i would write the last value to a text file or write periodically but only store the last value so that it is easily read during start up to pick up where I left off.

0 Kudos
Message 8 of 18
(2,295 Views)

@falafes wrote:

This is what I have so far, it's mostly the calculations. I have set up historical data to be an array of clusters which contains the cumulative data, however this resets at the end of each executable.


Where is this array of clusters? I assume that since you're referring to historical data that you want to keep a historical record. I would recommend NOT doing this as an ever growing array. Since it looks like you're doing this once per second log it to file. If you do TDMS, for example, you could write the latest value to a property and store the two data points.

0 Kudos
Message 9 of 18
(2,293 Views)
  • Those are not an array of clusters. You have two scalar doubles in that cluster named Historical Data which is a Global Variable.
  • It looks like your overwriting your Discharged Kwh values in both the True and False cases. Is this what you want?
0 Kudos
Message 10 of 18
(2,290 Views)