From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-05-2011 01:57 PM - edited 10-05-2011 02:05 PM
Hello,
I would like to create a LabVIEW counter display which increments with every boolean click (i.e. user input, Start button). Each boolean click is currently running one cycle of my test i.e. in a State Machine. So far, the counter increments with each click correctly.
Problem: I haven't found a way to reset the counter at will. I would like to reset this counter when the user selects a Stop button.
PS: I dont have Event Structures since im using LV Base. Your help will be appreciated, thanks!
Solved! Go to Solution.
10-05-2011 02:08 PM
That's an unusual use of a for loop combined with the boolean to 0,1.
I don't know what the rest of your code does, but I'd recommend one of two approaches:
1) a dedicated VI containing a while or for loop with shift register that stores your value. There should also be an "action" input; in your case the actions you would need are "reset" and "increment." The output would be the count. This is known as an "action engine" or a "functional global variable" and you can search this forum for those terms.
2) Keep the counter in a shift register in a while loop that surrounds most of your code, instead of just that single for loop. Put a "select" function in line somewhere; wire the stop button to the center boolean input. Wire the true input to the existing value (from the shift register) and the false input to 0.
10-05-2011 03:04 PM
Thanks for your respose, still having the same issue, the counter wont reset.
10-05-2011 03:06 PM
Can you upload your entire VI, instead of just a screenshot of one small section of it? Which approach are you using to reset the counter? The existing screenshot doesn't show anything that would reset it.
Or, are you asking about how to get it to reset when you click the "Stop" button in the LabVIEW toolbar?
10-05-2011 03:25 PM
10-05-2011 03:34 PM
Still not quite sure what you're trying to accomplish here since hitting the stop button will stop the loop, and if you simply initialize the counter shift register (as shown) outside the loop, it will reset to 0 when you start the code again. The attached snippet also demonstrates how you could reset it when the stop button is pushed by using the select function.
10-05-2011 03:40 PM
Have you tried the following in your for loop?
10-05-2011 03:58 PM
I have modified your code, and it should do what you want.
10-05-2011 04:13 PM
Looks to me like you're making it much more complicated than it needs to be. That loop in the first post doesn't do anything and the un-initialized shift register could cause a problem.
Here's an easy way which I think will work for you:
Basically, there are just two buttons. If Increment is pressed, it adds 1 to the current value. If Reset is pressed, it sets the value back to zero. In this configuration, Reset over-rules Increment.
10-05-2011 04:28 PM
Thank you all for the solutions! I think nathand's statement "if you simply initialize the counter shift register (as shown) outside the loop, it will reset to 0 when you start the code again" was the missing part of the puzzle for me. Once again, thank you all! 🙂