LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Elapsed Time express vi reset question

I am studying the example questions for the CLD exam, and they use a lot of timed events, so this leads to the use of the Elapsed Time express vi.  I am tearing my hair out to figure out how this thing works.  If it was my own project, I would just write my own vi, but for the CLD you need to use what is available and do it fast.

 

This is my understanding of how it works.  I know I am wrong somewhere, but I can't figure out where:

1) When you execute the Elapsed Time vi after reset or the first time it is called, it marks the current time and stores it.

2) The next time you call the vi, it looks at the current time, compares it to the stored value, and outputs a true on the "time elapsed" wire if the elapsed time is greater than the target time value.

3) The NEXT TIME the Elapsed Time vi is called, it should automagically reset itself, store the current time, and switch the "time elapsed" output to false.

 

It seems like sometimes this works, and sometimes it doesn't.   In elapsed_time_reset.vi the Elapsed Time vi never resets itself after time elapses, but in elapsed_time_reset_use_subvi.vi it works fine.  Can anyone explain this?

0 Kudos
Message 1 of 5
(7,137 Views)
Attached is the version I intended to attach:
0 Kudos
Message 2 of 5
(7,136 Views)
The problem seems to be with the autoreset functionality.  When I have an Elapsed Time vi in each case of the case structure, the autoreset does not seem to work.  When I make a subvi that contains an Elapsed Time vi in it, and use it in all cases of the case structure, then it works.  I cannot understand why the behavior changes like this.  Any hints would be welcome.
0 Kudos
Message 3 of 5
(7,116 Views)

Good Afternoon j_osh_o,

 

I believe that you have already found your answer but don't realize it  Smiley Happy.  By default, when a VI is created, it is ready to be used as a sub-VI (except that it won't have a configured Connector Pane, by default).  The default setting is to not allow reentrant execution.  This keeps memory usage lower by only creating one copy of the VI in memory.  The following links have more information on the topic of reentrancy.

 

Differences Between Reentrant VIs (Preallocate), Reentrant VIs (Share Clones), VI Templates, and Dynamic VIs

     http://digital.ni.com/public.nsf/allkb/98847B4E4C715E6D86256C59006B57CC?OpenDocument

 

 

Multithreaded Features of LabVIEW Functions and Drivers

     http://zone.ni.com/devzone/cda/tut/p/id/6411#toc2

 

 

By having two separate Express VIs in your non-sub-VI version of the code, you have created two instances of the Express VI in memory--each with it's own count in memory.

 

I made a quick (and not particularly efficient) modification to your elapsed_time_reset.vi to show one way in which you can obtain the same results as those when you implmented the Express VI as a sub-VI.

Message Edited by AE Charlie on 08-25-2009 04:23 PM
Message 4 of 5
(7,102 Views)
Hi Charlie, thanks a lot for your reply.  I definitely need to learn more about reentrant VIs.  I did figure out what I had done wrong, it was a misunderstanding about how this VI works, which is partly because I am just now learning about action engines.  The Elapsed Time vi is an action engine, where a USR holds the last time the VI was reset.  So as soon as the vi triggers "time elapsed", it starts timing the next interval.  I had assumed that the timer freezes after trigger, and then restarts the next time it is used, but this was wrong.  I did make my own action engine that works this way, and it may have some practical uses...
Message 5 of 5
(7,095 Views)