Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing Chai 3D( program run in Microsoft Visual studio 2008)and LABVIEW

Hello,

 

I am doing research on controlling Haptic device using EMG signals. Data acquisition of EMG signals is done using labVIEW and control of Haptic device is done using CHAI 3D which is basically a program run in Microsoft Visual studio 2008. I have problem in synchronizing both softwares.

It would be great if you could suggest a way to synchronize Visual studio and LabVIEW. 

Please find the code of CHAI 3D attached to this post.

 

Thanks & Regards,

Haritha Srinivasan

0 Kudos
Message 1 of 25
(8,329 Views)

Hello Sauvik,

 

Thanks for the question.  Can you clarify what you mean by synchronizing Visual Studio and LabVIEW?  Are you trying to control the haptic device using CHAI 3D?  Is it possible to do this in LabVIEW instead?  You can check our instrument drivers to see if there is already one created for your device.

 

Can you also provide additional information for your application?  For example, are you trying to trigger the haptic device based on muscle contraction?

 

Thanks,

 

Lisa

Applications Engineer
National Instruments
0 Kudos
Message 2 of 25
(8,323 Views)

Hi Lisa,

 

By synchronizing what we mean is as follows:-

 

We are collecting the surface EMG signals from human hands through NI 9234 DAQ Board & LabVIEW. At the same time, we are exerting some force on the Novint Falcon Haptic Device with the same hand from which EMG is collected. This Haptic Device runs on CHAI 3D, in which the code is written in Microsoft Visual Studio 2008.

 

Now, when we stop our LabVIEW program(after 1 instance of the experiment), we need that program to send out a command to the Haptic Device(controlled using CHAI 3D) to stop the program of force collection; so that the Time Stamp for both EMG & Force collection is the same.

 

We checked the Instrument Drivers list too. We couldn't find any such support drivers.

 

Can you suggest any solution for this?

 

Thanks & Regards,

Sauvik Das Gupta

 

0 Kudos
Message 3 of 25
(8,316 Views)

Sauvik,

 

It looks like the haptic device is a plug and play instrument, so you can use LabVIEW's basic VISA functions to communicate directly with the device.  An easier option may be for you to directly call the DLLs used by the 3rd party software in LabVIEW.  You would need to check to see which DLLs you need and use the Call Library Function Node in LabVIEW to use them.  Please see this document on calling DLLs for more information.

 

Lisa

Applications Engineer
National Instruments
0 Kudos
Message 4 of 25
(8,305 Views)

Hi Lisa,

 

Do we need to modify the Visual C++ code of Chai 3D in any way, to call it from LabVIEW using the Call Library Function Node?

 

Can you explain in a bit more detailed way in this matter? I have not created a DLL file & called into LabVIEW before this.

 

Thanks,

Sauvik

 

0 Kudos
Message 5 of 25
(8,292 Views)

I can probably help you write the dll and get it into LabVIEW, but you'll have to describe your code a bit better and maybe post an example of your c++ code.

 

What I imagine you have is an exe built with MSVC++ that does some work and you'd like it to do something based on a signal from LabVIEW. If you want to use a dll the easiest way to do this (that I know) is to in your C++ exe code wait for for a named event which when signaled tells your c++ code to do the task (i.e. stop sampling). Then all the dll does is when called from LabVIEW it signals the named event

 

Are you comfortable with c++?

 

Matt

0 Kudos
Message 6 of 25
(8,290 Views)

Hi Matt,

 

Yes we have a MSVC++ File (that runs in Chai 3D), by which we control a Haptic Device called Novint Falcon. Our project is based on Real-time & simultaneous acquisition of Hand Force & EMG data while we are making some gestures from the Human Arm.

 

Now, we are measuring the EMG signals & acquiring by NI 9234 with the help of a program written in LabVIEW. The corresponding Force signals(for the EMG) are recorded by the Novint Falcon Haptic device(controlled by CHAI 3D, written in MSVC++).

 

What we need is as soon as we are stopping our LabVIEW program(at the end of our experiment), the LabVIEW program should generate a signal to the MSVC++ program of CHAI 3D, so that the Haptic Device stops recording the Force, at the same instant when we are stopping to record the EMG signals. There should not be any delay between the stoppages of these two programs.

 

Now what we found was that there are some already built-in DLL files inside the Bins of the Novint Falcon Haptic Device. So we tried to call the hdFalcon Open Dll file & then tried to call that file into LabVIEW using the Call Library Function Node. However, the error 1097 popped out. Also when we are trying to access the other built-in DLL files, it is crashing & stopping the LabVIEW completely.

 

Can you provide a solution to our problem now? Do you need our program written in MSVC++ code in CHAI 3D for that?

 

I am also attaching a Screenshot of the Error we are facing.

 

Thanks,

Sauvik Das Gupta

 

 

 

0 Kudos
Message 7 of 25
(8,282 Views)

Ok, then you should be able to solve it once you are able to load and control the dlls from LabVIEW, right? If you can access the functions in the dlls, will these functions be enough?

 

I looked at the header file for the hdFalconOpen function (\chai3d-2.0.0\external\hdFalcon\..., it's defined in hdFalcon.cpp) and the reason why LV crahsed is that you didn't import the function properly in LabVIEW. I can show you how to do it, but first when I try to run it complains that's missing a hdl.dll file, persumably because I didn't install the driver. Can you check if that dll is installed on your compuet? Also I need to know which version of LV you're running so that I can save the VI for your version.

 

Matt

0 Kudos
Message 8 of 25
(8,174 Views)

Hi Matt,

 

Yes, we should be able to solve it once we are able to load and control the dlls from LabVIEW. We need to access the functions in the dlls through LabVIEW.

 

hdl.dll file is installed in our system in the Program Files Folder, where the Files for the Novint Falcon Haptic Device are installed. We have also copied hdl.dll file in System 32 of our PC too and loaded it into the system to run the device.

 

We are using LabVIEW 2010 version. Can you send us the VI to call the dlls. into LabVIEW & control all the functions of the Haptic Device?

 

You can also install the Drivers of the Novint Falcon device if you need to.

 

Thanks,

Sauvik Das Gupta

 

0 Kudos
Message 9 of 25
(8,161 Views)

Using the LV shared library import wizard I imported the functions exported in hdFalcon.dll. Each of the functions got their own VI. However, you first have to copy the hdFalcon.dll file into the top folder (I didn't want to post it because of GPL issues). If the VI shows that there's still some errors, you'll have to go into each of the "Call library function" nodes for each VI and reselect the dll from its correct path.

 

Some of the complex functions crashed after it ran, but I think that's because I don't have the device. Let me know if it crahses for you. They did import to LabVIEW properly, however.

 

The reason your VI crahsed is that selecting the function from the list of functions under "function name" is not enough. After you do that you have to go into the Parameters tab and add the parameters for the functions so that the function prototype in the Function tab matches the function declartaion in the header file. See the VIs and the image attached for how the function prototype is supposed to look after you add the proper parameters.

 

If you want to import other Chai3D dlls in LabVIEW I suggest you look at the link posted by Lisa and look at the LabVIEW examples shipped with LabVIEW, they are quite helpful.

 

Let me know if it worked,

Matt

0 Kudos
Message 10 of 25
(8,156 Views)