LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean to increment a counter

Solved!
Go to solution

But this works fine, check it out

Message 11 of 15
(1,579 Views)
But locals are bad programming, in general. You should never use them unless there is no other option.
Message 12 of 15
(1,575 Views)

, you overuse local variable

 

Memory Considerations when Using Local Variables

Local variables make copies of data buffers. When you read from a local variable, you create a new buffer for the data from its associated control.

If you use local variables to transfer large amounts of data from one place on the block diagram to another, you generally use more memory and, consequently, have slower execution speed than if you transfer data using a wire. If you need to store data during execution, consider using a shift register



Thank you & Best regards
syrpimp

=======================================================
“You must continue to gain expertise, but avoid thinking like an expert." -Denis Waitley
Message 13 of 15
(1,573 Views)
Solution
Accepted by topic author karthiksudhir80

@karthiksudhir80 wrote:

thanks for your support, i used event structure and local variables and implemented this application which increments the counter when swittch 1 is pressed and decrements the counter when switch 2 is pressed, and glows a light when the value of the counter is greater than 0.


Do not attach pictures, attach a VI (or snippet). We cannot see what's in the other cases of the case and event structures.

 

As others have already said, your VI is inefficient, ugly, disfunctional, and overly complicated. You have race conditions because you read from and write to local variables in parallel. There is duplicate code. Your stop button does not work correctly, because you don't have a correctly designed event for it. You use incorrect representation for integer math (You need blue instead of orange).

 

Try something like the attached.

0 Kudos
Message 14 of 15
(1,554 Views)

Thank you, I understand that i have to learn a lot about optimising the vi if i plan to continue working on labview

0 Kudos
Message 15 of 15
(1,511 Views)