How can I create a subVI that has state?

I'm trying to simplify a VI that I inherited and I noticed a recurring pattern that IMHO should be a subVI.  The pattern is that we have a digital output line that is controlled by a timer.  Each output has a start time for it to activate and a duration after which it is turned off.  When the state changes, a single line entry is added to a common log file and an indicator shared variable is set so that the remote host VI updates.  We have a big while loop that checks the current time against each of the activation conditions.  To detect when the state has changed, we're using a shift register (for each actuator).  It's one thing to see the same pattern 3 times, but it's worse -- we want to sometimes use a different number of actuators.  If I was writing this in C++ (with which I'm far more comfortable than LabView), I'd write a class for the actuator and instantiate it N times.  The class would have member data to keep track of its state.  I can create a subVI that does the meat of the design pattern, but I can't figure out how to store the previous state in the subVI without requiring it to be passed in.  How do I keep the state and behavior of a VI together?  Surely there's a way to do this because otherwise I can't see how you could implement state-ful algorithms like, say, a PID controller.  But I'm at a loss to figure it out ...
Thanks.
Keith.

To save state in a subVI and not use that state in other subVI calls, make the subVI reentrant.  When a subVI that is reentrant is called it creates a unique memory space for that subVI.  This is called a clone.  That memory space is where state is held for that subVI.  Keep in mind that it also means that the memory footprint is going to be larger.
To set a subVI to be reentrant, open it and go to File -> VI Properties and select execution.  It will be a choice on the bottom left.
Hope that this helps,
Bob Young
Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
DISTek Integration, Inc. - NI Alliance Member
mailto:[email protected]

Similar Messages

  • How can I create an application that has no menu bar?

    I have an application which has all of its functionailty available on screen as buttons or fields. This works very well at the moment. However when I create and run the application I see a men bar appears nuch the same as when deisgning the application namely, "File, Edit, Operate, Tools,, Browse, Windows, Help". I really don't want them to appear at all as everything is already catered for on screen. I have looked at the menu vi's but it is not clear how I can simply not have a menu bar.
    Any suggestions?
    Regards
    Kevin

    Many thanks,
    I have asked a similar question to this before but for some reason I always think I need to do these sort of things programmatically in the code rather than in a settings.
    Thanks in any case.
    regards
    Kevin

  • How can we create a form that has a pay now (via paypal) or pay later option for events

    Hi we have people that attend events that do not like to pay online they pat at the door - so they are not completing the registration form so we are getting emails for RSVPs as well as form data so this has created more of an issue for us than solved our registration process.

    Check out this post: http://forums.adobe.com/message/4399918#4399918
    You can use skip logic to get the desired effect. If you have problems do it just reply back.
    Randy

  • Can you create a template that has a header and footer to forms?

    Can you create a template that has a header and footer to forms?

    Yes but how are they going to create the Landscape versions?
    The problem with doing it in Pages '09 as rotated content is that the Headers and Footers are not rotated and there is inherent clumsiness in the rotated content usually being too large for the page when viewed at 90°.
    Best to make it in two or more separate documents.
    Peter

  • How do i create a report that has drill-down with class?

    How do I create a report that has drill-down levels so that I can have summary information at the top level but then view specific records at a more detailed level?

    can i know ur email address.
    this is my other one coding
    but problem is very very slow when i 1 see my output
    TABLES: proj, coep.
    *&            TYPES DECLARATION                                        *
    *TYPES: BEGIN OF tb_coep,
             wtgbtr TYPE coep-wtgbtr,
          END OF tb_coep.
    DATA : int_proj TYPE proj OCCURS 0 WITH HEADER LINE.
    DATA : int_coep TYPE coep OCCURS 0 WITH HEADER LINE.
    DATA : gd_date(10). " FIELD TO STORE OUTPUT DATE
    TYPES : BEGIN OF t_date,
              year(4)  TYPE n,
              month(2) TYPE n,
              day(2)   TYPE n,
           END OF t_date.
    *&            SELECTION-SCREEN                                         *
    SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
    SELECT-OPTIONS: so_pspnr FOR proj-pspnr OBLIGATORY.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN END OF BLOCK b01.
    *&            TOP-OF-PAGE                                              *
    *&            fetch the data for the list                              *
    SELECT * INTO int_proj FROM proj where
             pspnr in so_pspnr.
    append int_proj.
    CLEAR int_proj.
    ENDSELECT.
    SELECT * into int_coep FROM coep WHERE
             wtgbtr in so_pspnr.
    append int_coep.
    CLEAR int_coep.
    ENDSELECT.
    LOOP at int_proj.
      write : / int_proj-pspnr, int_proj-post1.
    ENDLOOP.
    LOOP at int_coep.
      write : int_coep-wtgbtr.
    ENDLOOP.
    Edited by: Dickson on Jul 10, 2009 10:53 AM

  • How can I create a slideshow that depicts only a version of a photo rather than the original? Since the original and new versions are saved together, the aperture slideshow often choices the original rather than the desired version to display/

    How can I create a slideshow that depicts only a version of a photo rather than the original?   Since the original and new versions are saved together, the aperture slideshow often choices the original rather than the desired version to display.

    There are two things we use the name "Slideshow" for in Aperture:  a Slideshow Album, used for making Slideshows, and the Slideshow that is made.  (Imho, it is a design mistake to not call the containers used to create Slideshows, Books, etc., "Albums".)
    The Slideshow will use the Album Pick from any Stack.  A good way to use Aperture is to promote the Image you want to regularly use (such as, for example, a Version with adjustments) to the top of the Stack.  This makes it the Stack Pick, and will be the default Album Pick.  If you haven't done that, you can still change the Album Pick for any Stack in a Slideshow Album.  Expand your Stack(s), select the Image in each Stack that you want to be the Album Pick (and thus shown in the Slideshow), and "Stacks➞Set Album Pick".  (Note the keyboard shortcut; there is also a Toolbar icon for this.)  The change is immediate.  The Slideshow will always show the Album Pick (or, if there is not one, the Stack Pick) for every Stack in your Slideshow Album.

  • How can I debug a sequence that has a subsequence is running in a separate thread?

    Hi,
    How can I debug a sequence that has a subsequence is running in a separate thread?
    I have to have a continues check for a  digital in signal to be able to terminate the sequence if a physical button is pushed.
    This is running in a separate thread, but this way I cannot debug the main sequence.
    Is there any workaround for this?
    Thanks,
    Andras

    This KB might help you:
    http://digital.ni.com/public.nsf/websearch/46D1E157756C37E686256CED0075E156?OpenDocument
    Let me know if this does not help.
    Allen P.
    NI

  • How can i copy a picture that has been installed with the flash player

    how can i copy a picture that has been installed using the flash player

    You can't. You can take a screen cap of it, but the container doesn't allow access to the individual images used in a SWF or FLV.

  • In DPS/Indesign for iPad - How can i create a button that once tapped, will pre-populate an email?

    In DPS/Indesign for iPad - How can i create a button that once tapped, will pre-populate an email? like when you tap a recipe in Marth Stewart Every Day Food for example....

    http://forums.adobe.com/message/4190932

  • How can I uninstall an app that has locked my phone?  Can I uninstall the app online from my computer?

    How can I uninstall an app that has locked my phone?  Can I uninstall the app online from my computer?

    I don't know about uninstalling an app from a web page but if all else fails you could try recovering with the Nokia lumia recovery tool.
    FAQ - How can I recover/reset/restore my phone software? - Nokia - USA

  • How can you find an ipod that has been lost

    how can you find an ipod that has been lost and the icloud is not turned on

    lost/stolen                                      
    No app is required.                                               
    - If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    iCloud: Find My iPhone
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    iCloud: Find My iPhone
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    - If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
    - Change the passwords for all accounts used on the iPod and report to police
    - There is no way to prevent someone from restoring the iPod (it erases it) using it unless you had iOS 7 on the device. With iOS 7, one has to enter the Apple ID and password to restore the device.
    - Apple will do nothing without a court order                                                        
    Reporting a lost or stolen Apple product                                               
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

  • HT1420 how can i deauthorized a computer that has crashed. i have hit my limit but i have no way to access itunes on those computers

    How can I deauthorize my computer that has crashed. I have hit my limit but have no way to access itunes on any of those computers

    By using the Deauthorize All function.
    (69001)

  • How can I backup a drive that has errors?

    How do I backup a drive that has this error? So I can re-partition and reformat it.
    Starting repair tool:
    2013-01-12 16:35:55 +0800: Checking prerequisites
    2013-01-12 16:35:56 +0800: Checking the partition list
    2013-01-12 16:35:56 +0800: Problems were encountered during repair of the partition map
    2013-01-12 16:35:56 +0800: Error: Partition map check failed because no slices were foun
    I bought a new 3tb internal drive for my windows machine so I can backup an external drive which I didn't know was mac formatted. When I was trying to extend the capacity of my internal drives in wndows so it would add another 3tb I accidentally chose my exteranal drive and it changed the master boot record although I cancelled the process the drive won't mount in my mac anymore. And I get those errors in the disck utility.
    The data in it are very important I was trying to backup it to my sohotank harddrive enclosure which already had a 2tb and now a 3tb installed. Any help would be appreaciated.
    I'm now trying to create an image of the mac drive and had reformatted my 3tb drive to Mac just so I can place the image there. I don't know if it would work or it will jus take too long because the progress bar is not moving at all.
    Thanks!

    sp0radic wrote:
    I'll buy software if i have to.
    I prefer one full backup then incremental backups.
    maybe ChronoSync can do what you want.
    good luck !

  • How can I create an icon that when clicked will open and maximize an image file?

    How do I create a icon that when clicked will open and maximize an image file?  I have tried to use the simple image widget with maximize upon tap/click - however I am can only size the image really small and put on the page.  I'd prefer to have a graphic that when clicked it simply opens up the image.  This is for a very simple question/answer book.   The user is suppose to look at a picture and locate something.  I want to put an 'Answer' graphic on the image and then the user can click the 'answer' graphic and it will open up the picture with the answer identified. 
    Is this possible?

    Have yiu tried the PopOver widget?  You can drop an image into it, maximise the image and the widgets window...But, you cannot get it full screen.
    With iBooks Author, you either learn to use what is available within the app, or look online for third party widgets to purchase which suit your project.

  • How Can I validate an Cust_Id that has nubers and letters within it

    I am trying to validate a cust_id that has both numbers and letter in it. like this 111A12345678. the valid letters to be imputed are A,C,D,E,G,Z how can I validate this so that when the fourth character is any other letter than the above, like this 111B12345678 it display an error message that A,C,D,E,G,Z are the only valid letter that can be imputed in the fourth character.
    Your help is greatly appreciated
    Thanks
    Hank

    I think Sergio was wondering what Db version, 10G will give you regexp, if you're running 9i then a sql exists may do it for you
    select 1
    from dual
    where substr(:cust_id_item,4,1) in ('A','C','D','E','G','Z')

Maybe you are looking for

  • Schedule jobs witj job open, submit and close

    Hi gurus, I need to know if there is any way to schedule various jobs using the FM job_open job_submit and job_close. Like schedule the first job for a date and a hour and schedule others jobs to run after the first job sequential. Its this possible?

  • Can not open any open any web pages. Receive the following error message (Error code: sec_error_library_failure)

    I can not open any websites using Mozilla browser. I have attached a screen shot of the error message that I receive. You will also find it below: . Secure Connection Failed An error occurred during a connection to www.google.com. security library fa

  • JSC and running webapp

    Hi, Sorry if this is the wrong place to post this message, but I am new to the Java/JSC forums. I am trying to use JSC 9 and when I try to run a web app I am creating the IDE fires up my text editor instead of my web browser. In the options my defaul

  • Always looping RUnning Debt

    I'm already create 2 view using union to union the transaction 1. View Transaction (View For Union all the transaction debet n kredit) 2. View LAST_SALDO (View for find Last Customer Customer Debt) I have a problem when i query it looking for Running

  • Dimension variable shows two rows in Webi report

    Hello everyone! I want to build a report with the following structure: Account group 1 | KYF 1| KYF 2 For this effect, I've created a dimension variable called "Account group 1" with a formula like "GL account starts with "64"". With this I'm getting