klove Posted January 25, 2005 Report Share Posted January 25, 2005 Could someone kindly set a new user straight on this... I need to create multiple instances of the same sub-VI to communicate with some number of identical devices on an RS485 bus. I have flailed about using a couple different methods that I have come across in my searches as follows: 1. Used a call by reference node. Result: could only create one instance of the VI. Pehaps I need to make the VI re-entrant, but what I really want is multiple independant instances of the VI... 2. Tried the OpenG "Open_VI_Clone_Reference" function but can't make anything open at all. Does anyone have some simple example code using this method? 3. As I understand it, I should be able to also do this with something known as a VI template, but as of yet have been unable to find any documentation on this. I would really appreciate some guidance on what direction I should be heading with this, and perhaps a simple example of creating the multiple instances. Thanks, Kirk :headbang: Quote Link to comment
didierj Posted January 26, 2005 Report Share Posted January 26, 2005 1. Used a call by reference node. Result: could only create one instance of the VI. Pehaps I need to make the VI re-entrant, but what I really want is multiple independant instances of the VI...3. As I understand it, I should be able to also do this with something known as a VI template, but as of yet have been unable to find any documentation on this. 3670[/snapback] Combine the two methods: 1. create a template (see picture) the same way you would do with a normal vi. Vi and templates are same, except of the tailing "t" in the file extension. In the explorer (for Windoze) one can convert from one type to the other by removing/adding the "t". 2. Call this template with the "call by reference node". LV creates a vi-instance of this template, and you are not limited to one instance. Didier Quote Link to comment
Michael Aivaliotis Posted January 26, 2005 Report Share Posted January 26, 2005 Here is a presentation with lots of examples that explains how to use templates with process spawning (multiple VI instances): http://lavausergroup.org/niweek2004/meetin...niweek_2004.zip Quote Link to comment
Mike Ashe Posted February 8, 2005 Report Share Posted February 8, 2005 In the OpenG toolkit there is a VI that you can point to any other VI and it will make a copy of your VI, as a template, then open a copy of the template, (get it into memory) then delete the physical copy it just made. Palettes>>Application Control>>OpenG Application Control>>Open VI Clone Reference. Not only is it a nifty VI, it is a good, compact example of templates, etc. (But you should still study the NI Week 2004 presentation referenced above). Quote Link to comment
David Boyd Posted February 8, 2005 Report Share Posted February 8, 2005 Let me chime in here just to suggest that the application may neither require nor benefit from multiple instanciations of a VI. The only thing I know about the application so far is that you have multiple identical devices with which you need to communicate (and thus perhaps maintain state information on them). But you also said that they share a common RS-485 bus. So, is it correct to say that the system hardware constrains you to only communicate with one device at a time? If this is the case, could you do all your operations in a for loop, indexing on some array of state clusters? Unless the devices may be in multiple states requiring more or less access to the shared resource (the RS-485 communications channel), it may be much simpler to design a system that just traverses from device 0 to device N-1, calling a common code block that takes state info as input and produces state info as output. The array can grow or shrink at runtime as needed to accommodate device additions or deletions if this is a requirement. Fundamentally all presentation to the user interface begins with arrays of controls/indicators, which may appear as tables or lists. If you choose to go the dynamically instanciated VI route, you'll still need some mechanism (a semaphore, or a non-reentrant subVI) to marshal the access to the shared resource. Your call - I've designed such things both ways in the past. Just figured it wouldn't hurt to ask about the particulars a little more. Best regards, Dave Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.