LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Loop optimization

Hopefully attached is a picture of the main portion of my code that does data acquisition and generation.  I modelled this architecture after the Producer/consumer concept (http://forums.ni.com/ni/board/message?board.id=170&message.id=190777).  Now that I have added a large portion of code which modifies the display INSIDE the acquisition loop, my code obviously runs slower (about 40ms per acquisition loop compared to 10-20ms before, as evidenced by the timer on the upper right portion of the block diagram you can see).  Basically, I want to be able to "lock the scaling" of the display (as discussed here http://forums.ni.com/ni/board/message?board.id=170&message.id=211947), which requires accessing the lock buttons and applying the correct ranges inside the acquisition loop (As far as I can tell).  I am looking for ways to optimize my code, and what follows is a discussion of what I've seen in the forums:

  1. Separate acquisition loop from other 'running tasks' - e.g. update display, change display, etc.  But I have to do these inside my loop - just like the writing of data to disk - in this case, because I want the user to be able to modify the dispaly as the data comes in!
  2. Build array can be problematic.  However, I initialize my array at the beginning of the program, and it is small, so this should not be a problem, correct?
  3. Do buffered acquisition.  Aren't I already?  I set samples to read to -1, allowing the program to grab whatever is on the card's buffer when it asks for data...
  4. Decimate the data before displaying it.  Is this necessary? Are there good examples somewhere?
  5. Are sequence structures bad for code optimization?  I use one for space considerations, but also because that sequence only needs to execute once inside the main acquisition loop.
  6. Could a Timed loop help me out in making the acquisition occur at a constant rate?  It is annoying that the display is 'jumpy' because different amounts of data comes in each time... If I set a specific number of samples to acquire, the task generally fails...

I am seeking further suggestions/discussion!

Thanks,
Adam

P.S. I can post the entire program somewhere, but there are many subVI's, so if someone wants it, I guess I should make a library and post it to the web?
0 Kudos
Message 1 of 3
(2,832 Views)
Picture attached here.  No idea why it wouldn't stick the first time.
0 Kudos
Message 2 of 3
(2,831 Views)
Hi,
 
It is usually recommended to avoid overusing of sequence structure as it limits the level of parallelism. Furthermore with sequence structure, you cannot stop the execution part way through the sequence. So I will suggest restructuring your code if possible to avoid using sequence structure. Another approach will be to use a state machine design pattern.
 
Looking at the 8th frame of the sequence structure, it seems you performing a lot of analysis on the acquired data. So I think it will be better you separate the data acquisition from the analysis using the queue design pattern (Producer and consumer). With the queue design pattern, you can still analyze the data as they are acquired since all the data are stored in a queue and processed at rate different from the acquisition. With this, you can prevent buffer overflow and data loss at the acquisition stage.
 
Tunde
0 Kudos
Message 3 of 3
(2,768 Views)