LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous reading of array elements

Solved!
Go to solution

Hello everyone, 

 

i am pretty new to Labview and i am trying to do some tasks. I found some difficulty to continously read elements from an array. For example, if we have an array with 10, 15, 20, 25, 30, 35, 40 i would like to read each value sequentially, 10 then 15 then 20 etc. I know it has to do something with For loop and Index Array but I can't make it work. Any ideas? 

0 Kudos
Message 1 of 8
(4,013 Views)
Solution
Accepted by Loukask

What should happen in you run out of elements?

 

All you need is auto-indexing on a FOR loop and placing a numeric indicator inside the loop. Since this will complete in nanoseconds, you also want to place a small wait inside the FOR loop.

Message 2 of 8
(3,992 Views)
Solution
Accepted by Loukask

For Loop.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 8
(3,955 Views)

After the elements finish, just to stop. Nothing special. 

0 Kudos
Message 4 of 8
(3,949 Views)

Hello again, please take a look at my photo. I create an array of 10 elements (read from txt) then i want to take each of them and sequentialy. When i run it, it works fine but the only thing i see to my "subarray" indicator is number 10 which is the first element of the array. (the array contains this values (10, 15, 25, 35, 45, 55, 65, 75, 85, 95). Any ideas?

0 Kudos
Message 5 of 8
(3,904 Views)

Why are you using "built array" to turn your 1D array into a 2D array? Don't!

All you need is Yamaeda's code above, don't over-complicate things!

 

(Explanation of what you are seeing: Your 2D array has only one row, and since you are autoindexing, the FOR loop only iterates once, no matter what you wire to N. The shortest autoindexing array always wins! Also, next time please simply attach your VI. Oversized images are pointless)

Message 6 of 8
(3,884 Views)

Ok thanks a lot, i managed to make this. Now, what i would like to do is from this array, take an element, pass it as a setpoint to PID (not finished) do a control loop with this setpoint and after that, change the setpoint with the next element from the array. If element1=10, then setpoint=10, do control loop then element2=20, setpoint=20 etc. 

0 Kudos
Message 7 of 8
(3,875 Views)

Do a state machine. Look at the templates and examples that ship with LabVIEW.

0 Kudos
Message 8 of 8
(3,872 Views)