LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting a counter variable

I am trying to use counter variable "count". The default for "count" is 0 when the program is opened up. I initialize ssd and sumclick to be 0. However once it goes through the formula node, the value for "count" changes to 1 and then the decision loop within the formula node that checks if "count>0" is used.

 

My problem is, if I stop the program and then rerun the program without closing and reopenign the program, the value for count continues to be 1, and so my intialization for ssd and sumclick dont happen. Whenever I hit the run button I want count to be 0. I dont want count to remember the 1 from the previous run. How can I do this?

 

The VI is below.

 

 

untitled.JPG

 

0 Kudos
Message 1 of 5
(2,845 Views)

Add a shift register to the while loop, then add a "count" input to the math node. wire the count output to the right shift register, then wire the left shift register to the count input. Finally, add a zero constant outside the while loop and wire it to the outside of the left part of the shift register. Or post the vi and I'll mod it for you.

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 2 of 5
(2,838 Views)

Hi Charles,

 

Thanks for answering my question. The pciture I posted is part of a large program. After I posted the question I reworked on the block diagram to create a base level example to try and figure out what was going wrong. Here is the base level example. I tried to get rid of the formula node in this. i just have a while loop and all LV operations. 

 

I am trying to generate a random number, take the deviation^2 of the random number from 1 and then keep adding that cumulatively to make SSD. I want my SSD to begin with 0, everytime I stop and re-run the program. VI Attached. Please look at it and tell me. Thanks for the help in advance. 

0 Kudos
Message 3 of 5
(2,834 Views)

I'm not 100% sure I understand what you're trying to do - so I'm not sure if what I have attached will help. I hope it does 🙂

0 Kudos
Message 4 of 5
(2,821 Views)

Aalenox,

 

Yep! It helped. Thanks a lot!

0 Kudos
Message 5 of 5
(2,817 Views)