08-24-2009 11:06 PM
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?
08-24-2009 11:11 PM
08-25-2009 06:27 AM
08-25-2009 04:22 PM - edited 08-25-2009 04:23 PM
Good Afternoon j_osh_o,
I believe that you have already found your answer but don't realize it . 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.
08-25-2009 06:24 PM