03-19-2009 06:21 PM
Hi,
I am using a PCI 6601 DAQmx card with a SCB-68 connector block. I am performing pulse width counting from four channels. My algoritm must calculate an (x,y) position of a robot. It uses four time measurements to do this. When all four measurements are known the (x,y) position will be calculated. After every 50 ms all four measurements are known. It seems Labview is not able to calculate the (x,y) position every 50 ms. When I track the time between each (x,y) location this is about 150 ms. How is it possible that Labview is not able to execute my VI in 50 ms? The result should be that I get more (x,y) locations within 1 s.
Do I need some type of real-time package? My computer is very fast: Quad-Core (2.67 GHz with 4GB) so that is not the problem.
A copy of my VI is added as an attachment.
03-20-2009 12:07 AM
Actually what you posted is not your VI. It is just a screenshot of your block diagram. Having your actual VI would allow us to look into those express VI's.
What kind of frequencies are you expecting for your signals? Perhaps the pulses are coming in so slow that it is taking longer than you think to acquire them.
03-20-2009 07:51 AM
As Ravens Fan mentioned it is impossible to tell what the Express vis are doing from a picture.
Some general suggestions:
1. Do the calculations with LV primitives and functions rather than text based code. None of the code is very complicated and it may be faster to use the LV functions. Try it both ways to see which is faster.
2. Move the Write to File to a parallel loop. File operations can be time consuming, especially if the OS has to reallocate file space as the file grows.
3. Put the data acquisition in a separate parallel loop from all calculations, front panel displays, and file operations. Look at the Producer/Consumer Design Patterns.
Lynn
03-20-2009 08:18 AM
Hi, thanks for your help so far. This is my VI, I am sorry for the inconvenience.
Wouter
03-20-2009 08:39 AM - edited 03-20-2009 08:44 AM
You still haven't said what are the frequencies/expected pulse widths of your signals.
You may want to try placing all 4 counters in a single DAQ ExpressVI and splitting apart the outputs rather than having 4 separate DAQ assistants with a single data point each. It may make the counting operations more efficient. I don't know how the DAQmx drivers handle multiple counter tasks.
You may want to benchmark your code. It looks like you have 5 distinct activities going on.
1. Acquire pulse widths.
2. Run a mathscript node.
3. Run a formula node.
4. Build an XY graph.
5. Write to File.
Break everything up into some sequence frames and place millisecond timers appropriately to determine how long it takes to run each frame. Here is an example of how to do the file writing part.
I would bet #4 and especially number 5 are the time consuming activities. #4 not so much early on, but maybe later if the XY graph grows large.
If writing to file proves to be too slow, you will probably want to move that into its own while loop and pass data to it using the producer/consumer architecture.
#2 and #3 should probably be merged into a single node. While running text based code is slower than using LabVIEW based primitives, I don't know if it would be that slow. Using formula or mathscript nodes do add a convenience factor for doing somewhat complicated or long math instructions in a small amount of block diagram space, as long as it isn't too big a cost in CPU time. Benchmarking would tell.
03-20-2009 09:03 AM
Thank you very much, I will implement this in my VI Ravens Fan. Expected pulses from each of my four measurements are between 10-50 ms per signal. The signals always come in sequential order, so T1, T2, T3, and T4. The mathscript node and formula node are needed to compensate for a missed measurement. When the time out value of the script has been reached it will choose another case from the mathscript. The algorithm can work with one missed measurement.
The algorithm will start when all measurements are known so, 4*(10-50 ms)=40-200 ms
03-31-2009 08:24 AM
Hi,
It seems that the Data AQcuisition Express VI is the slow element. I've implemented a sequence structure with ms timers. For calculating one (x,y) location it takes the following steps:
1. DAQ Express VI takes 4 time measurements that last 80 ms in total (see Ttotal in attached screenshot). The total acquisition of this step takes 145 ms. This is the slowest component.
2. Mathscript (0 ms)
3. XY script (0 ms)
4. XY graph (0 ms)
5. Writing to measurement file (11 ms)
Could someone help me with speeding up the DAQ Express VI?
Wouter
03-31-2009 08:36 AM
04-20-2009 01:18 PM
Hi,
It seems it is not possible to use four counters in one express VI. When I use four counters I get the following error:
Error 200147: "There cannot be multiple counters in the same task for input operations. Use a separate task for each counter.
How can I speed up Data Acquisition?
Another minor problem is updating the XY graph. Now a new plot is generated after each measurement. I would like to see the previous measurements also.
Thanks so far,
Wouter
04-20-2009 03:02 PM