05-23-2010 11:24 AM
Forgive me if it sounds silly. But I need some help on how to connect multiple VIs to the same Simulink model. We are developing a complex simulation model in MATLAB/Simulink with hundreds of model parameters that should be displayed to and manipulated by the users. We decided early on to use LabVIEW to develop the User Interfaces utilizing SIT Simulation interface toolkit to connect to the Simulink models. The reasons were that we used LabVIEW in previous project and were happy with it, it is easy to use to our clients, the LabVIEW User Interfaces mimics the real consoles very well and last but not least the Simulation Interface Toolkit documentation affirms that it is possible to connect multiple VIs with one model. I spent quite some time searching this site for some clue about this last fact without any success. Using global or shared Variables doesn’t help us a lot, because we have hundreds of model parameters to map to. It will make our already complex design even more complex. I suspect that the SIT Connection Manager as it is now cannot do it. I may need to make some modification to the template “sit Client VI Template.vi” or one of the SubVIs used in that template or even do all TCP connection, model initialization and parameter mapping myself from scratch using the VIs shipped with the Simulation Toolkit. Can anybody tall me where to start, before I may scrap the whole approach to realize this project using LabVIEW? I cannot afford to spend more time on this than I already did.
While reading the Simulation toolkit help document, I come across very enlightening examples on how to create a custom I/O Driver and custom FPGA VI with Simulation Interface Toolkit. Is there something like that on how to create custom Host VIs? The only thing I always come cross here is the following paragraph:
“.Using the Simulation Interface Toolkit, you can connect multiple VIs created on the host computer to the same Simulink® model. You also can connect multiple Simulink® models on the same computer to a single VI created on the host computer. “
It doesn’t say how. I do not know why NI did not come up with a similar example to demonstrate this fact. May be it is not as complicated as I think for the other LabVIEW users.
05-24-2010 10:33 AM
Good morning!
To clarify, do you want to have multiple VIs connect to a single model because you want to organize the parameters? If so it may be easier to use a Tab Control to organize your data (Controls palette»Containers»Tab Control).
Otherwise are you trying to have multiple VIs access the same models as it is running or do you want to have them access the model at different times? If it is at different times, you would simply set up the VIs the same way as if you were using a single VI.
Regards,
05-24-2010 01:55 PM
Thanks Tanya for the prompt response.
We are developing a simulation model with multiple consoles for a central control room mainly for a training purpose. The type and number of consoles are selected by our client and are to be designed as a separate VI. There is no room for a design change here. There is one main User Interface VI, which is responsible to start and initialize the model. The other VIs can be lunched from this Main VI. It is possible that user may lunch as many VIs as possible at same time. When the Main VI is lunched, it will create the TCP connection and loads the model, if it is not yet loaded. User can specify the model default parameters by selecting a file and then starts the model. From this point on, the model is initialized and running with the default parameter values. Now they can lunch one or more console VIs. When lunched a VI should connect to the already running model through the already opened connection and consume data. When it is closed, it should die gracefully without taking the rest with it or closing the connection.Is it possible to do the following?Check, if there is an already established connection. If there is not, so it is a new lunch and we know that this scenario works fine. If there is a connection, there is another VI already running. So it checks, if the running model is the same as the one specified in its sit Meta Info. If the model is the same, it just subscribes the data it wants without disturbing the existing traffic.
Best Regards.
Getachew
05-25-2010 09:11 AM
Hi Getachew,
The easiest way to do what you want to do would be to use shared variables. You could use the main VI to collect all the data, and write it to shared variables. If network-published shared variables are used, any computer on the network could potentially access the data. There are more complicated ways of doing this but using shared variables is by far the most straight forward.
Here's a tutorial that describes the different types of shared variables and how to use them.
http://zone.ni.com/devzone/cda/tut/p/id/4679
Let me know if this will work for your application.
Take care!
05-25-2010 03:23 PM
05-27-2010 09:51 AM
Hi Getachew,
I'm still working on a solution to connect multiple VIs to one running model at the same time.
As a side note, front panel controls and indicators can be directly bound to network-published shared variables by right-clicking them on the front panel and selecting Properties from the right-click menu. In the Data Binding tab you can choose a variable to which you want to bind. That would clean up the block diagram because you wouldn't have to drop down variable nodes.
05-28-2010 09:46 AM
Hi Tanya,
Thanks, this is a good advice. You know, I come from a text based programming background recently. So, there are many things I do not know yet. Thank you also for working hard on a solution to directly connect multiple VIs to same model.
Best Regards.
Getachew
06-01-2010 05:06 PM
Hi Getachew,
I am still looking into this issue for you. I've escalated this question to R&D and am still waiting for a response. Once I get an answer I will make sure the Developer Zone article is clearer.
Take care!
06-02-2010 10:46 AM
06-02-2010 03:46 PM
Hi Getachew,
I heard back from R&D and there cannot be more than one TCP connection to a model at a time. There can be one central VI communicating with the model and all other VIs would need to communicate to that central VI (not the model). This can be done using shared variables as we discussed.
The DevZone article was a little misleading, in that it meant that multiple VIs can connect to a model but not simultaneously.
As for using shared variables, to use an array type or waveform type you would want to use Single process shared variables or Network-Published shared variables. These can be accessed from a project in LabVIEW. Is your VI in a project? If it is not I would recomment including it in a project and using the above mentioned variable types to transfer data between your VIs.
Take care!