01-22-2010 07:55 AM
I am new to labview and working on an application where I am supposed to store an element into an array (without overwriting) after each iteration in a for loop. I have tried using Build Array Function keeping the indicator outside the for loop and played with indexing but didn't work. Please suggest me an idea how to do it.
Thanks
Solved! Go to Solution.
01-22-2010 08:14 AM
Several methods. Here are the most common:
The best way is obviously the auto-indexing method.
01-22-2010 08:34 AM
01-22-2010 09:03 AM
It would be better if you attached the actual VI.
Neither of your images show an "insert into array" operation.
01-22-2010 09:10 AM
The problem with your framework is that you lose your information each time you change of case in the case structure.
So you need to keep your array in memory by using a 'shift register' as
when you need to fill your array
and
in all other cases
Don't forget to link the node for all cases of case structure (don't use ' Use default if unwired')
It's a typical use of shift register 😉
01-22-2010 11:31 AM
01-22-2010 12:09 PM
Does it work for you now?
You should probably mark J.Dechet's reply #5 as the solution as he was the one who figured out from the screenshots that you were missing the shift register.
I would recommend trying to avoid the local variables. Wire the times into other shift registers to carry them from iteration to iteration. You can connect the indicator to the wire through the shift register to update the screen display. As the very least, rename those time indicators to something more meaningful than Current Time, Current Time 1, Current Time 2. It will help the local variables that you are currently using make more sense. Such as Switch 1 High Time, Switch 1 Low Time.
I don't know what your code is supposed to do as it seems to run instantly. I don't know the reasoning why you have the For Loop around your state machine's while loop.
It seems to me that if you are trying to act on switch changes, you should be using an event structure to detect when the switches are toggled.