02-10-2009 11:06 AM
I'm trying to write a data acquisition and control program for my company's new test stand and I'm running into a problem with how fast the program executes. The individual pieces all seem to run very fast, but there is one section that takes around 40ms and I can't figure out why or how to make it run faster. I've included my top-level VI with this message in case anyone can spot something I've missed.
I've organized the code into several nested sequence structures. The outermost structure handles program initializations, and then goes into a while loop on frame 3. This loop runs most of the program features: waiting for user input, controlling valves on the test stand, and taking data. Inside the loop is another sequence structure that handles these tasks. I've put a bunch of Tick Counts inside this loop to measure the execution time at different points in the program, and from this data I was able to back out an average time interval between different parts of the code.
What I found was that the slowdown occured between frames 1 and 2 of the sequence that's inside the while loop. This is right after the program finishes hardware control, and before data acquisition begins. There is very little (data transfers along wires mostly) that occurs in this section, so I cannot figure out why this is taking as long as it is. If anyone else has an idea, please let me know.
Thank you.
02-10-2009 11:11 AM
That code is going to be very difficult for someone else to read/debug.
You have so many nested stacked sequence structures it is hard to tell what is going on.
You can dictate the order of code execution by wiring the error in/out of each funtion.
02-12-2009 09:09 AM
Hello,
We actually just came out with an awesome tool to debug a problem as such, it's called the LabVIEW Desktop Execution Trace Toolkit and you can download the Evaluation version for free and use it for 30 days. I think you will find it very useful especially since your code is quite large and complex, it may not be easy to discover the problem by looking at it. The description and link to the toolkit is below.
The LabVIEW Desktop Execution Trace Toolkit can help you debug and troubleshoot LabVIEW applications by providing low-level details about the execution of VIs and executables at run-time. You can monitor code and easily identify the source of problems such as reference leaks, memory leaks, unhandled errors, and other issues that can negatively impact the performance and reliability of an application.
http://www.ni.com/softwareengineering/
Just scroll down and click Evaluate under LabVIEW Desktop Execution Trace Toolkit
Regards,
Anna K.
02-12-2009 09:41 AM
I agree. Your code is a mess. Placing the code into several nested sequence structures is not "organizing" - it's just sweeping the mess under a carpet that's on top of another carpet that's on top of another carpet. You would do well to use well-established coding principles such as state machines or the producer-consumer architecture.
Specific comments: