07-27-2010 12:49 PM
Hello All,
I want to be able to communicate between two different projects on two separate machines. My setup is quite simple and is shown in the figure below. I have a cRIO connected to a switch along with two other PC's. I want to be able to access a hardware reading from the cRIO on two separate machines on the same network. I have tried several different ways, but have not done so with success. Any information or help is greatly appreciated.
I will describe briefly what I have tried so far. First I added the cRIO to both projects but that does not work considering only one project can control the cRIO at a time. Since the variables for the cRIO I thought that perhaps I would be able to grab the variables published to the network but this was not the case. So next, I tried to create my own variable/library and add this library to each project. The problem with this is that each project starts its own variable service, creating an instance of each variable, so when when I write to the variable in one project the other project does not receive the updated variable because it is looking at the wrong instance.
There are two solutions that I am fairly certain will work but I am trying to stay away from them considering they are non-optimal solutions. The first solution is to add my VI in the project with the project reading the cRIO. Since someone else is developing that project, I do not want to update projects constantly with new revisions and having to cross projects. The other solution is to pass the variables over TCP/IP or UDP. I have done variable communication between VI's this way before but the coding involved is not optimal and again, does not allow for easy integration between the two projects.
If you guys have any other solutions or comments please let me know and I would be happy to consider them. Thank you for your time and have a good day.
Michael
07-27-2010 03:24 PM
When you tried using shared variables, where did you host them? I can't test it, but I think this will work if you host the shared variables on the cRIO. There might also be a way to have only one of the PCs host them and then access them from the other PC.
07-28-2010 07:20 AM
Thank you for the response. If what you are saying is possible, then I am unaware of it. I scanned through the options for the shared variables and did not see an option that would produce the results you are describing. That being said, I do believe that this should be possible. If you, or anyone else, could let me know how to do this that would be great. Thank you again.
Michael
07-28-2010 09:20 AM
In my opinion the best way is to us TCP IP betwenn your RT-System and Host. How to send your data from RT to host please see the screenshots!
07-28-2010 09:37 AM
You might also check out the Simple Messaging Reference Library. It's a messaging system built on top of TCP that makes it a little easier to manage and use. It's quite popular, and you can view the source if you want to understand what it's doing or tinker with it a little.
07-28-2010 11:25 AM
Do you know which system hosts the shared variables in your setup? Which target contains the shared variable library?
07-28-2010 12:07 PM
Thank you all for the responses.
FHM - I figured that is what the final solution was going to be. I have done UDP in the past with other projects and assumed that TCP is relatively the same and judging by the screen shot, it is. Thank you for the screen shot!
Jarrod - I haven't heard of the "Simple Messaging Reference Library" but if it makes TCP easier to work with it sounds like a good solution to me. I will check it out and hopefully the solution will be easy to implement.
Nathand - In my setup both systems are hosting the variables in my setup and that is where the problem is stemming. In order to use the same variables in different projects, the library has to be included in each project (from my understanding). Therefore when a project is deployed to run, the corresponding VI that uses those variables starts the variable server on whatever machine-type it is running on (Windows, RTOS, etc...). Then when the next project starts its own variable server with the same variables, but since there are two separate copies of the variables the data is never passed. Unless there is some way to specify where to run the variable server and cause projects to not deploy that server but rather just access the one created, then the possibility of this working using shared variables increases. Until there is a way presented to do that, I am not sure that is going to be a feasible solution.
Thank you for the responses. If there is someone that can do the above with a network published shared variable (which would be the easiest solution with the least coding) please let me know. Thank you again.
Michael
07-28-2010 12:21 PM
You want the cRIO to host the shared variables, not the Windows systems. That makes the cRIO the central source for your data, and both Windows projects can subscribe to that data without interfering with each other. You do need the shared variable library in each project, but you can put it inside the cRIO target rather than inside My Computer as shown in this screenshot.
07-28-2010 01:19 PM
I have exactly what you have in the picture but the problem lies in my other project. I have a completely separate project that needs to use the same variables. So in order to use those variables in that project I need to put that library in another VI, which causes both servers to start. In essence I have two of the pictures you have above.
07-28-2010 01:30 PM
When you start the second project, are you re-deploying to the cRIO? I would expect that if you run only the Windows VI in the second project, it will not re-deploy variables to the cRIO and will instead connect to the existing, running shared variable engine. If that doesn't work, you could also try the "enable aliasing" option which should allow you to bind your shared variable to the PSP URL of a variable hosted on the cRIO.