LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

bad lag in vi using "initialize array"

Greetings,

What did I do to deserve all this lag in this vi?

Thanks in advance.


0 Kudos
Message 1 of 23
(2,986 Views)

I really can't tell you. Can you provide more details on what is happening? Just stating that you are seeing lag does not tell us much.

An initial guess is that the IMAQ VI's are causing the lag and not the array functions.

Also, since you need to input the array as a Single precision floating point, you should just initialize the array as a Single instead of a Double and then converting it. Just right click on all of the "DBL" terminals and navigate to the "Representation" menu and select "SGL". That will eliminate one copy of the array.

Ed



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 23
(2,962 Views)
Thank you for your help so far.

The reason I think its the Init Array is b/c I eliminated the Init Array function and just wired the same size array into the IMAQ functions, and there was no lag.  By lag, I mean on the FP, for some reason the interface is lagging.  In the large program where I have this sample included, the FP only lags when I have the tab exposed where this particular image is displayed.  As soon as I navigate away to another tab with a different image, the lag disappears.

Any additional advice is appreciated Smiley Happy


0 Kudos
Message 3 of 23
(2,940 Views)
Just for fun, try moving the image indicator off the tab and see if you still get the lag.
 
There's been other delay problems with graphs and charts when used on a tab control and I'm curious if the image indicator might be doing the same thing.
 
Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 23
(2,934 Views)
Sorry, I don't have IMAQ, but I seriously doubt that the array initialization is the problem. Maybe there is something wrong on your FP. Do you have overlapping elements? Is this operation occurring in a loop?
 
side issue:
Of course you do way to much duplicate work. In addition to the DBL computations for a SGL output already mentioned, It does not matter in which order you do multiplications and divisions.
 
You do 1024 multiplications with power/pixel, then 1024 multiplications with vResp, then 1024 divisions with AD count.
 
3072 operations! 😞
 
All you need is to multiply power/pixel with vresp and divide by AD count, then multiply the result with the array.
 
1027 operations! 🙂
 
You do about 3x more operation than really needed. Right?

Message Edited by altenbach on 07-26-2007 06:36 AM

0 Kudos
Message 5 of 23
(2,930 Views)
Well, in the sample vi which I have included, the image display does not rest on a tab and it's still lagging.  Furthermore, I have 4 other images displayed on 4 other tabs which are not experiencing the lag.  Coincidentally those 4 other images do not have the Init Array function wired to them.

Thanks again for your help.  If you have any other suggestions, please let me know 🙂
0 Kudos
Message 6 of 23
(2,925 Views)
Yes thank you, that is true. I will fix order of operations and continue.

As far as does this occur in a loop--no.  It's nested in the program just as you see it in the sample.
0 Kudos
Message 7 of 23
(2,923 Views)
Ok I have fixed what was suggested to be fixed.

I still have lag on the FP.   Argh!!


0 Kudos
Message 8 of 23
(2,924 Views)

The initialize array stalls while allocating memory.

An Action Engine with a

set-up state (to do every from the multiply backwards and save in a SR)

And a Do-Imaq state to do the rest may help.

This let you force the memory allocation to happen before your code will be impacted by the call to the OS to allocate the memory.

Trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 23
(2,916 Views)


@Candice wrote:
Ok I have fixed what was suggested to be fixed.

I told you that was only a general suggestion for better coding, but will NOT fix your problem.

We would really need to see the code.

  1. I am not familiar with IMAQ functions, but why do you retain the reference in an indicator while you destroy it at the same time?
  2. Have you tried wiring the error output?
  3. Is there any other code in that case?
  4. Are you really sure there are no overlapping elements on the front panel?
  5. Are any of your priorities higher than normal?
  6. Have you tried placing some timing code at strategic locations to see how long the initialization really takes, for example?
  7. Have you done some profiling?
0 Kudos
Message 10 of 23
(2,908 Views)