cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Continuous reading of array elements

Solved!
Go to solution
Highlighted

Continuous reading of array elements

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
(322 Views)
Solution
Accepted by topic author Loukask
05-19-2017 12:45 AM

Re: Continuous reading of array elements

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
(301 Views)
Solution
Accepted by topic author Loukask
05-19-2017 12:44 AM

Re: Continuous reading of array elements

For Loop.png

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 3 of 8
(264 Views)

Re: Continuous reading of array elements

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

0 Kudos
Message 4 of 8
(258 Views)

Re: Continuous reading of array elements

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
(213 Views)

Re: Continuous reading of array elements

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
(193 Views)

Re: Continuous reading of array elements

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
(184 Views)

Re: Continuous reading of array elements

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

0 Kudos
Message 8 of 8
(181 Views)