LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is my variable incrementing multiple times?

In my application I need to increment a variable when a certain condition is met so I have a case statement which checks whether the condition is true then increments a variable. However the variable is increment for the entire time that the condition is met. How can I restrict this to only increment one time per occasion of the condition being true. I've tried while and for loops that execute only one time and nothing seems to work.
0 Kudos
Message 1 of 7
(3,464 Views)
Hello,

A simple way to do this is using a boolean variable that is set to true by your condition and then set to false inside the case where the variable is incremented.
Check attached vi.

Hope this helps,
Paulo
0 Kudos
Message 2 of 7
(3,457 Views)
here is another way of doing it.

-Joe
0 Kudos
Message 3 of 7
(3,453 Views)
I have modified Paulo's example so that you don't use local variables. This should be a more efficient approach since the local variables will make copies of the boolean.
0 Kudos
Message 4 of 7
(3,442 Views)
Or you could do it similar to this.



Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 5 of 7
(3,428 Views)
Oops. I just realized that the vi was not attached. Here it is.
0 Kudos
Message 6 of 7
(3,425 Views)
This is how i'd go about it
0 Kudos
Message 7 of 7
(3,406 Views)