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

Hi Matt,

 

Yes the VI Library functioned properly & we are now able to control the Haptic Device through the LabVIEW VIs. We can open it, close it & also give it the force values to control its motion.

 

However, what now we want is the following:-

 

We have a Master LabVIEW VI by which we are measuring the EMG signals, when we are pushing the Haptic Device with our hands. We are using NI 9234 DAQ device for this application. The corresponding LabVIEW program is titled "ECEN 4313 Project Source Code" attached with this email.

 

The function of the Haptic Device is to simulataneously measure the Force generated & the Position of the Human Hand, when the hand pushes the

Haptic Device. The corresponding MSVC++ code doing this is titled "CHAI 3D MSVC++ Code for saving the Force and Position Data from the Novint Falcon Haptic Device" attached with this email.

 

What we want is that the VI "ECEN 4313 Project Source Code", when stopped should immediately send a command to the Novint Falcon Haptic Device to also close at the same instant and stop recording the Force & Position data, so that we can exactly do a mapping of the recorded EMG with the Force & Position generated by the device. 

 

The LabVIEW program that you have sent us in the "hdFalcon Folder.zip" is not saving the Force & the Position data. We are able to set some Force values, but not able to tabulate the Force what we are exerting to the Haptic Device.

 

This whole application should happen in LabVIEW to make the system completely Real-Time & thus avoid any delays.

 

Thanks,

Sauvik Das Gupta

0 Kudos
Message 11 of 25
(3,424 Views)

@Sauvik wrote:

The LabVIEW program that you have sent us in the "hdFalcon Folder.zip" is not saving the Force & the Position data. We are able to set some Force values, but not able to tabulate the Force what we are exerting to the Haptic Device.

 

This whole application should happen in LabVIEW to make the system completely Real-Time & thus avoid any delays.


I'm not sure I understand this, can you elaborate. You would like the LabVIEW program to save force and position data of the heptic device? How did you used to save the data before? Did the c++ code used to do that? I did not see anywhere in the c++ code where that was logged. I only saw it displayed.

 

The other issue is that the Falcon dll doesn't actually offer force data, all it returns is the position data. If you want force data the dll will have to be modified to return that.

 

Now say we are able to get the force data, does this data need to be in a waveform or can the samples have irregular times between them. The reason is that I don't see in the Chai code a way to get waveforms, only a bunch of single samples and therefore there'll be different times between different samples.


@Sauvik wrote:

What we want is that the VI "ECEN 4313 Project Source Code", when stopped should immediately send a command to the Novint Falcon Haptic Device to also close at the same instant and stop recording the Force & Position data, so that we can exactly do a mapping of the recorded EMG with the Force & Position generated by the device.

That should be simple since all you have to do is place the close vi that I previously attached after the loop has finished running. However, you cannot mix the c++ code with the dll. If you want to close the device using the dll you'll have to open it with the dll open vi as well.

 

However, before we do that there's some more questions. When you say say "immediately" how immediate does it need to be? In the order of microseconds? Milliseconds? Seconds? Because both the NI 9234 and heptic devices are controlled over USB when you tell each USB device to stop you'll get at least a few ms between the last data points of each device. USB resolution isn't better than 1ms and you have to add to that the additional delays introduced by each device, so your data time stamps might be off by a few ms.

 

Matt

0 Kudos
Message 12 of 25
(3,417 Views)

Hello Matt,

 

Thanks for your reply. 

 

Apart from dll file, we have an .exe file which opens the haptic device and saves the force data. It is an executable version of C++ code that I sent to you earlier. Please find the edited code attached to this reply.

 

As you can see, at the beginning we are running the VI & opening the Haptic Device(by opening .exe file using system Exec block). Then inside the While Loop we are acquiring the Electro-Myo-Graphy(EMG) signals & doing some Signal Processing. So the starting time of both (EMG and Force recording) is same now.

 

Now can you suggest some solution to close the .exe file when the loop is finished and execution comes out of it so that the ending time will also be the same? 

 

Thanks,

Sauvik Das Gupta

0 Kudos
Message 13 of 25
(3,406 Views)

To answer this I first need to know what kind of time tolerance you need, i.e. does your data require accuracy within ms, microseconds, or seconds? There will always some uncertainty between the LabVIEW time stamps and the chai data because they are generated with different devices with no common clock, but with different ways of control (i.e. LabVIEW + chai exe vs. LabVIEW + dll only) you can reduce this uncertainty.

 

For instance, although in the VI you call the exe and start sampling from the NI DAQ device at almost the same time, I'd bet that the exe takes at least a few hundred ms to actually start saving the data because it takes time for it to load and prepre the device etc. So the data from the NI DAQ device and heptic device aren't actually starting at the same time.

 

Also, can you please upload a sample of the logfile saved by the exe (I want to see how the force data in the log is time stamped) because I'm curious how regular the chai exe saves data points.

 

Meanwhile I'll code up a simple way using your current setup (chai exe + LabVIEW) that will let you close the chai exe from LabVIEW directly. I'll add some methods to a dll which will let you start data collection form the heptic device with much better timing accuracy than simply callling the exe using the System Exec VI.

 

Matt

0 Kudos
Message 14 of 25
(3,401 Views)

I believe I'm finished writing the code. However, I think that because I don't have the device and this is 32 bit while the falcon driver I insalled on my computer is 64 bit it returns an error when I try to run it. So please try to run the open device VI attached. If LabVIEW doesn't return an error when you run it I'll post the complete project.

 

Matt

0 Kudos
Message 15 of 25
(3,387 Views)

Hi Matt,

 

We tried to download your Program & run it. However, we are also getting an error. I have attached the Screenshots of the errors we are getting.

 

Thanks,

Sauvik

 

 

 

0 Kudos
Message 16 of 25
(3,382 Views)

Hi Matt,

 

We are trying to achieve data accuracy at least within Miliseconds, if not, Microseconds. 

 

To second you, I also think that although in the VI we call the exe and start sampling from the NI DAQ device at almost the same time, the exe takes considerable amount of time to actually start saving the data, which we can see visually.

 

Also, to let you know, the MSVC++ code in CHAI 3D does not save the force & position data on its own. We have modified the program and given it the Time Stamps, so that it can record the Force & Position Data from the haptic device, after we run the experiments. 

 

I have attached the CHAI 3D Program(modified) and the sample Force & Position Log File saved by the program.

 

Thanks,

Sauvik Das Gupta

 

 

 

Download All
0 Kudos
Message 17 of 25
(3,380 Views)

You get this error because you're missing a MS dll. Download the visual studio distributable here (http://www.microsoft.com/download/en/details.aspx?id=5555) and try again.

 

 

Matt

0 Kudos
Message 18 of 25
(3,379 Views)

Hi Matt,

 

Yes we downloaded the MSVC++ installer package. Now there is no error in running the VI.

 

Can you post the entire project now?

 

Thanks,

Sauvik

 

 

0 Kudos
Message 19 of 25
(3,376 Views)

In case you didn't see it, when I replied to this thread, it created a new thread out of the reply here: http://forums.ni.com/t5/Measurement-Studio-for-VC/Re-Synchronizing-Chai-3D-program-run-in-Microsoft-...

0 Kudos
Message 20 of 25
(3,357 Views)