LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow Signal Acquisition

Solved!
Go to solution

Hello,

I'm still an inexperienced user and just started to compose new Lab software in modules, subvi's. The file in the attachment shows the arrangement. The problem is that the writing and plotting is 50% as fast it should be. I.e. after 10 sec only 5 sec are plotted and written. I already tried to have the file writing and the plotting in different loops, but the problem remained the same. I also ran an older code that does not have any subvi and there the data acquisition (plotting and writing) went as it should. Hence, I suppose the problem is buried in the code, but I can't find it (already checked the forums).

I'm a bit under time pressure to finish this program and therefore quick help is much appreciated.

Thank you!

 

0 Kudos
Message 1 of 7
(3,536 Views)

Hi RUF2

 

I have had a look at the PDF you attached and there are a number of points;

 

  • The DAQmx Timing.vi will define the speed of the while loop which contains the DAQmx Read.vi - there is no need for Wait Until Next ms Multiple
  • Dataflow will define the execution of the tasks (all input terminals of a given function node must have data before it executes) - meaning you wont need the sequence structure in this case

This tutorial is very useful for learning about how to use the DAQmx functions.

 

For reference, if you are in the LabVIEW environment, pushing Ctrl-H will display Context Help.  If you then hover over any controls/functions you will get some extra information about it, from there you can select "Detailed Help" which will give you much more help.  This also links into the NI Example Finder where you can find many examples, this can also be accessed from LabVIEW by navigating to "Help >> Find Examples..." - I would recommend accessing "Hardware and Software >> DAQmx >> Analog Measurements >> Voltage" for now.

 

There are many examples of acquiring, graphing and logging data in that folder.


Regards,

Peter D

Message 2 of 7
(3,520 Views)

hej Pete,

thanks - I will check out the tutorial. I guessed already that the sequence would not be necessary, but I made 3 other versions of the code before without sequence and the problem of the slow reading could not be solved. The sequences were an act of disperation. Do you have any idea what might cause the slow reading? I look into the tutorial you sent asap - thanks

R.

0 Kudos
Message 3 of 7
(3,500 Views)

Thanks for getting back to me, the tutorials should help you out.

 

It is most likely due to a combination of the DAQmx Timing.vi configuration (you have setup to sample at 10 Hz) and the Wait functions (they will cause an extra delay before and after the reading)


Regards,

Peter D

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

ok,

I narrowed the problem down and I do not think that the data acquisition is the problem. The attached subvi data_writer seems to be the problem. If I take it out the data are acquired as they should. One option would of course be to write the data after the loop exit, but the tests that we are doing are ice model tests and a loss of measurement data can be very expensive and therefore I want to write constantly while measuring. Might the subvi as a structural element be the problem?

All kind of suggestions are appreciated.

Terv.

RUF

0 Kudos
Message 5 of 7
(3,455 Views)
Solution
Accepted by topic author RUF2

RUF,

 

The fact that some of the code is in a subVI is not the problem.  SubVIs have a very small ovehead which is completely negligible in your case.

 

I see several things which may contribute to your performance issues:

1. You save every other data point to the file and plot the ones in between to XY Graph 0.  Is that intentional?

2. You acquire one point at a time (per channel) and then write it to the file.  This means about 50 DAQ Reads and 50 writes to file in the subVI, another 50 DAQ Reads and 50 writes to the graph per second.  Writing to the file can be quite slow. Writing to a fornt panel graph faster than the user's eye can respond wastes time. Are you keeping up or do you get buffer overflow errors?

3. Performing calcuations inside the loop which never change wastes time.  Do them once outside the loop. (1/100 rate).

4. You take scalars, build them into one element arrays, convert to dynamic data type, run two points through the Build XY Graph Express VI (which converts them to wavefroms and then back to arrays), and then plot them on XY Grpah 0.  A Bundle node would do most of this in one step.  But what is the value of a graph of one point?

 

Solutions.

1. Define exactly what data you need to acquire, what data you need to save, and what data you need to display.  You indicate that loss of data is expensive.  What is the most likely cause of lost data? Slow performance of your program? Power interruptions? Something else?  Is the data used while being acquired or only after the test are complete?  I suspect the latter because you indicate that you could write later if there were no risk of loss of data.

2. Consider a Producer/Consumer architecture for your program.  This would have all the DAQ Reads in a separate (Producer) loop.  The only other thing in the Producer loop would be a queue or other mechanism to tranfer the data to the Consumer loop(s). The Consumer loop would accumulate the data and periodically write it to the file and update the graph.  The loops could (and probably should) run at different speeds.  Look at the Producer/Consumre Design Patterns which ship with LV.  How much data you read in each iteration of the Producer and how often the Consumer writes to the file and updates the graph depend on the results of suggestion 1.  I am sure that the timing you now have is far from optimum.

3. Clean up the loops. Loop Iteration/Sampling Frequency = (1/Sampling Frequency)*Loop Iteration.

4. Shift registers in the Consumer loop will probably be the way to accumulate the data for both the graph and the file.  You never need to send the graph more points than there are pixels in the plot.  XY Graph 0 has a plot area 624 pixels wide.  If you ever send it more than 624 points, LV will compress the data (in some way which is not well publicized) to the number of pixels in the display.  So do not send tens of thousands of points to the graph.  Insert Into Array can cause problems with memory allocations and speed when used in a loop.  Use Initialize Array outside the loop and Replace Array Subset inside.

 

Lynn

Message 6 of 7
(3,444 Views)

hej,

that was a good advice and it basically solved the problem. I'm still not happy with the representation of plot, since it does not show the real (CPU) time and a xy graph might run into buffer overflow. That is however solvable. The link below was also helpful and shows how several consumers can be connected to one producer.

I attached the vi of my solution.

Thanx

R.

 

http://forums.ni.com/t5/LabVIEW/one-producer-two-consumer-loops-dequeue-same-element-in-both/td-p/15...

 

 

0 Kudos
Message 7 of 7
(3,414 Views)