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?
Solved! Go to Solution.
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.
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?
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)
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.
Do a state machine. Look at the templates and examples that ship with LabVIEW.