09-08-2014 02:38 AM
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
09-09-2014 10:01 AM
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.
09-10-2014 08:58 PM
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
09-11-2014 05:12 AM - edited 09-11-2014 05:13 AM
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.
09-11-2014 10:30 PM
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
09-11-2014 11:07 PM
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
09-12-2014 12:02 PM
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,