11-27-2009 10:12 AM
11-27-2009 11:06 AM
Hey Plato,
It is not entirely clear what you were trying to do in your VI, but:
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
11-27-2009 11:54 AM
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...
11-27-2009 12:17 PM
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).
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.
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
04-12-2010 08:43 AM
Thanks for the timing functional global! Found it useful for my project too.
Have a very pleasant day!