LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a numeric control (of any type) that can ONLY be increased or decreased by one 'unit' at a time?

Solved!
Go to solution

As in the title.  I wish to create a numeric control (no current limitations on its type) with a range of 1-10 (and a step of 1).  The only difficulty I'm having is that the user must only be able to increase or decrease it by 1 at any time.  The code initiated by this value change must have completed at least once before the value can be changed again.  This is because the VI's code is mostly contained in a while loop, and the control is read once every iteration and its last value must not differ by more than 1.

 

Is this possible with LabVIEW 6.1 and if so, how?

 

One of the solutions I've come up with so far is to disable the control immediately after it's read, and to enable it again immediately before it's read for the next time (I have to assume that the user is unable to click twice before the control is disabled).  Is this an acceptable method or is there a better way?

 

I also had an idea of partially disabling a normal numeric control such that it could not be typed in - only the arrows remained operational.  However, i don't know quite how to do this. 😞

 

James



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 1 of 4
(2,672 Views)
Solution
Accepted by topic author J.Mamakos

Hi James,

you can use two buttons (latch when released) and a numeric indicator which shows the current value. One button increase the value and the other decrease it. Store the value in a shiftregister to work with it.

I'm not sure if your solution would work because the use can directly enter the new value.

 

Hope it helps.

Mike

Message 2 of 4
(2,645 Views)

Yes, i realize my solution needs the idea that followed it to be feasable in order to work properly.  My bad!

 

I did wonder about using a combination like that, but I hoped it could all be done with one object.  Ah well - just means adding an extra little bit of code.  No probs.

 

Thank you anyway. 🙂



Never say "Oops." Always say "Ah, interesting!"

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

Hi James,

you can also do it with the numeric control, but then you have to insert some logic to make what you need. You could store the old value and check if the difference to the new value is 1, if this is the fact, then the new value is valid, otherwise you could check if the new value is greater than the old one and increase it by one. The same for a smaller value and decrease.

 

Mike

Message 4 of 4
(2,633 Views)