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:
- 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!
- 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?
- 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...
- Decimate the data before displaying it. Is this necessary? Are there good examples somewhere?
- 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.
- 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?