Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading PNI FieldForce TCM sensor data in C++ in real time

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

0 Kudos
Message 1 of 5
(4,331 Views)

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

Software Engineer
National Instruments
0 Kudos
Message 2 of 5
(4,313 Views)

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

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

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

Software Engineer
National Instruments
0 Kudos
Message 4 of 5
(4,200 Views)

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.  

0 Kudos
Message 5 of 5
(4,143 Views)