LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an easy way to check if a numeric button is pushed?

Solved!
Go to solution

I have a control array of numeric controls( and I want to keep it this way). I would like to check if the user is pressing any of the increment/decrement  buttons. 

If any of the butons is pressed I do nothing; if none is pressed I take the value down to zero.  The value does not matter to me much.

 

How do I check if the increment/ decrement is pushed down ? Thanks

 LV2011 SP1

0 Kudos
Message 1 of 34
(4,524 Views)

If you are talking about a button on a VI front panel the event structure is what you want to do.  You can use the example finder to look up event structure and there will be several variations on the approach.  There is also information available at http://zone.ni.com/reference/en-XX/help/371361H-01/glang/event_structure/.

 

Thanks

Wire Warrior

Wire Warrior

Behold the power of LabVIEW as my army of Roomba minions streaks across the floor!
0 Kudos
Message 2 of 34
(4,523 Views)

There is no easy way to tell if the Increment/Decrement arraws have been clicked on. You can check to see if the array has changed using an event structure.

 

The problem with an array of numerics is that you get one event when any element of the array is changed. See the code picture here for how to check which element was changed.

 

Changed Array Pic.png

 

Rob

 

p.s. I uploaded this as a .png since a code snippet left the events of the structure blank (no event name) and broke all the wires from the terminals. But this one is simple enough anyway.

0 Kudos
Message 3 of 34
(4,511 Views)

Actually I think you are going to have to do this instead. The example above will only show you when the array value has changed not the index number.

 

Example.png

Tim
GHSP
0 Kudos
Message 4 of 34
(4,504 Views)

I thought from the description that the OP wants to know when one of the numeric controls within the array has been changed. My VI will do that.

 

If, as aestet postulates, he wants to know that the user has changed which index is at the top of the array control, aestet's VI will do that.

 

I guess this comes down to an interpretation of which up/down arrows the OP is looking for.

 

Rob

0 Kudos
Message 5 of 34
(4,499 Views)

Thanks for the fast help.

 

What I need to check is whether the user holds the button down, not the  value change.

If the value hits the limit and the user still holds the button I need to know that.

The value change does not help me. The numeric button ( up or down) pushed, not pushed is what I need to check.

 

 

 

 

0 Kudos
Message 6 of 34
(4,492 Views)

The real thing I want to accomplish with very minimum effort and changes to the rest of the project is that (using gigantic simplifications).

 

I have six actuators. The can stay idle, go positive or negative way. I will run them most likely one at a time (from interface). 

The goal is to be able to create a minimal control (my UI is already full ) on the front panel. The array of six numerics seems like a perfect solution. All I need to do is to set it all to zero when the the user take his hand off the control. For compatibility purposes I keep it numeric  not bolean or anything like that.

 

Of course I could have two buttons for each axis but  or a three state button without latch ( how would I do it?)  but this all will clutter the interface. 

 

Technically I could  set the limit (low and high)  to be very high  and just read the value-> if changes ok  if not set it to zero.

I was hoping that I can sense that the index is being pushes (or rather not pushed) and have it more elegant.

 

 

 

0 Kudos
Message 7 of 34
(4,489 Views)

@AndyN wrote:

Thanks for the fast help.

 

 

The value change does not help me. The numeric button ( up or down) pushed, not pushed is what I need to check.

 



Are you simply wanting to check if the buttons have been pushed?

 


@AndyN wrote:
 

What I need to check is whether the user holds the button down, not the  value change.

If the value hits the limit and the user still holds the button I need to know that.


Or if the user holds the button down when the limit is reached?  It sounds like you want both.  There is a contadiction in what you are asking.  One, you say the value change does not help you, but then you say you want to know when the inc/dec arrows are pressed (which is a value change).  I'm just trying to get clarification on what you want.  What the others are saying is you can use the value change to indicate that the button has been pressed.  You can use the Data Entry Limits property node to determine when the limit has been reached and compare against the actual value in the Event structure. 

 

 

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 8 of 34
(4,482 Views)

I don't think there is a property or control to tell you when one of the increment/decrement buttons has been pressed or when one is held down. You could set up a cluster with a numeric (buttons not visible) and boolean inputs (making your own increment/decrement buttons). In this case you could access the state of each of the buttons. You then have an array of clusters to check.

 

Rob

Message 9 of 34
(4,479 Views)

The numeric button goes back to its default state once you stop pushing it.

The only and only thing I need to know is if the button is pushed or not (Up or down irrelevant).

I do not need to know the value or the limit.

 

I used the limit example only as an argument to explain that the value check would fail. You can still keep holding the button but the value does not change, hence the value check does not work.

 

Goal->to check if the button is being pushed. Solution based on the value change - > fail due to value limit.

 

0 Kudos
Message 10 of 34
(4,478 Views)