LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to calculate percentage of total run time a push button has been depressed?

Hi,

 

I am trying to calculate the percentage of total run time a push button is depressed using while loop which iterates every one-hundredth of a a second.

 

What I am trying to do is to find how long a button is depressed during the total run time. And then dividing it with the total run time to find the ratio. I am trying to display this ratio only after the loop is stopped. Also show the total run time in every iteration of the loop.

 

I have managed to implement a stop button which stops the loop when pressed and delaying each loop by one-hundredth of a a second(10 milli sec).

 

Does someone know how to solve the above? 

 

I have been trying to implement all the above for days. 

0 Kudos
Message 1 of 3
(5,281 Views)

 

Hi,

 

  Does this helps?

 

  Basically, it just counts the no. of loops where the button is depressed and the total no. of loop iterations. Accuracy is limited to mulitple of 10ms. Better accuracy can be obtained by reducing the loop duration.

 

 loop press sample.PNG

 

 

 

Rgds

 

 

Message Edited by Limsg on 03-16-2010 07:42 PM
0 Kudos
Message 2 of 3
(5,274 Views)

Is this a stand-alone program or part of a program which is also doing other things while the timing takes place?

 

I would probably use the event structure to detect the button presses and the tick counter for timing.  Use shift registers to keep track of accumulated time and total elapsed time.

 

I do not have LV handy to test it now. 

 

Lynn 

0 Kudos
Message 3 of 3
(5,214 Views)