03-16-2010 07:10 PM
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.
03-16-2010 07:38 PM - edited 03-16-2010 07:42 PM
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.
Rgds
03-17-2010 11:42 AM
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