LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

nested while-loops, reset indicator

As can be seen on the attached picture, I created a VI with several nested while loops. The innermost counts certain events and indexes a following array. Now I want to reset the indictor "number of strings" back to zero (default value), so everytime you push the Run-Button the counter starts from zero! How can I realise this? Or does anybody has a more elegant solution than using that many loops? Thanks
0 Kudos
Message 1 of 12
(4,218 Views)
Not all of your diagram shows on the image, but it looks as though you are not initializing your shift registers. If they are not initialized, they retain the last value as long as the VI remains in memory. To initialize, connect the desired starting value (zero) to the left terminal, outside the loop.

Lynn
0 Kudos
Message 2 of 12
(4,218 Views)
I already tried this, but because I am using nested while-loops, this is not possible. If I initialise the innermost while-loop to zero, the counter always starts with zero in every loop iteration. So this does not solve my problem.
0 Kudos
Message 3 of 12
(4,218 Views)
Hi,
Could you explain your problem rather than the image as we are not able to figure out what your trying to tell,so that we can suggest a better code if any.
vicky
0 Kudos
Message 4 of 12
(4,218 Views)
You can create nested shift registers. If you do not want to initialize the register in the inner loop to zero on each iteration of the outer loop, put a shift register in the outer loop. Initialize that to zero and connect its left terminal to the left side of the shift register on the inner loop. Connect the output from the inner loop shift regiter to the right terminal of the outer shift register. It is a bit awkward to explain in text. If you can't follow what I am suggesting, post a copy of your VI as Vicky suggested and we will try to modfiy it.

Lynn
Message 5 of 12
(4,218 Views)
I attached my example-VI! Thank you very much for your help!
0 Kudos
Message 6 of 12
(4,218 Views)
Hi Aquarel,
You say in the Program that you want to : RESET AFTER THE LAST ITERATION OF THE OUTERMOST LOOP THE COUNTER "Number of triggers" BACK TO ZERO.
By this i can understand that you want to evertime that you start this program or run this program you want the count of "Number of triggers"=0,if i am right all you will have to do is initiliaze the local variable of the "Number of triggers"= 0 before it comes into the loop,if i am wrong in understanding plz let me know what you want to do.The LAST ITERATION of the outermost loop is the iteration at which you press the STOP button.
0 Kudos
Message 7 of 12
(4,218 Views)
Hi Vicky,

I think you understood quite well, what I wanted to do, but if I create a local variable of this indicator, initialise it to zero, before it goes into the loop...the loop still counts on, if I stop and rerun the programme! Maybe I am doing something wrong, handling with this local variable? Don't know?!
0 Kudos
Message 8 of 12
(4,218 Views)
ok i am attaching ur program with the changes along see it.
hope this will solve ur problem.
vicky
0 Kudos
Message 9 of 12
(4,218 Views)
I agree with Vicky. I have modified your example to show how you can initialize the counter to do what I think you are asking. Note that unless it is performing some other function, the inner loop is not required after this modification. Run it. Then pop up on the inner loop and Remove While Loop and run it again. The "number of trigger" display is the same.

Lynn
0 Kudos
Message 10 of 12
(4,031 Views)