LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

keeping track of pauses

Hello,

 

I am trying to keep track of how long a system has been paused and so far I can only get an output of zero or add up every increment the timer tracks (so my sum becomes .001+.002+.003, etc). I've tried with and without the while loop, but this is within a larger while loop. The time wire is just initialized with Get Date/Time in seconds. the orange zero goes into a shift register on the big while loop (not pictured) which becomes the running sum of time the pause button has been "true". The second while loop was an attempt to have the time not output again until after the loop was completed, so if the loop ran for 3 seconds, the sum would have 3 added. It currently functions the same as if there was no loop, but its easier to see the connections with the loop in. If pause is "true", I want to add time to a counter, but not to the sum until pause is "false" again. If I take out the sum, it counts time properly but reverts to zero every time pause is "false", so I cannot sum all the times it has been false. Please let me know if there is anything I can clarify, and thank you for your help!

0 Kudos
Message 1 of 5
(2,506 Views)

Your pause button belongs inside the loop, else it will only get read exactly once before the loop starts.

 

Can you show us the rest of the code? Currently, your loop burns 100% CPU while waiting.

0 Kudos
Message 2 of 5
(2,487 Views)

The rest of the code is not near working yet and has a lot of inputs, so I made a little code that maybe I can implement as a sub vi and save space. Putting the pause inside looks like it may have slowed the addition slightly, but its still adding all the increments. The end goal of this piece is to output the total time and the time minus the pauses (to later track how much time certain machines need to run, etc). I'm sure getting the time from the computer is less efficient than the tick counter, but I cannot make the tick counter work for this either. It jumps to 60000 or something right away.

0 Kudos
Message 3 of 5
(2,468 Views)

@Jamie_Stanton wrote:

 I'm sure getting the time from the computer is less efficient than the tick counter, but I cannot make the tick counter work for this either. It jumps to 60000 or something right away.


The counter value is irrelevant. The only thing that matters is the difference between two of them.

 

Your inner loop still needs​ a small wait.

 

A better way is a state machine without inner loops. "Paused" is just another state.

0 Kudos
Message 4 of 5
(2,466 Views)

I changed the Get Date/Time to Tick count. I am unsure how to implement a state machine in this case as the outer while loop is needed for the other inputs and functions I excluded in the example. Would I use an event structure in place of the while loop? I am trying to remake code that was so full of stacked sequences that it was hard to determine what was happening at all, so I would like to use flat sequences if absolutely necessary but subvi's if possible to make the code easier to read. What I really need to keep track of with this step is that a "timer" is paused and the program waits for pause to be deselected. The amount of time on the timer will be read from a file and correspond to a step. (ie, Step 1 should last 2 mins, step 2, 5 mins, etc) So the time paused should not affect the time left on a given step. Counting time paused to subtract sounded like the easiest way to accomplish this, but I am open to other solutions.

 

Thank you

0 Kudos
Message 5 of 5
(2,424 Views)