LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Master VI Timer

I have set up an instrument control project using the producer-consumer architecture. Now I would like to implement a "Master Timer" VI that can be started, stopped, and reset using the P-C VI. Furthermore, I would like to display the seconds and minutes from the sub-VI on the front panel of the P-C VI. I need the timer to start based on an event from the P-C VI (a button press), and stop on an event from the P-C VI (another button press). I have attached the timer (sub-VI) that I would like to use - it is fairly simple. Does anyone have any suggestions on how to implement this architecture as described?
0 Kudos
Message 1 of 5
(3,926 Views)

Hey Plato,

 

It is not entirely clear what you were trying to do in your VI, but:

  1. It was not a producer consumer architecture (check here for how to implement that architecture);
  2. You did not attach your global VI so I am not sure of the exact output you are looking for;

I have attached something that may be what you are looking for.  It uses a simple notifier triggered by an event in the producer loop to tell the consumer loop to start the timer.  The consumer loop will run at a rate of 10 Hz so that it does not have to wait for notification to calculate the time passed since the timing start was triggered.  You close the VI in the traditional Windows manner which destroys the notifier and results in an error in the consumer loop which triggers a graceful shutdown there.

 

Anyway, let me know if this is kind of what you are looking for.  Cheers, Matt

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

Hi Matt,

 

Thanks for the post. I suppose that the needs in my original post were not all that well conveyed. I did not post the P-C VI because of all the dependancies in it, and the global varaible in the VI posted was something I was playing around with, trying to get things to work. Perhaps my question has more to do with running a sub-VI and reading realtime data from it with a master VI. In my case, the sub-VI is the Timer.vi that I posted, and the master vi is the P-C that I did not post. I want the timer to run autonomously, but yet be controlled (start, stop, reset) from events in the master VI. What I gather from the discussion forums is that a global variable is appropriate in this situation. As the sub-Vi runs, it is writing data to the global variable. Simultaneously, the main P-C VI is reading and displaying that data.Perhaps I woud use global boolean variables for the start, stop, reset? I hope this clears things up...

0 Kudos
Message 3 of 5
(3,904 Views)

OK, now we are getting somewhere.  So the subVI is not really a subVI at all but one that runs independently yet concurrent with the VI which may control the start/stop of the timer?  There may be several approaches that you may be able to take.  The first is to use VI server - you can have VI server start the timing VI and then use the rerference to that VI to start/stop the timer (like the pic below).

vi_server_ex.png

The best option might be to create a functional global (especially if you have several VIs that might need access to the timing info.  David L has an example of a timing VI here that youmight be able to exploit.  Below is how you might use the functinal global to time when a VI starts, stops, etc.

timing_ex.png

Each time the reset is called the timer is reset such that the elapsed time indicator gives the time (in ms) since the last time the VI was reset.  

 

Is this understandable?  Does it work?

 

Matt

Message 4 of 5
(3,896 Views)

Thanks for the timing functional global! Found it useful for my project too.

 

Have a very pleasant day!

0 Kudos
Message 5 of 5
(3,695 Views)