LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared variables for transfering data between VI's

Solved!
Go to solution

I have trouble knowing if I should use data binding variables or network shared variables (or perhaps something else entirely. 

 

I have a cRIO-9056, I've created a VI where I read/write data from multiple modules, so far so good. But, I want to have my main display panel running on the host computer, that would make it easier for me to communicate with other systems that are connected through USB. So, I need to transfer data from the VI running on the RIO, to the VI running on the host computer.

 

To accomplish this I create the DAQmx tasks, and assign them to variables in the VI running on the RIO

Reading.png

 

Then to read/write data from the VI on the host PC I found three options

 

1) I use the open variable connection then read/write accordingly all of this running on a loop.

 

Approach1.png

 

2) I create the variables and then I use data binding on the properties tab.

Approach2.png

 

3) I create a shared variable and attach them to an indicator/control 

 

Approach3.png

 

When I run option 1, the VI starts immediately whereas with the other two options the "Deployment Status" window pops up and it takes a little while before I can start reading/writing. Apart from that I don't see any clear difference or advantage/disadvantages

 

so my questions are

 

1) Why option 1 runs with no delay, whereas 2 and 3 show the "Deployment Status' window.

2) Is there anything wrong with the approach I'm taking?. For the moment I have a preference over option 1, but I don't know if I can run into some issues in the future. Or perhaps this is a wrong way to do what I need.

 

 

Thanks in advance.

 

 

 

0 Kudos
Message 1 of 9
(2,918 Views)

Hello Andres,

 

Your code running on RT target looks good, but I also would suggest you to use better error handling e. g. merging errors of all tasks at the end of the code, and using a simple error handler. This can be helpful in further usage of the code. Also not forget to mention, If you don't have to acquire data from different modules at different rates, you can use one while loop and one stop button on RT VI, this can be helpful (sometimes local variables are not the best way to stop the loops). Your first approach is right, also it is mostly good to use network-shared variables to communicate between RT and Host VIs when you transfer Tag data.

Also at first run the RT VI and then start the Host VI, it is right approach to working with RT targets. 

 

Regards.

0 Kudos
Message 2 of 9
(2,861 Views)

Thank you for your input. I can merge the errors as you suggest, I think is a good idea. But, I do need the loops to run at different speeds, so for the moment I'd have to leave it like that.

0 Kudos
Message 3 of 9
(2,832 Views)

Hi Andres,

I hope you are doing well. Have you solved the problem? Is everything working properly?

 

 

0 Kudos
Message 4 of 9
(2,809 Views)

The VI is working fine, but I still don't understand why option 1 launches instantly and the other two have the "Deployment window", this difference in behavior is not clear to me.

0 Kudos
Message 5 of 9
(2,780 Views)
Solution
Accepted by topic author AMTS

I presume that such behavior is connected with the code structure. In the first case, you are using the open variables method, which doesn't need to deploy the code before running to get the data. The deployment process takes place while the code is running when the open variable sub VI is starting the process. In two other cases, the code has to refer to the RT target and project tree to get information about shared variables. 

 

I hope that this was helpful.

Best Regards

0 Kudos
Message 6 of 9
(2,778 Views)

Great, that makes it clear. Thank you very much.

0 Kudos
Message 7 of 9
(2,776 Views)

I forgot to ask one more thing. Is there a reason to prefer one method over the others?

0 Kudos
Message 8 of 9
(2,770 Views)

There are no major differences between these methods. They transfer Tag data (the last value). It is depended on your preferences and the task that the program must complete (as you could see one major difference was the deployment method). But anyway you can check it in the LabVIEW Help section, I think you can get more information there.

 

Message 9 of 9
(2,764 Views)