LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-blocking stopwatch indicator?

I would like to build a panel that controls two instruments and tells you how long they've been running. The instruments have , which is easy enough to program into an event structure. I would like to display a stopwatch to the user indicating how long the instruments have been on, and stop running when the user clicks "Stop Instrument". What's the simplest way to go about this? The stopwatch does not get any information from the instrument, it's strictly internal to the computer. I would like to be able to process other events while the stopwatch is running. I have 7 total events.

 

I have tried the Elapsed Time express vi but can't figure out how to wire it such that it resets and starts the stopwatch when "Start/stop" is true and stops when "start/stop" is false.

 

Thoughts?

0 Kudos
Message 1 of 11
(455 Views)

There is insufficient information here. Can each instrument start and stop on its own or is it sufficient to have a single time indicator?

 

You typically would have a timeout case that executes are regular intervals just to update the time. We can give more specific advice once we see your code. (We also need to assume that your events are sane and complete quickly and don't contain interactive code.)

0 Kudos
Message 2 of 11
(434 Views)

Good questions - each instrument can start and stop on its own, but I have some logic around one of them that makes it automatically stop after dispensing a certain volume. However, when it automatically stops, I would like its timer to keep running, since I want to be able to monitor how long an analyte is parked in a certain region of my flow loop.

 

In the attached (working) code, event [4] handles the redox syringe pump while event [7] handles the analyte syringe pump. Both pumps are identical. You'll see some missing VIs, those are the drivers for the NX-50 that you can find thru Labview's Help>Find Instrument Drivers. However, I've modified a few of the files to be more straightforward or to expose additional data.

 

In practical use, I will only ever use one pump at a time, so I suppose a single timer is sufficient.

0 Kudos
Message 3 of 11
(415 Views)

You should do a "save for previous" (2020 or below) before attaching, else I cannot inspect your VI.

0 Kudos
Message 4 of 11
(403 Views)

How's this? Save for Previous only gives version numbers, not years, so I did v20.

0 Kudos
Message 5 of 11
(398 Views)

Here is a very quick draft that can give you some ideas...

 

(In principle you could use a completely parallel while loop with an event structure that just reacts to the instrument control and does the timing in parallel. Useful of some of the events take a bit long. Not shown)

 

(Sorry, attachments don't seem to be working at the moment. Will try later)

 

tried again, this time by drag-drop (instead of browsing to file) and it apparently worked. <shrug>

0 Kudos
Message 6 of 11
(351 Views)

Since LabVIEW 2009, version numbers have been (Year - 2000).(Service pack number), so it's only on 8.x versions and before.  However, the VI you posted appears to be in version 18, so... success?

 

Just on a quick glance it appears that your program does a bunch of setup, then drops the user into an event structure.  For starters, I'd advise that instead of doing that, look into putting the whole thing into something called a "state machine".  There should be plenty of examples for that you can look up online.

 

On another quick note, you probably have a lot of problems with your VISA references dying because in a lot of your cases you don't pass the references through.  You should un-check the "use default if unwired" option on these to prevent the reference from resetting.

 
 

 

 

To more immediately address your main issue without refactoring anything, you would need to start using your "timeout" case in the event structure.  Wire up a value to the timeout input such as 100 ms, then set your code up to do whatever you need to do to monitor time elapsed each time that timeout runs.

0 Kudos
Message 7 of 11
(343 Views)

That's a good interface that accomplishes much of what I'm trying to do. However, it seems like the stopwatch resets itself when you stop the instrument. I'd like it to remain at the stop time until the instrument is started again, so we can record times.

0 Kudos
Message 8 of 11
(312 Views)

@bendrinksalotofcoffee wrote:

That's a good interface that accomplishes much of what I'm trying to do. However, it seems like the stopwatch resets itself when you stop the instrument. I'd like it to remain at the stop time until the instrument is started again, so we can record times.


Well, you did not give any detailed requirements, but that would be a trivial change to make. Try it!

0 Kudos
Message 9 of 11
(284 Views)

@altenbach wrote:

@bendrinksalotofcoffee wrote:

That's a good interface that accomplishes much of what I'm trying to do. However, it seems like the stopwatch resets itself when you stop the instrument. I'd like it to remain at the stop time until the instrument is started again, so we can record times.


Well, you did not give any detailed requirements, but that would be a trivial change to make. Try it!


Try this rough draft....

 

0 Kudos
Message 10 of 11
(281 Views)