LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count up at a press of a button and then count down at a press of another button

Hi guys,

 

I want to create a small Labview Vi that count up when I press a "+" button and then to count down if i press a "-"button.

 

For example if i press 10 times the + then the numeric indicator on the front window  to show me number 10 and then if i press the - button to be able to count down from 10 at each press of the "-" button.

 

At the moment i can count up using the shift register of a while loop but i don't manage t0 get right the second part...to count down from where i stopped the count up

 

Thanks for your suggestion

0 Kudos
Message 1 of 4
(2,463 Views)

I could not open the VI because it was in 2020 version. Anyway, your requirement is simple enough, you can avoid corner cases by using an event structure to capture the button presses and the typical shift register to maintain the count value, just a while loop and shift register will not work out well in this case.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 2 of 4
(2,456 Views)

Please start with the simple learning resources listed at the top of the forum.

 

You don't understand dataflow yet, but maybe try to execute your code using execution highlighting and you will see that the top loop runs once and stops, then the second loop runs once, then stops. All done! (I really hope you are not using the "run continuously" mode!).

Both of your buttons are outside the loop and only get read once.

 

All you need is a single while loop that continues to spin at a define rate and a single indicator that you can increment or decrement based on which button to press. The buttons belong inside the loop! The you need a stop button at the loop terminal to stop the program when you are done.

 

Since you are counting, there should be no orange, because you are only dealing with integers.

 

Se how far you get.

0 Kudos
Message 3 of 4
(2,448 Views)

Maybe this very primitive code can give you a start (all buttons are latch action).

 

 

altenbach_0-1630188855697.png

 

 

Once it works the way you want you can make the code a little more fancy by e.g. using an event structure and add other features.

0 Kudos
Message 4 of 4
(2,444 Views)