06-03-2012 05:58 PM
Hello Everyone,
I'm trying to use an array to store the time of an event like pressing a button. So "if" the button was pressed then store that time in an array, "else" the button was not pressed then continue. I can't seem to figure out how to do this. Below is some code I made that has the idea of what I want to do but not completely. "If" the button is pressed it displays the output of the time in a numeric indicator and "else" it just keeps displaying the previous time. I saw this post http://forums.ni.com/t5/LabVIEW/Conditionally-add-value-to-array/m-p/1974835/highlight/true#M653360 but I can't open the vi because it's a newer version and I don't understand what is happening. Your help is appreciated.
Max
06-03-2012 07:08 PM
First of all, you don't have any arrays on your diagram. If you want to append to an array, use a "built array" node inside the case, and keep the array in the shift regsiter.
(You should also initialize your shift register. Also, you have a mismatch in datatypes. your indicator should probably be blue. You should also use a latch action boolean, not a switch.)
06-03-2012 09:16 PM
Thank you for your help. The latch when pressed action is much better, now it doesn't gather up a bunch of times when the button is pressed. I'm close to having it, I think my loops are wrong or my array is wrong? It doesn't look like the I32 array in this tutorial: http://stackoverflow.com/questions/9863450/how-to-store-values-in-array-inside-loop except they are using a for loop, how would I implement a while loop?
06-03-2012 09:34 PM
@mbigras wrote:
...I'm close to having it, I think my loops are wrong or my array is wrong? It doesn't look like the I32 array in this tutorial: http://stackoverflow.com/questions/9863450/how-to-store-values-in-array-inside-loop except they are using a for loop, how would I implement a while loop?
I don't see where you think what you have is wrong. What part of your solution does not meet your requirements?
06-03-2012 09:35 PM
Because your loop counter is still incrementing even when you don't push the button. Also, your indicator is outside the loop so it won't update until you press stop.