11-06-2011 02:49 PM
Hi everyone,
I am using an orientation tracker sensor from PNI corporation (which has a driver for using in LabVIEW) to track the orientation of some equipment that I mount the sensor on. I was using C++ for acquiring data from the sensor and run an animation (using OSG) based on those data. Now, I am trying to collect the data using LabVIEW and receiving those data in C++ in real time to play the animation simultaneously. Can anybody help me how can I read the data in real time in C++ from LabVIEW?
p.s1: the sensor uses serial port and I can read the data in LabVIEW using the specific driver.
p.s2: I think Justin_P knows the answer! 🙂
p.s: I am a new member and it is my first post. Sorry if I am not familiar with the forum rules.
Thanks,
Reza
11-10-2011 08:58 AM
Hello Reza,
This is Andrew Brown, an Applications Engineer from National Instruments. One idea you could explore is calling a LabVIEW program built into a shared library from C++. An overview of this method is Calling LabVIEW VIs from Other Programming Languages. Alternately, you could use LabVIEW for both data collection and animation display using 3D picture controls. A good article for this idea is Create Advanced User Interfaces with OpenGL Based 3D Visualization.
Please let me know if you have questions about these methods (or about other potential methods).
Regards,
Andrew Brown
12-20-2011 12:42 AM
Hi Andrew,
Thanks for your solution and sorry for long delay in my reply. Actually, I am now using ActiveX technology to communicate between LabVIEW and VS C++ which I think fits better for my purpose. I have a question though. Now I can communicate between my C++ code and a simple LabVIEW code. But what I want to do, is to collect data using LabVIEW and pass the data continuously to my C++ code to run my OpenSceneGraph code. Is there any C++ sample code in NI website that uses the flow of data coming from LabVIEW for any purpose?
Thanks,
Reza
12-21-2011 11:56 AM
Hello Reza,
I have not been able to locate sample C++ code that parses LabVIEW data. However, I have located several good resources on passing information and the general process to parse this data. First, an excellent method of passing large amounts of data between your programs is to use TCP communication. This ideas is overviewed in this article, while more details are contained here.
Next, a good method of structuring the data passed is to flatten the data to a byte array using the Flatten to String function. The resulting set of bytes can then be parsed by the C++ program.
Finally, an article containing ideas related to reading LabVIEW data in a text-based program can be found here. I understand that it does not reference C++ functions, but it should provide the general concepts.
Regards,
Andrew Brown
12-30-2011 03:03 PM
Reza.a,
I am curious as to how you got the compass working. I'd like to see your C++ code if you do not mind sharing.
We have the same compass and are planning on using on a AUV but have had no luck. Though we can get the TCMStudio working fine.
Good luck with your programming.
Thank You.