06-21-2016 11:00 AM
Hello,
I have a 'for' loop that can takes different number of iterations depending on the number of measurements that the user wants to do.
Inside of this loop, I'm auto-indexing four different 1D arrays. This means that the size of the arrays will be different in different phases of the execution of the program (the size will be equal to the number of measurements).
My question is: Will the auto-indexing of the arrays with different sizes affect the performance of the program? I think that it's slowing my Vi....
Thank you so much.
Solved! Go to Solution.
06-21-2016 11:33 AM
If you need all 4 arrays every time, then it seems like a fine way to do it. If you only need 1 of the 4 arrays at a time and the other 3 get thrown away, then you should probably break up that loop so you are not doing unnecessary calculations.
06-22-2016 07:06 AM
Thank you for your reply.
I think that I didn't explain my problem very well.
The question was regarding to the auto-indexation of an array of different size. Imagine the following example:
1) Measurement number 1: The user wants 11 points, then the for loop is of 11 iterations. Consequently, the output 1D array is of 11 positions.
2) Measurement number 2: The user wants 20 points, then the for loop is of 20 iterations. Consequently, the output 1D array is of 20 positions.
.
.
.
N) Measurement number N: The user wants 5 points, then the for loop is of 5 iterations. Consequently, the output 1D array is of 5 positions.
My question is: Can the fact of changing randomly the size of the output array produce a performance problem of the Vi? My program is slowing over time, but I don't find where is the problem and I don't know if it could be one.
Maybe this question is basic, but I don't know very much of Labview. Sorry for that.
Thank you again.
06-22-2016 08:52 AM
If you are using indexing More Elements (in Thounsands or More) it will slow down the system performance. If less it wont slow down
of you are using continuous Looping Try with the Delay between iteration and Try to find the system Performance
Its Just a Method to find the Difference after putting Delay
06-22-2016 08:54 AM
Be careful with autoindexing, as the for loop runs the minimum number of times for either the N input or whatever it's autoindexing. So if one of your four autoindexed arrays has 0 elements, the for loop will run 0 times, no matter how many elements the other arrays have. This might lead to inconsistent logic in your program.
06-22-2016 09:29 AM
Do you mean if you continuesly running the VI and it is getting slowly? Or do you mean if you try different iteration numbers and the VI is getting slower?
I guess it is the first one and with the information you given it should not caused by the auto-indexing. Can you post more details of your code?
In addition, you can check the lapse time with you code following this example by NI.(http://digital.ni.com/public.nsf/allkb/6F6B9F4E149C80578625652800784764)
06-22-2016 09:46 AM
Autoindexing on the output tunnels of a FOR loop is very efficient, because the final array size is known when the loop starts.
Array sizes of a few dozens elements are never a problem, so if you have problems with "slowdowns" (whatever that means. How do you measure it?) the problem is most likely elsewhere. Can you show us the rest of the code?
06-22-2016 09:54 AM
The application is getting slowly when it is continuesly running.
I'm checking the lapse time as the example indicates, and it is growing continuesly.
About my code. The code is basically a .NET nodes (interfacing with HadBoardApi.dll) that allow to communicate with an A/D converter in order to capture data from this device. These captured data is manipulated and processed by the Matlab Script in order to calculate parameters as impedance, phase or frequency.
The following image shows the main code. There is a first stage where the communication with the ADC is performed and the data is captured. This data is sent to the Matlab script (numBytes1 and numBytes2) and this script performs some calculations in order to obtain the impedance (Z), the phase difference between the signals captured (phase_diff) and the frequency (freq_lse).
The curious of this is if I don't connect the outputs of the Matlab script the program isn't getting slowly. As you can see in the image, the output variables of the script aren't connected to anything.
However, if I connect the outputs of the Matlab script, the program is getting slowly. As you can see in the following iamge, the output variables of the script are connected to the 'for' loop and they are auto-indexing in output arrays.
The 'for' loop iterations is set to 9 but this number can change depending on the number of measurements as I said in previous posts.
If you say that the auto-indexing is not a problem, maybe is due to the Matlab script?? I don't know what is happening and I'm trying to solve this problem since few weeks ago.
Any help will be appreciated.
06-22-2016 09:57 AM
06-22-2016 10:07 AM
My very first thought is that the LabVIEW compiler is actually removing the Matlab Node since the outputs are not being used. As soon as you wire them up, then LabVIEW has to call Matlab and wait for it to run. I know from experience, calling Matlab to run the script is SLOW. I would also recommend doing the math in native LabVIEW.