LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I reset get date/time function in a while loop? (stopwatch)

Hi, here is my problem:

As part of a bigger VI, i want to make a stopwatch to measure duration of changes in output voltage of an infrared sensor. I've already made the subVI to recognize changes and return a boolean value (works with level crossing).

I have problems with the stopwatch subVI. It's "get date/time in seconds"-based, it subtracts the starting time of the subVI from the current time (see attachment). It works perfectly for the first time, but once it's triggered, it continues to measure time from the first trigger point, and doesn't want to update the starting time, no matter how kindly I ask it to do so. From then on, the inbound boolean value only switches the display on and off. I tried modifications, but I can't figure out the solution. How could I reset the function, or what another way could I build a simple stopwatch? Thanks for your help!

0 Kudos
Message 1 of 10
(3,798 Views)

Try a forum search with the keyword "stopwatch" and you will find a solution.

 

Ben64

0 Kudos
Message 2 of 10
(3,771 Views)

can you post the snapshot of your vi to understand the problem i cannot open your vi because of version conflict.

0 Kudos
Message 3 of 10
(3,764 Views)

@Grasshopper98 wrote:

..., no matter how kindly I ask it to do so. 


Make sure the microphone is on. 😄

 

Seriously, as a cheap workaround simply use the "elapsed time" express VI. You can even open it and see how it does it.

 

In order to reset, you need to change the value held in the shift register or feedback node. This hint should be enough, try to fix it now. 😄

 

Under what conditions do you want to reset the start time? (whenever the boolean is off? Whenever it goes from off to on?, etc.)

 

 

(Also please don't maximize the front panel or diagram windows to the screen, especially for small VIs like this. Very annoying! A toplevel loop like this needs a small wait, there is absolutely no reason to spin the loop millions if times per second, consuming all available CPU. Overall, the VI is very poorly constructured and you should probably start with a few tutorials before you continue with more complex problems.)

0 Kudos
Message 4 of 10
(3,752 Views)

I would recommend just using the Elasped Time function that is already in LabVIEW.  Yes, it is an express VI, but it works really well for this kind of thing.


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
0 Kudos
Message 5 of 10
(3,743 Views)

snapshot.jpg

0 Kudos
Message 6 of 10
(3,701 Views)

Is there any reason why you would post a screenshot of your entire desktop, showing basically the VI you attached earlier and a lot of extra garbage? Keep the noise down, please! And please add some text to the post to tell us what the question is. Thanks.

0 Kudos
Message 7 of 10
(3,682 Views)

Is building a stopwatch part of a homework assignment?  I'm guessing because your screen shot is useful in that it shows you are using a student edition.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 10
(3,669 Views)

No, it's not a homework. Unfortunately my high school doesn't teach us this kind of stuff, so I'm an autodidact. This project will be for a competition, and NI provides a myDAQ kit with the Student Edition.

So, my problem is still this stopwatch thing: I want to measure the time that my lab-rats test subjects schoolmates spend with obstructing the way of an infralight across a corridor. I've figured out that I should reset the value held in the feedback node, but I don't know how, so that's why I originally posted the question. I've also looked at the elapsed time VI after your suggestion, but I find it a bit strange, that I have to give the starting time, I thought that it would be much easier to assemble a simple boolean-triggerable stopwatch with this otherwise sophisticated, handy program, that does not fill half of my screen.

So any ideas on resetting the time value? It always should start when the boolean is TRUE, and when it becomes FALSE again, then it should should stop, spit out the measured time, and then when it gets triggered again, it should refresh the feedback node with the actual time, if possible, and do the same thing all over again. It would be just an extra stuff, I'm working on it as a side-task, so I didn't really have time to dig myself into big stopwatch-diagrams. If I cannot keep it simple, I might just drop it, but I'm gonna make a try with this elapsed time VI. So thanks for the help, and I'd be grateful for any other tip. And sorry for the snapshot, I knew it's not really good, but I was in hurry. Smiley Embarassed

(Also, altenbach, at the end of your first response, I couldn't clearly understand the problem you wrote down. It might be my English or my insufficient programming knowledge, but could you be more detailed about what's wrong with the subVI's resource consumption?)

0 Kudos
Message 9 of 10
(3,644 Views)

Well Welcome to the forums!  and yes, few public high schools teach what you can learn here by accident.

 

Of course, fewer high school students are really interested in learning.  You may be the exception.  look here

a resetable, pausable, timer ins't exactly "Basic" but it is common.

 

Keep learning!


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(3,637 Views)