Create a subvi

hello,
I would like to create a subvi in labview 7.(I have a vi that I would like to reproduce 2 times in another Vi)

Hi Rémi,
in the upper right corner of your front panel you can see an icon depicted. It represents the code of VI as a subVI in anothor VI when it is loaded via "select a VI". Click rigth with the mouse on this icon and you get an context menu. There should be a menu point named "Show connector". The icon should change in a pattern of white sqaures. If you have in- and output structures on your front panel, the white should represent them in numbers. The rectancles on the left represents the input structures and the ones on the right the output structures. Take the "connect wire" tool and click the rectangle which should represent the data structure on the front panel und then click on the mentioned front panel structure. The colour of the recta
ngle changes from white to the colour of the used data type. E.g., if you have a simple Digital Indicator it should become orange for real values or blue for integer values.
If you load this VI now as a subVI with "select a VI" you should be able to see this connection on the icon.
Please keep telling me wheather my description has helped you.
Stephan

Similar Messages

  • 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]

  • How To Create a SubVi and Limit Required Inputs

    Hello,
    Description:
    I have created a VI that reads in voltage values from the NI USB-6008 device. After putting that value into a formula, I compare the new value with an array of data and output a corresponding value (this is not too important for the problem).
    Problem:
    The VI currently works great. My goal is to make it into a SubVi that can read in various channels and output their values. However, when I attempt to make a subVi thourgh Edit>>Create SubVi, the subVi created requires many inputs because of the many controls I utilize in the VI.
    What I want to do:
    Is there any way to use the default values of the controls in the SubVi and not require the user to input each control's value into the SubVi? Or, do I have to change my controls to be constants?
    Any assitance would be greatly appreciated.
    Attachments:
    YSI_R_to_T.vi ‏379 KB

    You don't have to create a subvi by using the Edit - Create Subvi button. Any vi can be a subvi. Go to the front panel, right click on the icon in the top right corner, select show connector. Figure out how many inputs and outputs you want to connect to the main vi. Right click on the connector pane and select Patterns, then the pattern that fits your needs. If you want to have the main send a channel and have the subvi send an output, choose the 4 connector pane pattern. Put Error In and Error Out clusters on your front panel. Wire the channel input control to the top left terminal of the connector pane, the output indicator to the top right connector, the Error In to the bottom left, and Error Out to the bottom right. It is good to use the Error In and Out to indicate errors and to help control execution order through data flow. Save the vi. In your main block diagram, go to functions - Select a VI, and select the vi you just saved, which now becomes a subvi to the main. You can wire a control to the new subvi top left, and so on...
    - tbob
    Inventor of the WORM Global

  • Create a subVI with fgv

    Hi,
    I Would like created a subVI with FGV of  my code in labview but  I cant see how to make the local variables to put them in subVI.
    Someone could show me an example with local variables in fgv pls?
    Best regards
     

    That VI really is something. How are you doing on LV Skills yourself? If you're new to LabVIEW I would highly suggest investing at least some time into the free courses and maybe even some money into a LabVIEW course.
    Here's a short list of the stuff available:
    3 Hour Introduction
    6 Hour Introduction
    LabVEW Basics
    Self Paced training for students
    Self Paced training beginner to advanced, SSP Required
    LabVIEW Wiki on Training
    Learning NI
    Getting Started with NI Products
    There you will learn many concepts of which I believe, FGVs, State Machine and Queue Driven State Machine (QDSM) should be particularly useful for you.

  • LV crashes when I Create a subVI

    I am a newbe with LabView, and I am working through some courses using the Student Edition.
    Every time I mark everything on this simple vi (written to try to isolate what conditions are causing this problem) LabView does a complete crash and burn. This only happens when I am using a local variable, although I am not sure I have implemented it correctly.
    Attached is the VI and the LabView error report.
    Regards,
    DerekS
    Attachments:
    Crasher.vi ‏19 KB
    lvlog07-26-04-21-36-17.txt ‏3 KB

    Hi,
    In your program there is no need of the sequence structure or even the local variable. I have attched a modified version of the vi that gives the same results as before but this one does not crash LabVIEW 7.0 when you try to create a subvi by highlighting. On another note, it is best if you create a subvi using the connector pane. Read on help for "creating Subvis from selection" on LabVIEW help to know what are the pitfalls when you create a subvi by highlighting.
    Attachments:
    Crasher_modified_lv_7.0.vi ‏14 KB

  • How do I create a subVI without controls?

    Greetings,
    I am going through some exercises to learn LabView and I have a question.
    One of the exercises in my book is to create a subVI that generates a random number within a min/max range.  (OK--re-invent the wheel)  I have the block diagram and I have the icon designed, but I am having difficulty in getting the connections wired.
    Right now it's a hard-coded static value for the min and max.  I'd like to have a connector in for each of the min and max (so that the parent can specify that however it wants be it with a static integer, an input, etc) and then a connector for the output--again, without a specified control so that the parent can take the value and run with it.
    How do I do the wiring?  I can obviously drop in controls into the front panel, but my parent project doesn't need the clutter of 3 extra controls coming up on it.
    Thank you,
    newbo
    Solved!
    Go to Solution.

    From the connector pane, you can right-click on a connector and select a setting.  You can set "This Connection is->" to Recommended or Optional.  This will allow the VI to be called without those terminals wired from the parent VI.  If left unwired, the default values you put in the controls will be used.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to copy VI and create new subVI paths

    Hi all,
    I'm still pretty new to LabView, and I'm not sure how to properly do this..
    Basically I have a working VI which validates a chassis, but I want to use the code on another chassis. The only differences (that I know of) are the login name and password for the new chassis. I enter these two fields using string constants in a subVI.
    If I simply copy the directory of the VI and all the subVIs to a new directory, and open one of the new .VIs, any of my changes are updated to the original VI. How do I break the links to the 'old' files?
    I want to have separate directories for chassis "A" and chassis "B" with all the necessary VIs and subVIs in each, even if the files are redundant on the hard drive (in case the VIs or subVIs need minute changes).
    Sorry for the vagueness in the subject, by the way.
    Solved!
    Go to Solution.

    Are you using projects?
    Copy the code to your new location.  Create a project and add the folder that contains your code.  Use the conflict resolver to fix your VIs.
    In some weird situations, I have also been known to delete the old project, resolve the conflicts for the new project, and then restore the old project from the recycling bin.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • When to create a subVI

    Happy new year folks
    My question is based on style.
    Should a SubVI be created with the view of simplifying a main VI or with the view of a general purpose. To make my question more clear i'll state an example. 
    I have a Cluster of 4 controls and based on the value of one control i must increment or decrement another control. Now, do i pass the complete cluster into a subVI and unbundle inside or Send in only the two controls involved in the process? because the other 2 control valuses would remain unchanged. Doing the former would make a simpler Main VI and the latter would permit me to use this same Sub VI somewhere else.Which is a better practice to use?
    Thank you
    Solved!
    Go to Solution.

    Personally, I think I may have had 2 subVIs in my CLD.  If you go for the subVI, make sure it is a concise function.  In the exam setup (because of time), go for the ease of reading (which will also be tidyness).  In your exact example, I wouldn't make the subVI unless it was something that I would need in multiple places.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to create a subVI to Clear all charts data on a main VI

    Hi all,
    As I am writing a subVI to clear all the "charts" data on a main VI.
    The number of Charts is unknown, beasue this subVI need to run at
    difference main VIs. Therefore, I can only input a ref. of main VI into
    the subVI and find out all the control ref.,then check the classes of
    the control. If it is a chart, I need to use "To More Specific Class" to
    to select waveform chart. However, if the property node is not create
    from the chart directly, the "histroy data" will be missing.
    No matter my concept to build this subVI should be right, I donot succeed.
    Are there any other methods to do that?  
    regards,
    Ryan

    parthabe wrote:
    Did you file a bug report with NI, Coq?
    No i did not. I got it working with some diagram cluttering, and forgot all about it. As my motto is "If the damn thing works, ship it"
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Edit - Create SubVI results in error "an input parameter is invalid [...] cannot save VI"

    I get this error with some frequency.  I select a bunch of my block diagram, create a subVI only to find that it is unsaveable.  Here are the steps I take to reproduce this:
    Select a portion of code
    Edit -> Create SubVI
    open the new subVI
    try to save it and this message pops up (without showing the Save dialog)
    I get past this by saving a snippet and making a new VI.
    I'm using LabVIEW 2012 on Windows XP, but I had it happen with LabVIEW 2011 as well.
    I read through this thread, but it's not the same situation because my message doesn't have an associated error code.  No variation of "Save As" has any effect, either.
    Has anyone else seen this behavior?  Have you any suggestions to help me resolve it?
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

    Greetings, Jim;
    I see the error happens with some frequency, is there anything that seems to bring that error to light or does it just seem to happen randomly when saving to a SubVI? That is to say, does it seem to happen when you are using/saving a particular set of VI's or a module or some such, or completely haphazardly? Is there any hardware that you are attempting to connect to in that VI as well?
    If you try to save the SubVI and get that error, can you simply save the main VI again without a problem? Finally, you have also seen this behaviour in 2011, did it happen with similar frequency?
    Cordially;
    Simon P.
    National Instruments
    Applications Engineer

  • Create subVI from single wire

    This must have been dealt with somewhere, but I can't find it and before I submit it as a suggestion or report it as a bug, here it is:
    If I select a piece of wire and go to Edit>> Create subVI... nothing happens. I would expect a Vi created with an input and output having the type of the wire.
    Comments welcome.

    The question is valid but at the moment it is not possible to create a subvi frm a wire.
    Maybe you should suggest it in the ideas exchange.
    T sometimes place a one frame flat sequence, hook up all the wires I need, then convert it into a subvi.
    LabVIEW Champion . Do more with less code and in less time .

  • Create subVI Control from Reference Name Bug

    If you connect N references to a sequence structure and create a subVI from this structure, the first N-1 controls will have the name of the original control (desired), but the last one will not. It will have the name of the generic type of the control this reference is pointing to. Of course, if N = 1, that means that the created control will have the generic name.
    Illustration:
    In the diagram above, subVI 1 has been created from a sequence to which a reference to "Numeric Control" was connected. Here is the FP of that subVI, as created by LV:
    subVI 2 was created from a sequence to which both references were connected. Here is the FP of that subVI:
    This does not seem to depend on the type of the control. If I add a graph:
    the created subVI looks like this:

    Kind of an extension of this bug, but not exactly the same. Might be due to the same cause though
    If you create a subVI incorporating Property Nodes (not recommended in general for performance reasons, but not a killer either), the subVI will obviously have references to the corresponding controls as controls and references to the controls will appear in the calling VI:
    Before:
    After:
    (it never ceases to amaze me how bad the cleanup/auto-routing algorithm developed by NI is :-)
    Here is the corresponding FP of the created subVI:
    This time, never mind the names of the original controls, they will be ignored, no matter how many different controls there is.
    (I am not even mentioning the well-known feature that if instead of enclosing the property nodes you just enclose the wires coming from the "Value" node, the subVI's controls will read "Value, Value2", etc, where the type of the "Value" controls will in general have absolutely nothing in common).

  • How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

    Hi.
    I think this is a pretty basic LV question, but I have not been able to find a good solution.
    I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.
    The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.
    Can any one suggest a good solution?
    Thanks,
    AlejandroZ
    Attachments:
    CallingVI.vi ‏7 KB
    subVI.vi ‏8 KB

    Hi.
    I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:
    I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.
    Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.
    As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.
    One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...
    There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.
    Thanks for all your responses.
    AlejandroZ

  • Subvi terminals in loops

    I'm trying to create a subVI from a VI in which most of the controls and indicators (that will become the terminals of the subVI) reside in loops. I then connect the resulting subVI into a wrapper VI.
    One boolean control within a while loop in the subVI is assigned to a terminal. If I connect a button in the wrapper VI to this terminal, the subVI doesn't seem to notice the input from the button at all. If I push the button on the subVI front panel, however, this works fine.
    For indicators that reside in loops, the corresponding output terminals do not seem to reflect the subVI outputs either.
    What am I doing wrong?

    Barry_Wealand wrote:
    What am I doing wrong? 
    You don't understand dataflow yet.
    A subVI receives values on all inputs when called and returns values on all outputs after it completes. The callling VI cannot continue with anything depending on the subVI output and thus it will also not read the control you are changing until the next iteration. Once called, all operations are local to the subVI. You can do what you are trying to do by wiring control references into the suVI and read values via value propety nodes wired to the references, for example. There are many other ways, though. Some better than others.
    It would probably help i you could describe what you are trying to achieve with all this. Most likley there are much better solutions. Why is there a loop in the subVI?
    Can you attach a simplified version of your architecture (i.e. toplevel VI and subVI)?
    LabVIEW Champion . Do more with less code and in less time .

  • Reading main VI front panel in SubVI

    Hi,
    I'm trying to create a subVI that writes a header text file containing info on essential parameters in my measurements. My mainVI front panel has a few dozen controls, some of them contained in a handful of clusters. 
    What I'd want is just to be able to access and read the values at the subVI to construct the string I want to write to the file.
    I wouldn't like to proceed the dumb way, i.e., building an array of clusters or individual controls or references to them and passing that to my subVI (and, obviously not passing each individual control/cluster as a subVI input).
    I figured I'd like to have some kind of refnum of the mainVI frontpanel passed to my subVI and dig use a big pile of property nodes to dig out the info that i need, inside the SubVI. Is this a feasible solution and if so, what's the way to conduct it? If not, what would be a better way?
    As before, I'm using LV7 so in case you answer with block diagram examples, I'd appreciate screenshots of them.
    Thanks,
    Lauri

    Vostokki wrote:
    I'm trying to create a subVI that writes a header text file containing info on essential parameters in my measurements. My mainVI front panel has a few dozen controls, some of them contained in a handful of clusters. 
    What I'd want is just to be able to access and read the values at the subVI to construct the string I want to write to the file.
    I wouldn't like to proceed the dumb way, i.e., building an array of clusters or individual controls or references to them and passing that to my subVI (and, obviously not passing each individual control/cluster as a subVI input).
    Lauri
    Actually that is the preferred way to do. Why you may ask? It is because you decouple the functionality (creating your log file header) from your specific user interface. By doing so you can reuse this VI in other places or applications. By using the references directly this ties the subVI to the calling VI. Unless the subVI is specifically doing something to the UI itself a subVI should avoid accessing data it needs via direct references. It should require the data to be wired in with the appropriate clusters, arrays or whatever your data needs are.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

Maybe you are looking for

  • How to reprint the Device Configuration page?

    Im installing my new printer for first time and was parially thru the wireless connection option set up and it printed off the Device Configuration Page but the page was partially blank and now I need the  printer IP address to complete the install a

  • ITunes 64 bit setup failure

    Recently i upgraded my computer from XP to windows 7 home premium 64 bit, i downloaded iTunes 9 64 bit and when finished clicked run only to be met by a message saying the digital signature was invalid. I started up the setup again by clicking on the

  • Adobe Reader 8.1 plugin error

    I've uninstalled and reinstalled Adobe Reader 8.1 and have even run the patch for 8.1.2 and yet ever time I try to either open Adobe reader or a pdf file, I get an error message saying "Invalid plugin detected, Adobe reader needs to close" and I am u

  • Anyone familiar with thunderbolt bridge on a mac air?

    Greetings cyber community, anyone familiar with Thunder Bolt Bridge on the Mac Air...it seems to be set up on my computer, & I have no clue.. Thx

  • List of Functional Module and BADIs

    Hi Forum, I m new in this CRM, started as a CRM functional. Just want to know from where can i get list of all FUNCTIONAL MODULES and BADI. and also is it mandatory for functional consultant to have gud knowledge and expert in usage of mentioned BADI