LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting how many times numeric control is pressed

Solved!
Go to solution

Hi guys

Is there any way to find how many times a numeric control switch has been pressed(either increment or decrement)???

thanks in advance

0 Kudos
Message 1 of 13
(4,978 Views)

Use an event structure. You could use the Value Change event, but that would be triggered even if the user clicked inside the control and typed a new value. Alternatively, you could use the Mouse Down event. In this case you'd need to compare the current value with the previous value (shift register or feedback node) to tell you if the value changed, since the value will be changed before the event is fired.

 

Please review the LabVIEW Help and the LabVIEW examples on shift registers and event structures.

0 Kudos
Message 2 of 13
(4,975 Views)

Hi  Newbee_2,

Figure 15

This is a sample VI.You can make this to the form you wish.In this it will count number of times one will click "pick" button.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 3 of 13
(4,951 Views)
Danil,

Giving a bad answer is worse than not giving an answer at all. That code is a ridiculous response to the question.
Message 4 of 13
(4,946 Views)

I wouldn't necessarily call it a bad example.  I can accomplish the goal of counting button clicks.  However, it might belong in the Rube Goldberg thread.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 13
(4,931 Views)

@crossrulz wrote:

I wouldn't necessarily call it a bad example.  I can accomplish the goal of counting button clicks.  However, it might belong in the Rube Goldberg thread.


Yes, except for the fact that the OP asked to count the number of times a numeric control's value was changed via the increment/decrement, and not how many times a button was pressed. Smiley Wink

0 Kudos
Message 6 of 13
(4,928 Views)

Thanks everyone for their valuable input but I just want to create a vi that makes a decision when value of numeric control changed for the first time and different decision for subsequent changes in numeric control. I am attaching that VI which is working but I want make it better because  here you have enter the value before starting of the VI otherwise it will not work...

0 Kudos
Message 7 of 13
(4,899 Views)

@Newbee_2 wrote:

Thanks everyone for their valuable input but I just want to create a vi that makes a decision when value of numeric control changed for the first time and different decision for subsequent changes in numeric control.


That is a completely different requirement. It would help if you stated what you actually want from the start.

 

As for your VI: it has numerous problems.

  • Local variable abuse. We see this constantly. None of your local variables are needed, despite what you may think. The "Set Value" local variable should be read from the control. The "Current Value" can be read from a single shift register or feedback node.
  • Constant opening/closing of DAQmx tasks, even if the value isn't changing. 

Based on what I am seeing, it seems to me that your statement that you just want to create VI that makes a decision if a control changes value the first time vs subsequent changes if just the tip of the iceberg. And while the solution to this problem is quite simple, rather than giving you a band-aid, it would be better if you explained what you are actually trying to do with your code, so better suggestions can be provided.

0 Kudos
Message 8 of 13
(4,882 Views)

Sorry but I am bit fond of local variable and inner conscious drive me toward using local variable. Actually the operation is like when you first time enter the value through numeric control it should check the default value of the IC(5K, AD529x) but after it has checked the value for the first time and ether  incremented(or decremented) it will check with current value rather than default value and will do necessary operation(making Porto high/low than no of pulses through port1 to go the that particular value ) and this a testing code which will used to test the operation of circuit which has that IC AD529x

0 Kudos
Message 9 of 13
(4,857 Views)

@Newbee_2 wrote:

Sorry but I am bit fond of local variable and inner conscious drive me toward using local variable.


 Why some people say Local Variables are bad...

0 Kudos
Message 10 of 13
(4,830 Views)