Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple VIs -> one Simulink model

Solved!
Go to solution

Hi all there,

 

I am trying to use LabVIEW as a user interface for a Simulink model.

According to the LabVIEW Simulation Interface Toolkit User guide -> "Using the Simulation Interface Toolkit, you can connect multiple VIs

created on the host computer to the same Simulink model".

 

And that is what I am trying to do. I have a Simulink model test3.mdl and I have generated two VIs: inputs.vi and display.vi.

I have mapped the controls and displays from the two VIs to the relevant parametres inside the Simulink model using the SIT connection manager, but when trying to run the two VIs and connect them to the Simulink model to modify parametres and display the outputs I get a conflict, only one of the VIs can be connected to the Simulink model at the same time.

 

Anybody know what are the steps to connect two VIs to the same Simulink model? SIT documentation claims that it can be done but unfortunately it does not explain how it can be done. The only examples are for connecting one vi to the model.

 

Thanks in advance

 

Jose

 

0 Kudos
Message 1 of 5
(3,703 Views)

Hi Jose,

 

Good afternoon and I hope your well today.

 

You are correct, that the documentation suggests this is possible. I have not been able to locate any resources to guide users through the steps. I am under the impression it is just more of the same - where you just select more controls/indicators.

 

I wanted to ask what version of SIT you are using? 

 

In the current connections window - does it show them correctly? 

 

Do the two VIs work sepeartely (to confirm)? I wonder if you have any conflicts with controls with the same name - is there anything in common between the two VIs? I would maybe try a really simple applicaiton... and very short names - just to give this the max chance of working. 

 

So when you run the first VI it works, and then when you go to run the second VI it errors? 

 

I would double check you haven't select the same control/indicator of the model for both host VIs.

 

Please let me know your thoughts, 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 5
(3,687 Views)

Hi James,

 

Thanks for your reply and sorry for not replying earlier, I have been trying several things to make this work.

 

The version of the SIT I am using is 5.0.

 

To explain you a bit more what I am trying to do:

I am running a simulink Simulation and using LabVIEW as an user interface. I have two screens, and I want to use the small for the user's data input to modify the Simulation's parametres, and a bigger one to show all the output graphs. So that is why I have two different VIs that I want to connect to the same Simulink model using the SIT connection manager.

 

Both VIs work properly separately, this is, I am able to connect them to the model using the SIT and modify parametres or display graphs depending on the VI. But when one of the VIs is connected to the model and the simulation is running and I try to use the SIT to connect the other VI to the simulation too, I get an error message, the VI that was connected to the simulation is disconnected and the other one is connected to the simulation, but never both at the same time can be running and interacting together with the Simulink Simulation.

 

What I have been trying this days has been to have a VI with all the controls and displays, where I execute the SIT (let call it "global VI"), and another one only with controls (lets call it "input VI"). By using shared variables, writing them in the "input VI" and reading them in the "global VI" I have been trying to use data binding and property nodes to modify the value of the front controls in the "global VI". This effectively changes the value of the front panel controls in the "global VI" according to the values given to the shared variables in the "input VI", but the SIT does not recognize these changes. The only way in which the SIT recognizes the change in the controls and applies the new values to the simulation is when I directly modify the controls from the "global VI". I guess this is something to do with the event structure that the SIT has to recognize changes in the front panel controls, but I still cannot understand why it does not react when the changes to the controls values come from data binding or property nodes.

 

Hope you can help me!

 

Thanks a lot,

 

Jose

0 Kudos
Message 3 of 5
(3,665 Views)
Solution
Accepted by topic author Joxe

Hi James,

 

At the end I have solved my problem with the second option I told you before: using shared variables to pass data between the two VIs.

But it has been a bit tricky to be able to modify the front panel controls' values for the SIT to recognize the change in the value.

 

I managed to achieve this by using the following structure for each of the fron panel controls inside the VI where the SIT is running:

 

 

NI_forum.JPG

 

 

In this case to write the value into the control called "Frequency", I have a shared variable "f" that is written in the other VI where all the data input is going to be implemented. Then inside the "Frequency" control properties, I have bound the control to this shared variable "f". And the using the structure of the picture I have managed to make the SIT react against the changes in the "Frequency" control and apply the new value to the Simulink Simulation.

 

The truth is that I still do not understand why the SIT does not recognize the change into the control without using all these stuff but it is working now.

 

So if you could clarify my doubts regarding this question and the issue with the two fron panels with the SIT, that would be great.

 

Thanks & Regards,

 

Jose

0 Kudos
Message 4 of 5
(3,662 Views)

Hi Jose,

 

Good afternoon and I hope your well today.

 

I am sorry I didn't managed to get back to this post until now. 

 

I am still unsure why you couldn't run two VIs as explained - I would ask you contact your local NI Support office and open a phone/email support request. This will allow us to get some more answers on this functionality - if your still interested.

 

I must admit, your solution is a good work around. 

 

The reason the Value(Signal) is the property you must use to alter the values of controls and indicators programmatically is the signal aspect creates an event.. and as you mentions, the events is what the SIT setup uses.

 

I hope I explained that ok, and best wishes with your applications.

 

Event Structure Does Not Capture the 'Value Change' Event When Values are Programmatically Changed

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 5 of 5
(3,644 Views)