LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decrementing the value of Numeric Control when Toggle Switch is ON

Hello everyone, I'm having trouble with a particular looping statement.

I have numeric control that is connected directly to the first numeric indicator that shows what is my input.
I want to decrement the value of that and display the result on the second numeric indicator.
Btw, the decrement function is continuing until it reaches the range that I set (6.5 - 😎 or via turning off the Toggle Switch.
Can you help me to solve this problem?

 

I'm using 2016 version

0 Kudos
Message 1 of 4
(844 Views)

First of, all code outside of the loop is only executed once.

Second, the value in Numeric is passed to Numeric 4 only once, so you would have to set it before running the VI.

Third, the loop will only stop when you flip the switch.

0 Kudos
Message 2 of 4
(838 Views)

You simply need to start with some of the basic LabVIEW learning resource listed at the top of the forum. It seems you have not grasped the basic concepts of dataflow.

 


@AlphaPhi wrote:

I have numeric control that is connected directly to the first numeric indicator that shows what is my input.
I want to decrement the value of that and display the result on the second numeric indicator.
Btw, the decrement function is continuing until it reaches the range that I set (6.5 - 😎 or via turning off the Toggle Switch.


  • You need to explain exactly what you want. There is no obvious way to distinguish "first" from "second" unless you label them as such. You should give reasonable names to ALL your controls and indicators (empty strings, Numeric 1, Numeric 2, Boolean, etc. are not intuitive. 
  • Never (never ever!) delete labels of indicators. If you don't want to see them on the front panel, you can change the visibility.
  • Learn about mechanical actions of Boolean controls. A switch action Boolean is typically not suitable to stop a loop.
  • There is a -1 primitive.
  • There is an in rage?" function.
  • Your booleans are just the NOT of each other.
  • Avoid duplicate code. Large sections including diagram constants are in triplicate for no reason.
  • Any reasonable code architecture has a toplevel loop. If you want to stop the loop at a certain condition, it should be wired to the loop termination terminal.

 

So please explain your requirements in simple terms. How does the program start? What is a typical control value? Is the user allowed to change the control while the loop is running or not? What are the termination requirements?

 

 

0 Kudos
Message 3 of 4
(804 Views)

See if this can give you some ideas for certain code simplifications.

 

altenbach_0-1680192102274.png

 

If you want to "decrement a control" (as in your subject), you could use a local variable of the "start value" and write to it inside the loop, a reasonable use here. Of course if the start value is below the range, you probably want to increment instead. Right?

 

0 Kudos
Message 4 of 4
(795 Views)