LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-time display at high data acquisition rate with continuous saving

Solved!
Go to solution

After having some issues with LabView 8.5 and simulating a device with the supplied MAX, I can now present you the code, using queues. Please look at first only at the "false"-case, which does not have an averaging function.

 

I have several questions concering my example:

 

1. Is that the way to allocate memory for the queue? I read to fill and then flush it, but I am not sure how trustable this information was.

2. Do I need these two queues or can I equivalently use only one as the data type is the same?

3. I rather need a XY-Chart than a XY-Graph, but how can I do this with a 2D-array? If I use shift-register and then build array, I will get a 3D-array..

4. Does the "open file" take too much time? It would be convenient to change the file destination while the program is running (as it is possible with the old program).

5. If I want to get the average, do I have to take the average of the number of samples the daq-read-function generates or can I use for example 200 points for averaging(but then averaging twice, like I aimed at in my example in the true case), but read out 400 points? I am not sure how long the averaging and followoing display/saving takes and I don't want to slow down my consumer case too much..

 

Thank you again for your kind help. I am sorry that I have so many questions!

 

Best wishes,

 

Mr KSE

0 Kudos
Message 11 of 17
(1,757 Views)
Solution
Accepted by topic author MrKSE

@MrKSE wrote:

After having some issues with LabView 8.5 and simulating a device with the supplied MAX, I can now present you the code, using queues. Please look at first only at the "false"-case, which does not have an averaging function.

 

I have several questions concering my example:

 

1. Is that the way to allocate memory for the queue? I read to fill and then flush it, but I am not sure how trustable this information was.

2. Do I need these two queues or can I equivalently use only one as the data type is the same?

3. I rather need a XY-Chart than a XY-Graph, but how can I do this with a 2D-array? If I use shift-register and then build array, I will get a 3D-array..

4. Does the "open file" take too much time? It would be convenient to change the file destination while the program is running (as it is possible with the old program).

5. If I want to get the average, do I have to take the average of the number of samples the daq-read-function generates or can I use for example 200 points for averaging(but then averaging twice, like I aimed at in my example in the true case), but read out 400 points? I am not sure how long the averaging and followoing display/saving takes and I don't want to slow down my consumer case too much..

 

Thank you again for your kind help. I am sorry that I have so many questions!

 

Best wishes,

 

Mr KSE


I am unable to open your VI, so I can't address all of your questions.

 

1.  If you have a Queue and start to fill it, LabVIEW may need to stop and allocate memory for the Queue.  If maximizing the speed of throughput for a finite length queue is paramount, you can avoid the possible loss of time should more memory be needed (for example, you specify a Queue length of 100, 10 elements are initially allocated, but while using the Queue, you need room for 10 more entries, so additional memory must be allocated to the Queue).  You do this by creating the finite-length Queue, fill it (which does all the allocation necessary), then flush it (which empties the Queue but doesn't deallocate its memory).  I, myself, have never needed to do this, though it is a good technique to know about.

 

2.  Can't answer.

 

3.  If you have a Chart, then you can input the points one at a time.  Just put each point into a Queue and "feed" the Chart from a Dequeue of the individual points.  [Note that this is without seeing your code -- there may be another, better, answer].

 

4.  I'm not sure why you'd want to switch output files in the middle of your program.  Generally, the most time-consuming part of file operations is opening and closing files, so if you can do that first and then "spool" data into the file, that's optimal from a speed perspective.  Having said that, I have written routines that put the open/close "inside" the loop, for example, when saving videos "mid-stream" (i.e. continuously taking video images, but saving the video file "mid-stream").  I use the Queue to allow frames to "accumulate" while the new video file is being opened -- the Queue needs to be long enough for this process to take place, then the Queue is quickly emptied as the frames are saved in the file.

 

5.  Averaging tends to be extremely quick (it's only arithmetic, and computers are very fast doing arithmetic).  Sorry I can't comment on the particulars of your code -- try posting it again, and also try saving it as a Snippet and attaching the resultant .PNG instead of zipping the VI.

 

Bob Schor

Message 12 of 17
(1,742 Views)

Thank you for your answers!

 

I wrote this VI using LV 8.5 evaluation. I don't know why you cannot open it. But  can I do these snippets with Labview 8.5? Would a normal screenshot be also okay?

0 Kudos
Message 13 of 17
(1,728 Views)

Initialization.PNG

 

That is the initialization and allocation of the queue. I try to attach the .vi,too.

 

Producer Loop.PNG

 

To the right hand of the producer loop, errors are collected and then the queue is released.

 

 

0 Kudos
Message 14 of 17
(1,711 Views)

Consumer Loop.PNG

 

These are the two consumer loops, which are supplied by different queues. I think a speed-issue could be the building of the 2D-array in the upper while loop, but I don't now, how I can otherwise store previous data in the XY-Graph. Could I also set the t0-value as a constant of 0? I only need relative times, not absolutes. The Waveform-Chart is only placed to control if everything works (now).

 

"Open File": The problem is, I could need this within the loop, because sometimes, one wants to start the program and sees the currents on the display. Then one changes for example a resistance and has a look at the change of the display and maybe save this. After saving some data, you want to disable saving, change another resistance, look at the effect and then decide to save in another file (otherwise, you would have tons of data wihtin the file, you dont want to evaluate later on).

0 Kudos
Message 15 of 17
(1,705 Views)

I am sorry for quadruple-posting 😕

 

I tried to use the VI for data acquisition. It showed fantastic performance, especially compared to the old VI as long as i don't save the data. Thanks a lot!

 

With saving there are some problems: If I press the "save" button while the VI runs, a file is created but there is only one line, with a value for time and NaN-valjues for the other channels. If I start the VI while the "save" button is pressed, it correctly collects the data.

I also tried to put the "Create/Open-VI" in front of the while loop and feeding the referenced through a shift register, but that did not change the thing (with the exception that I have to stop the program to change the file path).

 

In both cases, the program crashed, when I pressed the "save" button twice, to set the button value again to "false".

0 Kudos
Message 16 of 17
(1,683 Views)

After removing the error input to "dequeue" element, everything works as intended. Thanks a lot for all the help! 🙂

0 Kudos
Message 17 of 17
(1,629 Views)