LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: array --indexing

Solved!
Go to solution

Hello,

 

i have an array of 126 element that correspond to 126 sensors, i need to compare each element to an numerical value. and do some action depend if the numerical value is higher or lower than the element.

 

index array works fine but it takes a long time to put the index number from 0 to 125...

 

is someone have optmize way to do so?

 

thank you in advance

0 Kudos
Message 1 of 8
(2,221 Views)
Solution
Accepted by topic author igohilandi

I moved your message to a new thread since it really had nothing to do with the 7 year old thread marked solved you originally posted in. (https://forums.ni.com/t5/LabVIEW/array-indexing/m-p/2590095)

 

Attach a VI so we can see what you are doing.  Is it the same value for comparison for all 126 elements?  What is the "some action" you want to take?

 

There is no reason type in 126 index constants on an index array node.

 

You should be doing your work in a For Loop.  Or you may not even need a loop at all.

 

I would recommend you learn more about LabVIEW from here. How to Learn LV

0 Kudos
Message 2 of 8
(2,212 Views)

I would like to avoid to use a for loop to save memory and other task freeze during the for loop so if i have 100 of for loop it may be a pb. 

kaourou_0-1595491001913.png

 

0 Kudos
Message 3 of 8
(2,150 Views)

Hi kaourou,

 

this code shown in the image is pure rube-goldberg!

 

Learn LabVIEW basics, including autoindexing in loops and shift registers...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(2,131 Views)

I agree, much room for improvement with shift registers and auto indexing tunnels, also, not sure what your wait function is doing, that will be slowing it up quite a lot (By ~125ms)

 

If you post your actual VI rather than a picture someone might edit it to show you how you could do it better.

0 Kudos
Message 5 of 8
(2,119 Views)

@igohilandi wrote:

I would like to avoid to use a for loop to save memory and other task freeze during the for loop so if i have 100 of for loop it may be a pb. 

 

 


I don't understand this statement at all. How does this save memory? How are you freezing other tasks? I have created a simple VI that does everything that you were doing in your FOR loop and set it up for benchmarking. The time that it takes to run this FOR loop is minimal (340 microseconds on my PC). There are no local variables, no bundling and unbundling multiple times, and uses autoindexing. Array Processing Timing.png

 

In your picture it appears that this is part of a larger loop that you do not show. I do hope that you are not using local variables to send data to other parts of your code. This is asking for race conditions because you have no control over when the data is read. Use wires to force data flow.

0 Kudos
Message 6 of 8
(2,109 Views)

Hi kaourou,

 


@igohilandi wrote:

kaourou_0-1595491001913.png

 


This basically does the same:

Unfortunately you forgot to attach your VI and so we cannot determine what you hide in the TRUE case. It also is unclear why you need to replace elements of an integer array using DBL values. And it is irritating to use a non-typedefined cluster to hold 125 elements, which usually should be stored in an array…

 


@igohilandi wrote:

I would like to avoid to use a for loop to save memory and other task freeze during the for loop


To save memory by avoiding a FOR loop sounds like non-sense to me.

And which other task should freeze during execution of a FOR loop iterating about 125 times on a simple DBL array (within microseconds)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(2,108 Views)
Solution
Accepted by topic author igohilandi

@GerdW wrote:

This basically does the same:

As usual GerdW's approach is more efficient than mine, but either approach runs in microseconds.

Message 8 of 8
(2,097 Views)