Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

can not save all the data when using DAQ6356

Hi all,

I meet strange problem using the DAQ6356 to measure and save data. The VI can just save the former few data while the latter part data are lost. Why it behaves like that?

I am using 2 while loops in the VI, I is for PID control algorithm and the other is for data saving. The sampling rate is 2000 and number of sample is 25. The VI did not report any error. However the data can not be completed saved in the Excel sheet. I have used the probe to read the data I want to save and the realtime data is all correct. it seems just that the data are not saved. Could this be caused by the setting of the sampling rate and number of samples?

I attached the VI for you reference.

Thanks

best

 

 

0 Kudos
Message 1 of 7
(4,805 Views)

Hi Iyearning,

 

It sounds as if the data is not stored correctly. I suggest you to try using a producer/consumer architecture to prevent possible loss of data as in the following community example:

 

 

https://decibel.ni.com/content/docs/DOC-2431

 

Additionally, it is not recommended to use big flat sequence structures in your code. I would suggest you to consider using a State Machine instead. I hope the example above is useful to you.

 

Regards,   

 

K. 

0 Kudos
Message 2 of 7
(4,775 Views)

Dear K.

Thank you so much for your suggestion. I will try to modify my code based on state machine.

For the data storage, excel loop will run slower than PID loop such that some data is held in the queue. So I think the reason of missing data is due to the sequence of stopping the loop. The way I stop the loop is immediate. When I press the stop button, I clean up and release the queue. The data in the queue that not consumed by excel will be released.

How can I save all the data in the queue before release it? Can you give me some instruction on that?

I attached some simple VI for your reference.

Thanks so much!

best

0 Kudos
Message 3 of 7
(4,761 Views)

First thing I would do is change the data type in the cluster to a 2D Array.  It will make things a little simpler.  So what I do in my systems is create a command of sorts telling the consumer that it has consumed all of the data.  In this instance, I like to use an empty array.  So after you hit the stop button, the producer loop stops, and then you immediately send and empty array in the queue.  In the consumer loop, you just check the data after your dequeue to see if it is an empty array.  If the array is empty, stop the loop.  It will then be safe to release the queue.


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 4 of 7
(4,748 Views)

Dear Proven,

Thank you for your kind reply. It does solve my problem. However, it takes a lot of time to dequeue all the elements. Could you please tell me if there is any way to increase the processing speed of the dequeue loop?

BTW, you recommend me to use array instead of the cluster. In my case, I need to manipulate each element of the cluster separately. If I use array, I need to index the 2D array to get each column for manipulation. Which way is more efficient? It seems the cluster is more efficient to bound and unbound element.

Thanks

best

0 Kudos
Message 5 of 7
(4,725 Views)

Hi Proven,

I attached the simplified VI I am using. In the actual situation, I will manipulate each element in the cluster for complex calculation. When I press stop, it takes several minitues to finish the dequeue process as there are around 100,000 data measured. it is not the case when I using low frequency loop, like 10 Hz (right now I am using 80Hz measuring loop, and the overall size of measured data is similar), where everthing is done very fast. Is there anyway to increase the speed?

Thanks

Best

0 Kudos
Message 6 of 7
(4,724 Views)

Why not just save the data in binary format (.tdms)?  It's very fast/reliable and results in smaller file sizes.  It is also easier to program as you can just configure it through the DAQ Assistant and the producer/consumer architecture becomes unnecessary.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 7
(4,714 Views)