From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logging Data using Queues

Hi,

I want to log measurement data using queues.

The queues seem to work fine with the measured voltage signal. However, in addition to the measured voltage , I want to store another column which is let's say constant 5 for the whole time the code is running.

I tried to do this as in the VI posted, but I only get the 5 every now and than in the file, all other times, it's 0. This makes a little bit of sense, as I think during one loop iteration, more than one measurement value is created (?). Not sure if that is the reason..

I hope the problem is clear

 

 

Thanks for any hints on how to solve the issue.

 

Regards

jack

0 Kudos
Message 1 of 8
(2,597 Views)

The number of columns in a 2D array is the same for each row. The row with the smaller number of columns will be padded with the default value. If the measurement array has five elements then the constant '5' array will be 5,0,0,0,0.

 

Put this in your upper loop.

 

Example_VI_BD.png

=====================
LabVIEW 2012


0 Kudos
Message 2 of 8
(2,585 Views)

Just to be clear the build array with 1,2,3,4 is obviously for illustration and you don't need it Smiley Happy

=====================
LabVIEW 2012


0 Kudos
Message 3 of 8
(2,576 Views)

Thanks for the hint, that solved the issue!

However, in my actual program, not the stripped down version I posted, it almost works fine, but in my measurement file I get (randomly) rows of 0 for all columns:

 

99999.000000    18.007537    0.039616    0.000000
99999.000000    18.007537    0.033613    0.000000
99999.000000    18.007537    0.032973    0.000000
99999.000000    18.007537    0.044816    0.000000
99999.000000    18.007537    0.036829    0.000000
99999.000000    18.007537    0.045051    0.000000
0.000000    0.000000    0.000000    0.000000
99999.000000    18.007537    0.039986    0.000000
99999.000000    18.007537    0.057114    0.000000
99999.000000    18.007537    0.032430    0.000000
99999.000000    18.007537    0.039107    0.000000
99999.000000    18.007537    0.037108    0.000000
99999.000000    18.007537    0.034194    0.000000.

 

Not a huge problem, but not very nice...

Any hints? Thank you for the help.

0 Kudos
Message 4 of 8
(2,564 Views)

I'm not sure what is going on. Is the 99999.000000 value the constant, the one that was 5 in your example? If so you could put your enqueue in a case structure and only enqueue if that is not zero.

=====================
LabVIEW 2012


0 Kudos
Message 5 of 8
(2,547 Views)

Yes the 9999 is fine, all the values are as they are supposed to be, just the row of zeros is confusing, it occurs at random points during the measurement, lets say every 20-30 values.

Strange. I could use a case structure, but I'd rather find the cause for the problem as I might "miss" one set of data.

Hm...

0 Kudos
Message 6 of 8
(2,541 Views)

I think that the problem with the zeros in your measurement file is caused by the following reason:
You use the "DAQmx Read" inside a while loop with no timing. It is possible that you want to read new samples, but there aren't any new samples. In this case, you will receive an array with zero entries from the DAQmx Read VI. In this case, you add an constant to this empty array, which will probably cause this behavior.
I would try the following solution: If the array returned by the DAQmx Read VI is zero, don't enqueue the data. If the size of the array is bigger that 1, enqueue the data like now. Also, you should add a little timing in the while loop, like 10ms or so. That should solve the problem.

0 Kudos
Message 7 of 8
(2,510 Views)

Thanks for the hint.

I will give it a try and post the results. Right now, I use a "simulated device", maybe that causes a problem? Timing the producing loop with 10ms did not solve the issue.

 

Regards

 

0 Kudos
Message 8 of 8
(2,508 Views)