LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of excel File: write to measurement File timestamp

Solved!
Go to solution

Hello,

I have a Problem regarding to Write Configuration file and time consumption. I am reading measurements from different devices (4 x ni6008 rate 1250Hz, continuos samples, 100 samples/channel;  cDAQ9174, using as a ) so at the end I have 50 measurements in every iteration of the loop. I checked how much time every device Needs to read in the channels and the "slowest" Needs Maximum 300ms (between 280-290ms), the other devices are quite fast (10ms). I have also inside the loop a elapsed time block (sometimes I want 1 Minute of measurements, sometimes 1h) and I want to log These measurements into an Excel file

 

I would like to have These measurements, at maximum, every 0.5s (if it is faster, better, but I guess the Maximum for my Hardware configuration is 300ms) stored in an Excel file, with the timestamp, and I am using Write to Configuration file.

 

The Problem I have is: The first second of the measurements, I write data every 0.3s, and after that, every second. If I Change the time of the loop, doesn´t matter, first second I log data every 0.3 and then every second (you can see this behavior below, untitled is the time of the loop, in minutes). Why this Change of Speed of writing? Is a Problem of open/Close the Excel file in every Iteration of the loop? if it is this Problem, why I can write so fast at the beginning?

Is a Problem of the reading from the devices? The configuration of the Analog 1D DBL NChan 1 Sampl is timeout to -1, but I am not sure "how to Play" with this Parameter. I define the channels of the devices much before than coming into the loop, could be that the Problem that then the devices wait until they get the 100Samples?

(from the help: timeout specifies the amount of time in seconds to wait for samples to become available. If the time elapses, the VI returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to -1, the VI waits indefinitely. If you set timeout to 0, the VI tries once to read the requested samples and returns an error if it is unable to)

 

Should be 0 and put lower samples per channel?

 

Thanks in advance

 

 

Here the output excel

Time Untitled Untitled 1 Untitled 2
08.06.2017 16:33:41,249 10 0 0
08.06.2017 16:33:41,528 10 0 0
08.06.2017 16:33:41,788 10 0 0
08.06.2017 16:33:42,049 10 0 0
08.06.2017 16:33:42,388 10 0 0
08.06.2017 16:33:43,389 10 0 0
08.06.2017 16:33:44,389 10 0 0
08.06.2017 16:34:16,384 11 0 0
08.06.2017 16:34:16,631 11 0 0
08.06.2017 16:34:16,922 11 0 0
08.06.2017 16:34:17,387 11 0 0
08.06.2017 16:34:18,388 11 0 0
08.06.2017 16:34:19,387 11 0 0
0 Kudos
Message 1 of 13
(5,152 Views)

Can you share your VI? It seems likely there might be a small problem you're overlooking.


GCentral
0 Kudos
Message 2 of 13
(5,126 Views)

Sorry for the delay,

Here I attach the file with the part of the code where is this behaviour, I removed parts before and after the code which will not affect this part.

I don´t know why the behaviour explained above (first second I write in the file every 0.3s; then I write every second). More or less before I turn on fan and I do some settings, but it does not affect this part (sequentiell execution). After the set up is done, I want to do some measurements, so I attach only the code of the measurements, not how I turn on the fan.

I want to have data, as maximum, a value every 0.5s; if it is faster, better. How can I do it? I tried to change the sampling rate and the samples for channel...

Thanks in advance

0 Kudos
Message 3 of 13
(5,087 Views)
Solution
Accepted by topic author sarcanji

Saving in Excel is slovly, espessialy if close file every time. I make a big 1D array, make it 2 dimansion and than move it in excel in "value2" property of region.

0 Kudos
Message 4 of 13
(5,076 Views)

@sarcanji wrote:

Sorry for the delay,

Here I attach the file with the part of the code where is this behaviour, I removed parts before and after the code which will not affect this part.

I don´t know why the behaviour explained above (first second I write in the file every 0.3s; then I write every second). More or less before I turn on fan and I do some settings, but it does not affect this part (sequentiell execution). After the set up is done, I want to do some measurements, so I attach only the code of the measurements, not how I turn on the fan.

I want to have data, as maximum, a value every 0.5s; if it is faster, better. How can I do it? I tried to change the sampling rate and the samples for channel...

Thanks in advance


Like 0Forest0 expressed, the Write to Measurement file is probably slowing your loop quite a lot. However, you're also using a lot of unnecessary Dynamic Data Type conversions - you can just use the arrays, which will save at least some time, and more importantly, you're making 1 measurement per channel per iteration. You'll likely have more luck with a larger number of points per channel (this isn't controlled by the "samples per channel" input - that controls the buffer size for continuous samples).

 

You should change the DAQmx Read VIs to be "N channels N samples", then set the number of samples per channel to something larger than 1. Then, go ahead and reorganise the data manipulation inside the loop to match the new datatype. Try to avoid using lots of DDT conversions - these often cause unexpected problems, for example by setting dubious sampling rates (this might not affect you, but still, the arrays are clearer and won't do things you don't expect).

 

Once you've increased the number of samples per measurement, the loop won't need to run so unbelievably quickly, and the chances of you being able to get a reliable sampling is much higher. You might even be able to keep the Write to File inside the loop (although I wouldn't recommend it - a shift register or concatenating output is probably a better choice).


GCentral
0 Kudos
Message 5 of 13
(5,066 Views)


You might even be able to keep the Write to File inside the loop (although I wouldn't recommend it - a shift register or concatenating output is probably a better choice).

A producer-consumer topology will let him use the Write To File (Express VI) with no problems. However,  I think concatenating the output and writing only once to the excel file is a good way as well, if it is ok for him to write only once at the end.

0 Kudos
Message 6 of 13
(5,054 Views)

Thanks for your answers, i will check and I will inform you if I achieve the desired Performance.

 

I will Change first to Nchannels / Nsamples and I will check how it works.

 

I have to see every device independently (and all the associated signals) that is why I have the merge signals block and then the chart... and then I want to log all the signals in the Excel, so I thought I have to use that block. What do you propose to avoid that? Using the "Analog 2D DBL NChan NSamp" block and only one merge block at the end?

 

I will also try to create an Excel file and write in every Iteration of the Loop, after the Loop, I will Close the file (I think Í will save time too), but I would prefer keeping "log into measurement file"

 

Thanks in advance

 

0 Kudos
Message 7 of 13
(5,032 Views)

If you do not mind, I give another advice: just skip those Express VIs, and even saving to Excel/or ASCII files!

 

TMDS files for data management are just superior over what the above approaches can provide you. In terms of speed (Read/Write), database management, data structuring, etc...

Moreover, you can install a free plugin for Excel, so you can directly open TDMS files into Excel...

0 Kudos
Message 8 of 13
(5,023 Views)

Hello,

is still not working as desired, now I have 10 or 100 measurements with the same time stamp (and I want only one measurement from every line from every device), and after a while, the time stamp starts writing as before, every second... What I am doing wrong?

0 Kudos
Message 9 of 13
(5,010 Views)

Probably is not clear my problem:

I have 6 devices (4xni6008 + 2xni9401). I am want to read different paramenters from 8 inputs in every device + two values more. I need to write the values I am reading at minimum 2measurements per second.

The problem I have, the devices and the excel start writing quite fast (0.2 or 0.3 s) in the excel, and after a while (usually one second) I have a measurement every second, so it is much slower...

I need a value from every channel from every device and with a single time stamp (with the Nsamples N channels reading I got as many samples as I indicate as parameter but in one time stamp, and I don´t need it) and I need an excel file at the end (that is why of the write to measurement file and the casting to Dynamic data). 

The VI is above 

0 Kudos
Message 10 of 13
(4,999 Views)