08-29-2019 02:50 PM
Hi everyone. I'm new to labview and I'm developing a real-time system. I try to acquire a series of data of 20 each time and then calculate the core of gravity of the 1D data. Now I need to know the calculating time to test the fastest rate I can go. But I don't know how to calculate the time since both the DAQmx read and calculating code are both inside the while loop structure but I only want to get the time of the calculation part. Any feedback would be great. Thanks.
08-29-2019 02:53 PM
08-29-2019 04:13 PM
You cannot calculate it. You actually need to measure it. 😄
08-29-2019 04:34 PM
Still, measuring the execution time of the calculation will not give you any reliable indication on "how fast you can go". Do the experiment and simply see how fast you can go, i.e. increase the rate until things fall apart. 😄
You might also play with the buffer size. Currently you use buffer size=samples/channel. Why?
Also, since your samples/channel does not change during the loop, you could pre-calculate the ramp as follows:
Still, there are many glaring problems everywhere in your code:
08-29-2019 05:19 PM - edited 08-30-2019 09:49 AM
Now look at your extremely convoluted setup of the arrays. You are creating these gigantic 2D arrays just to throw everything but the first row away a nanosecond later. You are generating up to 40x more data for nothing!
All you need is much less for the exactly same result:
08-30-2019 08:53 AM
Thank you so much. I really appreciate!
08-30-2019 09:40 AM
Actually I want to measure the time of calculating. I don't think it has something to do with the reading rate.
08-30-2019 09:58 AM
@chen3477 wrote:
Actually I want to measure the time of calculating. I don't think it has something to do with the reading rate.
Our presentation from a few years ago has already been mentioned. Did you even look at it?
In my opinion, the calculation time here is probably insignificant and you should be able to do any speed your hardware supports. The calculation is NOT the time limiting step and even if you know the exact calculation time, you won't be able to draw any conclusions about the max data rate. If you are still worried about performance, use a queue and do the calculation in parallel in a separate loop.