LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Data from different loops saved in one single file

Hey there!

 

So I solved a problem that i had considering the sampling rate, by splitting one big loop into three seperate ones and it worked out

 

I was just about to test my sensor and then i realized, that the data of 2 loops dont get saved in the spreadsheet.... One problem solved the other one comes...

 

Screenshot (78).png

The only solution that i have in mind, is that every loop creates its own file.. so i have then basically 3 files for 3 loops... but isn´t there a smarter way?

 

Every kind of help is appreciated guys!😊

0 Kudos
Message 1 of 11
(2,294 Views)

Hi Jugo,

 

Idea would be to first make sure all the required data is transferred from your data acquisition loops to a 4th loop. which will periodically write data to a file.

 

If you want all data points collected, you can use Channels or queues to transfer required data. You can be smart about how many data points you want to read every iteration and write to a file. You can also store data in shift registers in the 4th loop and write data with further delay.

 

If you like to save data which can be lossy, then you can look into using FGVs or local variables (I would not prefer doing this)

 

Finally you can also look into creating subVIs to contain everything in a standard screen resolution. This will also help you clean up

your block diagram a bit and will help you be organized.

Message 2 of 11
(2,281 Views)
Jugo, To start with: here's the quick and dirty solution that you're probably looking for. Make each loop write it's own file, then when you stop running your program write a little routine to concatenate files together. ----------------------- Now, the "real" answer... and fair warning, the problem you're trying to solve here isn't trivial. Looking at your program there is a lot of requisite knowledge about LabVIEW programming fundamentals that you are lacking. In addition to some of the fundamentals, there are problems that I suspect you haven't considered yet. For example: your data for each loop will be coming in at different rates. If you just write data points as they come in, you will have discontinuous channels. TDMS file format can handle this, but it increases the size of the files greatly and won't be "human readable" like what you're currently doing now. First, you will need to figure out how to get the data all together in a single loop. There are many ways you can do this as a previous poster mentioned. Queues, FGVs, channel wires, DVRs, local variables, global variables, .... Each of these have their own uses and advantages/disadvantages and you will need to pick one. Searches for each of these terms "LabVIEW queues", "LabVIEW FGVs" should give good information. Next you will need to figure out your requirements for writing the file. Do you need to to capture every data point? Do you care if there is "jitter" in the timing of file writing, etc. Finally you will need to pick a file format that matches your needs. If you need to capture every data point, you're looking at probably looking at TDMS. Of course if you're then shipping this data off to someone else (engineer, customer) you need to make sure that the data is readable by them. Are they willing to install a TDMS converter, or do you need to convert it before sending? Would they prefer a different data format? If you don't need to capture every data point, you can pick a different file format. For example you could take all of your data as it comes in from loops, dump it into an FGV and then have another loop later that just writes it out in a spreadsheet once/second. This will absolutely miss data points, and there will be no guarantee about the age or timing precision of what you're writing to file, but it's probably the easiest to implement and would be sufficient for some applications. ----------------------- I'm not trying to discourage you here, but based on the code you posted you've got a bit of a learning ahead of you before you can "correctly" solve what you're trying to do here. If I were you, I would just implement the quick and dirty solution I proposed above, and next time you design a LabVIEW program take a look at some of the LabVIEW design patterns and pick one upfront.
Message 3 of 11
(2,262 Views)
Well, for some reason the webpage decided to strip the formatting from my above post. And not give me any options to edit it. I tried from three different computers on two different networks and three different browsers (Chrome, Firefox, Edge). So good luck mucking your way through the wall of text above. I'm so, so close to being done with NI for good. I'm a decent way down the path of becoming proficient enough with Python to completely make the switch.
Message 4 of 11
(2,242 Views)

If you want to save data from different loops to one file, we hopefully can assume that all loops run at the same rate. This also means that you could merge the code from all three loops into one loop instead. If the loops are not supposed to run at the same rate, you need to exactly define how the data is supposed to be merged into the file.

 

Currently, all your loops have very poorly define timing. You are still growing a string forever. A tab control with one tab does not need to be connected anywhere.

 

We already gave you advice how to simplify some of your code, e.g. lower the amount of dynamic data. (...  and no, having three different stop buttons is probably not the right way to do anything.)

Message 5 of 11
(2,217 Views)

@altenbach wrote:

If you want to save data from different loops to one file, we hopefully can assume that all loops run at the same rate.


No unfortunately they do not. I just checked and my sensor runs at roughly 165Hz but from my 2 NI Measurement cards (with these i measure my voltage/current) i get a rate of 4Hz. Which is weird. Maybe it is best just trying to make 3 different files...

0 Kudos
Message 6 of 11
(2,085 Views)

@Jugo wrote:

@altenbach wrote:

If you want to save data from different loops to one file, we hopefully can assume that all loops run at the same rate.


No unfortunately they do not. I just checked and my sensor runs at roughly 165Hz but from my 2 NI Measurement cards (with these i measure my voltage/current) i get a rate of 4Hz. Which is weird. Maybe it is best just trying to make 3 different files...


So, what is keeping you from using TDMS format?  Just write the data of each loop to the channel each loop records at whatever speed the loop spins at.  Jaw drop emoji!

 

Hey 2 of those acquisition loops are even DAQmx!!!!  You can simply enable DAQmx data logging and let DAQmx write those channels for you with NO ADDITIONAL CODE needed.


"Should be" isn't "Is" -Jay
Message 7 of 11
(2,078 Views)

@JÞB wrote:


So, what is keeping you from using TDMS format?  Just write the data of each loop to the channel each loop records at whatever speed the loop spins at.  Jaw drop emoji!


Yeah I use TDMS for separate sample rates.  Each Group in a TDMS file is its own sample rate.  If you are seeing some kind parallel access issue, you can even write to separate files, then perform a binary merge at the end to get a single file again.

0 Kudos
Message 8 of 11
(2,071 Views)

@JÞB wrote:

Hey 2 of those acquisition loops are even DAQmx!!!!  You can simply enable DAQmx data logging and let DAQmx write those channels for you with NO ADDITIONAL CODE needed.


Note that if you use the DAQmx Logging, which I highly recommend, the two tasks will have to log to two different files.  You can combine them afterwards.


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
0 Kudos
Message 9 of 11
(2,061 Views)

@crossrulz wrote:

@JÞB wrote:

Hey 2 of those acquisition loops are even DAQmx!!!!  You can simply enable DAQmx data logging and let DAQmx write those channels for you with NO ADDITIONAL CODE needed.


Note that if you use the DAQmx Logging, which I highly recommend, the two tasks will have to log to two different files.  You can combine them afterwards.


I'll have to try that but concurrent access should not be a problem. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 11
(2,055 Views)