LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically stop tick count

Hello everyone,

 

I am working on a stopwatch VI to learn LabVIEW.

 

The way the VI is supposed to work is that when you press the "Play" button, the stopwatch starts, when you press the "Pause" button the stopwatch stops and to resume counting you press the "Play" button again. I still haven't gotten to the "Lap" button and the stop button is giving me some errors that I believe will be solved when I incorporate it to the main VI.

 

Basically the indicators for seconds, minutes, and hours stop incrementing, but in the background they are still increasing and once I press "Play" they get updated and resume counting. Basically, my pause button only pauses the indicators.

 

I was thinking on using some sort of disable or case structure to stop the tick count, but I am not having a lot of success on this.

 

I am using LabVIEW 2018

 

Thanks!

0 Kudos
Message 1 of 5
(967 Views)

The tick count is providing a measurement of a clock that continues to tick independent of your program.  That's why you're looking for a starting time and using that to calculate elapsed time.

 

When you pause, you pause with a certain amount of time elapsed.  Your original logic abstracts doing this.  For the original, the offset is 0 so you can ignore it.  When you pause, you want to maintain your offset.  Implement some logic to keep the state of your timer at the pause and add that to the updated elapsed time after you un-pause.  When you reset the watch, initialize that state to 0

0 Kudos
Message 2 of 5
(939 Views)

I had tried this as well before, but I was running into an issue where the "Play" button still retained its old value, most likely because when the button is disabled it looks as though it was still being pressed. To fix this, I changed the mechanical action of the button from "switch when released" to "switch until released", but now the pause button is not working.🤔

 

I feel I am making a big rookie mistake, I just cant pinpoint it.

 

Any advice is well appreciated!

0 Kudos
Message 3 of 5
(894 Views)

Hi ht,

 


@ht210 wrote:

I feel I am making a big rookie mistake, I just cant pinpoint it.

Any advice is well appreciated!


Well: rookies often don't know the difference and importance of those switching modes…

For user interfaces you most often want to use "latch when pressed" mode - and stay away from local variables!

 

I also recommend to use the HighResolutionTime value as it already comes in unit "seconds":

It really simplifies your calculations!

It also helps to format that "time" indicator as "relative time, HH:MM:SS with 3 digits"…

 

  • There are a lot of "default if unwired" tunnels in your VI: do you really think this is a valid setting when you want to retain values when executing those different states?
  • Why do you append the "Lap" 1D array to an empty 2D array? Does that makes sense to you? Why don't you use one more shift register to hold previous lap data?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(878 Views)

Thanks for the advice GerW.

 

My question is, wouldn't I still need to format the output of the HighResolutionTime to show HH:MM:SS since the actual output if I wire it straight to an indicator is seconds?

 

To answer your questions:

  • There are a lot of "default if unwired" tunnels in your VI: do you really think this is a valid setting when you want to retain values when executing those different states?

I noticed using the "default if unwired" option gave me some issues before, but to be completely honest i am not sure how to go about this particular issue. Is there a better way to do it? If use use shift register the end result would be the same since its storing the last used value right?

  • Why do you append the "Lap" 1D array to an empty 2D array? Does that makes sense to you? Why don't you use one more shift register to hold previous lap data?

What I am hoping to accomplish, is to save the most current lap time when you click the lap button on the 1D array. Any subsequent presses of the lap button will push the lap time from the 1D array to the 2D array to have a history, so to speak, of all the lap times. I guess i could just get rid of the 1D array altogether and just keep a history on the 2D array given that this method works.

0 Kudos
Message 5 of 5
(825 Views)